Modular computer fixes and improvements 2 (#20170)

* Fixes runtime with can_run

* tr
This commit is contained in:
Shadowlight213
2016-08-30 01:43:53 -07:00
committed by AnturK
parent c3f5577eb5
commit e625464e09
8 changed files with 87 additions and 46 deletions
+10
View File
@@ -820,6 +820,16 @@
crate_name = "machine prototype crate"
crate_type = /obj/structure/closet/crate/secure
/datum/supply_pack/science/tablets
name = "Tablet Crate"
cost = 5000
contains = list(/obj/item/device/modular_computer/tablet/preset/cargo,
/obj/item/device/modular_computer/tablet/preset/cargo,
/obj/item/device/modular_computer/tablet/preset/cargo,
/obj/item/device/modular_computer/tablet/preset/cargo,
/obj/item/device/modular_computer/tablet/preset/cargo)
crate_name = "tablet crate"
//////////////////////////////////////////////////////////////////////////////
//////////////////////////// Organic /////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -19,3 +19,11 @@
install_component(new /obj/item/weapon/computer_hardware/network_card)
install_component(new /obj/item/weapon/computer_hardware/card_slot)
install_component(new /obj/item/weapon/computer_hardware/printer/mini)
/obj/item/device/modular_computer/tablet/preset/cargo/New()
. = ..()
install_component(new /obj/item/weapon/computer_hardware/processor_unit/small)
install_component(new /obj/item/weapon/computer_hardware/battery(src, /obj/item/weapon/stock_parts/cell/computer))
install_component(new /obj/item/weapon/computer_hardware/hard_drive/small)
install_component(new /obj/item/weapon/computer_hardware/network_card)
install_component(new /obj/item/weapon/computer_hardware/printer/mini)
@@ -77,7 +77,7 @@
if(!access_to_check) // No required_access, allow it.
return 1
if(computer.emagged && !transfer) //emags can bypass the execution locks but not the download ones.
if(!transfer && computer && computer.emagged) //emags can bypass the execution locks but not the download ones.
return 1
if(IsAdminGhost(user))
@@ -170,7 +170,7 @@ var/global/nttransfer_uid = 0
data["uploading"] = 1
data["upload_uid"] = unique_token
data["upload_clients"] = connected_clients.len
data["haspassword"] = server_password ? 1 : 0
data["upload_haspassword"] = server_password ? 1 : 0
data["upload_filename"] = "[provided_file.filename].[provided_file.filetype]"
else if (upload_menu)
var/list/all_files[0]
+25 -20
View File
@@ -178,6 +178,9 @@
if("clean_order")
reset_order()
return 1
if("purchase")
try_purchase()
return 1
if((state != 1) && devtype) // Following IFs should only be usable when in the Select Loadout mode
return 0
switch(action)
@@ -240,38 +243,21 @@ obj/machinery/lapvend/attackby(obj/item/I as obj, mob/user as mob)
if(!user.drop_item(c))
return
credits += c.value
visible_message("<span class='info'><span class='name'>[usr]</span> inserts [c.value] credits into the [src].</span>")
qdel(c)
return
var/obj/item/weapon/card/id/D = I.GetID()
// Awaiting payment state
if(state == 2 && D)
if(process_payment(D,I))
fabricate_and_recalc_price(1)
if((devtype == 1) && fabricated_laptop)
fabricated_laptop.forceMove(src.loc)
fabricated_laptop = null
else if((devtype == 2) && fabricated_tablet)
fabricated_tablet.forceMove(src.loc)
fabricated_tablet = null
say("Enjoy your new product!")
state = 3
return 1
return 0
return ..()
// Simplified payment processing, returns 1 on success.
/obj/machinery/lapvend/proc/process_payment(obj/item/weapon/card/id/I, obj/item/ID_container, obj/item/stack/spacecash)
/obj/machinery/lapvend/proc/process_payment()
if(total_price > credits)
say("Insufficient credits.")
return 0
else
return 1
visible_message("<span class='info'>\The [usr] swipes \the [I] through \the [src].</span>")
/obj/machinery/lapvend/ui_data(mob/user)
var/list/data = list()
@@ -287,5 +273,24 @@ obj/machinery/lapvend/attackby(obj/item/I as obj, mob/user as mob)
data["hw_cpu"] = dev_cpu
if(state == 1 || state == 2)
data["totalprice"] = total_price
data["credits"] = credits
return data
return data
/obj/machinery/lapvend/proc/try_purchase()
// Awaiting payment state
if(state == 2)
if(process_payment())
fabricate_and_recalc_price(1)
if((devtype == 1) && fabricated_laptop)
fabricated_laptop.forceMove(src.loc)
fabricated_laptop = null
else if((devtype == 2) && fabricated_tablet)
fabricated_tablet.forceMove(src.loc)
fabricated_tablet = null
credits -= total_price
say("Enjoy your new product!")
state = 3
return 1
return 0
+6 -6
View File
File diff suppressed because one or more lines are too long
+35 -17
View File
@@ -14,43 +14,58 @@
<tr>
<td><b>Current Price:</b>
<td>{{data.totalprice}}C
</tr>
<tr>
<td><b>Battery:</b>
<td><ui-button action='hw_battery' params='{"battery" : "1"}' state='{{data.hw_battery == 1 ? "selected" : null}}'>Standard</ui-button>
<td><ui-button action='hw_battery' params='{"battery" : "2"}' state='{{data.hw_battery == 2 ? "selected" : null}}'>Upgraded</ui-button>
<td><ui-button action='hw_battery' params='{"battery" : "3"}' state='{{data.hw_battery == 3 ? "selected" : null}}'>Advanced</ui-button>
</tr>
<tr>
<td><b>Hard Drive:</b>
<td><ui-button action='hw_disk' params='{"disk" : "1"}' state='{{data.hw_disk == 1 ? "selected" : null}}'>Standard</ui-button>
<td><ui-button action='hw_disk' params='{"disk" : "2"}' state='{{data.hw_disk == 2 ? "selected" : null}}'>Upgraded</ui-button>
<td><ui-button action='hw_disk' params='{"disk" : "3"}' state='{{data.hw_disk == 3 ? "selected" : null}}'>Advanced</ui-button>
</tr>
<tr>
<td><b>Network Card:</b>
<td><ui-button action='hw_netcard' params='{"netcard" : "0"}' state='{{data.hw_netcard == 0 ? "selected" : null}}'>None</ui-button>
<td><ui-button action='hw_netcard' params='{"netcard" : "1"}' state='{{data.hw_netcard == 1 ? "selected" : null}}'>Standard</ui-button>
<td><ui-button action='hw_netcard' params='{"netcard" : "2"}' state='{{data.hw_netcard == 2 ? "selected" : null}}'>Advanced</ui-button>
{{#if data.devtype != 2}} <!-- No tablets -->
<tr>
<td><b>Processor Unit:</b>
<td><ui-button action='hw_cpu' params='{"cpu" : "1"}' state='{{data.hw_cpu == 1 ? "selected" : null}}'>Standard</ui-button>
<td><ui-button action='hw_cpu' params='{"cpu" : "2"}' state='{{data.hw_cpu == 2 ? "selected" : null}}'>Advanced</ui-button>
<tr>
<td><b>Tesla Relay:</b>
<td><ui-button action='hw_tesla' params='{"tesla" : "0"}' state='{{data.hw_tesla == 0 ? "selected" : null}}'>None</ui-button>
<td><ui-button action='hw_tesla' params='{"tesla" : "1"}' state='{{data.hw_tesla == 1 ? "selected" : null}}'>Standard</ui-button>
{{/if}}
</tr>
<tr>
<td><b>Nano Printer:</b>
<td><ui-button action='hw_nanoprint' params='{"print" : "0"}' state='{{data.hw_nanoprint == 0 ? "selected" : null}}'>None</ui-button>
<td><ui-button action='hw_nanoprint' params='{"print" : "1"}' state='{{data.hw_nanoprint == 1 ? "selected" : null}}'>Standard</ui-button>
</tr>
<tr>
<td><b>Card Reader:</b>
<td><ui-button action='hw_card' params='{"card" : "0"}' state='{{data.hw_card == 0 ? "selected" : null}}'>None</ui-button>
<td><ui-button action='hw_card' params='{"card" : "1"}' state='{{data.hw_card == 1 ? "selected" : null}}'>Standard</ui-button>
<tr>
<td><b>Confirm Order:</b>
<td><ui-button action='confirm_order'>CONFIRM</ui-button>
</table>
</tr>
</table>
{{#if data.devtype != 2}} {{! No tablets}}
<table>
<tr>
<td><b>Processor Unit:</b>
<td><ui-button action='hw_cpu' params='{"cpu" : "1"}' state='{{data.hw_cpu == 1 ? "selected" : null}}'>Standard</ui-button>
<td><ui-button action='hw_cpu' params='{"cpu" : "2"}' state='{{data.hw_cpu == 2 ? "selected" : null}}'>Advanced</ui-button>
</tr>
<tr>
<td><b>Tesla Relay:</b>
<td><ui-button action='hw_tesla' params='{"tesla" : "0"}' state='{{data.hw_tesla == 0 ? "selected" : null}}'>None</ui-button>
<td><ui-button action='hw_tesla' params='{"tesla" : "1"}' state='{{data.hw_tesla == 1 ? "selected" : null}}'>Standard</ui-button>
</tr>
</table>
{{/if}}
<table>
<tr>
<td><b>Confirm Order:</b>
<td><ui-button action='confirm_order'>CONFIRM</ui-button>
</tr>
</table>
<hr>
<b>Battery</b> allows your device to operate without external utility power source. Advanced batteries increase battery life.<br>
<b>Hard Drive</b> stores file on your device. Advanced drives can store more files, but use more power, shortening battery life.<br>
@@ -63,9 +78,12 @@
{{elseif data.state == 2}}
<h2>Step 3: Payment</h2>
<b>Your device is now ready for fabrication..</b><br>
<i>Please swipe your identification card to finish purchase.</i><br>
<i>Total price: <b>{{data.totalprice}}C</b></i>
<i>Please ensure the required amount of credits are in the machine, then press purchase.</i><br>
<i>Current credits: <b>{{data.credits}}C</b></i><br>
<i>Total price: <b>{{data.totalprice}}C</b></i><br><br>
<ui-button action='purchase' state='{{data.credits >= data.totalprice ? null : "disabled"}}'>PURCHASE</ui-button>
{{elseif data.state == 3}}
<h2>Step 4: Thank you for your purchase</h2>
<h2>Step 4: Thank you for your purchase</h2><br>
<b>Should you experience any issues with your new device, contact your local network admin for assistance.</b>
{{/if}}
+1 -1
View File
@@ -86,7 +86,7 @@
Server password:
</div>
<div class="itemContent">
{{#if data.haspassword}}
{{#if data.upload_haspassword}}
ENABLED
{{else}}
DISABLED