mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 07:08:00 +01:00
Modular computers changes (#19928)
* Fixes and documentation. * WIp on laptop vendor * some fixes
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
name = "NTNet Quantum Relay"
|
||||
desc = "A very complex router and transmitter capable of connecting electronic devices together. Looks fragile."
|
||||
use_power = 2
|
||||
active_power_usage = 20000 //20kW, apropriate for machine that keeps massive cross-Zlevel wireless network operational.
|
||||
active_power_usage = 10000 //10kW, apropriate for machine that keeps massive cross-Zlevel wireless network operational. Used to be 20 but that actually drained the smes one round
|
||||
idle_power_usage = 100
|
||||
icon = 'icons/obj/machines/telecomms.dmi'
|
||||
icon_state = "bus"
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
/obj/item/modular_computer/attack_ghost(mob/dead/observer/user)
|
||||
if(enabled)
|
||||
ui_interact(user)
|
||||
else if(check_rights_for(user.client, R_ADMIN))
|
||||
else if(IsAdminGhost(user))
|
||||
var/response = alert(user, "This computer is turned off. Would you like to turn it on?", "Admin Override", "Yes", "No")
|
||||
if(response == "Yes")
|
||||
turn_on(user)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
|
||||
Ok. so a quick rundown on how to make a program. This is kind of a shitty documentation, but oh well I was asked to.
|
||||
|
||||
|
||||
This is how the base program is setup. the rest is mostly tgui stuff. I'll use the ntnetmonitor as a base
|
||||
|
||||
/datum/computer_file/program/ntnetmonitor
|
||||
filename = "ntmonitor" <- This is obviously the name of the file itself. not much to be said
|
||||
filedesc = "NTNet Diagnostics and Monitoring" <- This sort of the official name. it's what shows up on the main menu
|
||||
program_icon_state = "comm_monitor" <- This is what the screen will look like when the program is active
|
||||
extended_desc = "This program is a dummy. <- This is a sort of description, visible when looking on the ntnet
|
||||
size = 12 <- size of the program. Big programs need more hard drive space. Don't make it too big though.
|
||||
requires_ntnet = 1 <- if this is set, the program will not run and will close if ntnet connection is lost. mainly for primarily online programs.
|
||||
required_access = access_network <- This is access required to run the program itself. ONLY SET THIS FOR SUPER SECURE SHIT. This also acts as transfer_access as well.
|
||||
transfer_access = access_change_ids <- this is the access needed to download from ntnet or host on the ptp program. This is what you want to use most of the time.
|
||||
available_on_ntnet = 1 <- If it's available to download on ntnet. pretty self explanatory.
|
||||
available_on_syndinet = 0 <- ditto but on emagged syndie net. Use this for antag programs
|
||||
usage_flags = PROGRAM_ALL // Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
|
||||
^^- The comment above sorta explains it. Use this to limit what kind of machines can run the program. For example, comms program should be limited to consoles and laptops.
|
||||
var/ui_header = "downloader_finished.gif" <- this one is kinda cool. If you have the program minimized, this will show up in the header of the computer screen.
|
||||
you can even have the program change what the header is based on the situation! see alarm.dm for an example.
|
||||
|
||||
|
||||
Now. for pre-installing stuff.
|
||||
|
||||
Primarily done for consoles, there's an install_programs() proc in the console presets file in the machines folder.
|
||||
|
||||
for example, the command console one.
|
||||
|
||||
/obj/machinery/modular_computer/console/preset/command/install_programs()
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/card_mod())
|
||||
|
||||
Basically, you want to do cpu.hard_drive.store_file(new/*program path here*()) and put it in the subtype's install_programs().
|
||||
Probably pretty self explanatory, but just in case.
|
||||
|
||||
Will probably be expanded when new features come around or I get asked to mention something.
|
||||
|
||||
*/
|
||||
@@ -71,6 +71,8 @@
|
||||
battery.charge = battery.maxcharge
|
||||
|
||||
/obj/item/weapon/computer_hardware/battery_module/try_install_component(mob/living/user, obj/item/modular_computer/M, found = 0)
|
||||
if(!user.drop_item(src))
|
||||
return
|
||||
if(M.battery_module)
|
||||
user << "This computer's battery slot is already occupied by \the [M.battery_module]."
|
||||
return
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
..()
|
||||
|
||||
/obj/item/weapon/computer_hardware/card_slot/try_install_component(mob/living/user, obj/item/modular_computer/M, found = 0)
|
||||
if(!user.drop_item(src))
|
||||
return
|
||||
if(M.card_slot)
|
||||
user << "This computer's card slot is already occupied by \the [M.card_slot]."
|
||||
return
|
||||
|
||||
@@ -167,6 +167,8 @@
|
||||
..()
|
||||
|
||||
/obj/item/weapon/computer_hardware/hard_drive/try_install_component(mob/living/user, obj/item/modular_computer/M, found = 0)
|
||||
if(!user.drop_item(src))
|
||||
return
|
||||
if(M.hard_drive)
|
||||
user << "This computer's hard drive slot is already occupied by \the [M.hard_drive]."
|
||||
return
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
..()
|
||||
|
||||
/obj/item/weapon/computer_hardware/nano_printer/try_install_component(mob/living/user, obj/item/modular_computer/M, found = 0)
|
||||
if(!user.drop_item(src))
|
||||
return
|
||||
if(M.nano_printer)
|
||||
user << "This computer's nano printer slot is already occupied by \the [M.nano_printer]."
|
||||
return
|
||||
|
||||
@@ -96,6 +96,8 @@ var/global/ntnet_card_uid = 1
|
||||
..()
|
||||
|
||||
/obj/item/weapon/computer_hardware/network_card/try_install_component(mob/living/user, obj/item/modular_computer/M, found = 0)
|
||||
if(!user.drop_item(src))
|
||||
return
|
||||
if(M.network_card)
|
||||
user << "This computer's network card slot is already occupied by \the [M.network_card]."
|
||||
return
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
|
||||
/obj/item/weapon/computer_hardware/hard_drive/portable/try_install_component(mob/living/user, obj/item/modular_computer/M, found = 0)
|
||||
if(!user.drop_item(src))
|
||||
return
|
||||
if(M.portable_drive)
|
||||
user << "This computer's portable drive slot is already occupied by \the [M.portable_drive]."
|
||||
return
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
origin_tech = list("programming" = 4, "engineering" = 3)
|
||||
|
||||
/obj/item/weapon/computer_hardware/processor_unit/try_install_component(mob/living/user, obj/item/modular_computer/M, found = 0)
|
||||
if(!user.drop_item(src))
|
||||
return
|
||||
if(M.processor_unit)
|
||||
user << "This computer's processor slot is already occupied by \the [M.processor_unit]."
|
||||
return
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
..()
|
||||
|
||||
/obj/item/weapon/computer_hardware/tesla_link/try_install_component(mob/living/user, obj/item/modular_computer/M, found = 0)
|
||||
if(!user.drop_item(src))
|
||||
return
|
||||
if(istype(M, /obj/item/modular_computer/processor))
|
||||
var/obj/item/modular_computer/processor/P = M
|
||||
if(P.machinery_computer.tesla_link)
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
// A vendor machine for modular computer portable devices - Laptops and Tablets
|
||||
|
||||
/obj/machinery/lapvend
|
||||
name = "computer vendor"
|
||||
desc = "A vending machine with microfabricator capable of dispensing various NT-branded computers."
|
||||
icon = 'icons/obj/vending.dmi'
|
||||
icon_state = "robotics"
|
||||
layer = 2.9
|
||||
anchored = 1
|
||||
density = 1
|
||||
|
||||
// The actual laptop/tablet
|
||||
var/obj/machinery/modular_computer/laptop/fabricated_laptop = null
|
||||
var/obj/item/modular_computer/tablet/fabricated_tablet = null
|
||||
|
||||
// Utility vars
|
||||
var/state = 0 // 0: Select device type, 1: Select loadout, 2: Payment, 3: Thankyou screen
|
||||
var/devtype = 0 // 0: None(unselected), 1: Laptop, 2: Tablet
|
||||
var/total_price = 0 // Price of currently vended device.
|
||||
var/credits = 0
|
||||
|
||||
// Device loadout
|
||||
var/dev_cpu = 1 // 1: Default, 2: Upgraded
|
||||
var/dev_battery = 1 // 1: Default, 2: Upgraded, 3: Advanced
|
||||
var/dev_disk = 1 // 1: Default, 2: Upgraded, 3: Advanced
|
||||
var/dev_netcard = 0 // 0: None, 1: Basic, 2: Long-Range
|
||||
var/dev_tesla = 0 // 0: None, 1: Standard (LAPTOP ONLY)
|
||||
var/dev_nanoprint = 0 // 0: None, 1: Standard
|
||||
var/dev_card = 0 // 0: None, 1: Standard
|
||||
|
||||
// Removes all traces of old order and allows you to begin configuration from scratch.
|
||||
/obj/machinery/lapvend/proc/reset_order()
|
||||
state = 0
|
||||
devtype = 0
|
||||
if(fabricated_laptop)
|
||||
qdel(fabricated_laptop)
|
||||
fabricated_laptop = null
|
||||
if(fabricated_tablet)
|
||||
qdel(fabricated_tablet)
|
||||
fabricated_tablet = null
|
||||
dev_cpu = 1
|
||||
dev_battery = 1
|
||||
dev_disk = 1
|
||||
dev_netcard = 0
|
||||
dev_tesla = 0
|
||||
dev_nanoprint = 0
|
||||
dev_card = 0
|
||||
|
||||
// Recalculates the price and optionally even fabricates the device.
|
||||
/obj/machinery/lapvend/proc/fabricate_and_recalc_price(fabricate = 0)
|
||||
total_price = 0
|
||||
if(devtype == 1) // Laptop, generally cheaper to make it accessible for most station roles
|
||||
if(fabricate)
|
||||
fabricated_laptop = new(src)
|
||||
total_price = 99
|
||||
switch(dev_cpu)
|
||||
if(1)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(fabricated_laptop.cpu)
|
||||
if(2)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.processor_unit = new/obj/item/weapon/computer_hardware/processor_unit(fabricated_laptop.cpu)
|
||||
total_price += 299
|
||||
switch(dev_battery)
|
||||
if(1) // Basic(750C)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.battery_module = new/obj/item/weapon/computer_hardware/battery_module(fabricated_laptop.cpu)
|
||||
if(2) // Upgraded(1100C)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.battery_module = new/obj/item/weapon/computer_hardware/battery_module/advanced(fabricated_laptop.cpu)
|
||||
total_price += 199
|
||||
if(3) // Advanced(1500C)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.battery_module = new/obj/item/weapon/computer_hardware/battery_module/super(fabricated_laptop.cpu)
|
||||
total_price += 499
|
||||
switch(dev_disk)
|
||||
if(1) // Basic(128GQ)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive(fabricated_laptop.cpu)
|
||||
if(2) // Upgraded(256GQ)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/advanced(fabricated_laptop.cpu)
|
||||
total_price += 99
|
||||
if(3) // Advanced(512GQ)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/super(fabricated_laptop.cpu)
|
||||
total_price += 299
|
||||
switch(dev_netcard)
|
||||
if(1) // Basic(Short-Range)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.network_card = new/obj/item/weapon/computer_hardware/network_card(fabricated_laptop.cpu)
|
||||
total_price += 99
|
||||
if(2) // Advanced (Long Range)
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.network_card = new/obj/item/weapon/computer_hardware/network_card/advanced(fabricated_laptop.cpu)
|
||||
total_price += 299
|
||||
if(dev_tesla)
|
||||
total_price += 399
|
||||
if(fabricate)
|
||||
fabricated_laptop.tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(fabricated_laptop)
|
||||
if(dev_nanoprint)
|
||||
total_price += 99
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(fabricated_laptop.cpu)
|
||||
if(dev_card)
|
||||
total_price += 199
|
||||
if(fabricate)
|
||||
fabricated_laptop.cpu.card_slot = new/obj/item/weapon/computer_hardware/card_slot(fabricated_laptop.cpu)
|
||||
|
||||
return total_price
|
||||
else if(devtype == 2) // Tablet, more expensive, not everyone could probably afford this.
|
||||
if(fabricate)
|
||||
fabricated_tablet = new(src)
|
||||
fabricated_tablet.processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(fabricated_tablet)
|
||||
total_price = 199
|
||||
switch(dev_battery)
|
||||
if(1) // Basic(300C)
|
||||
if(fabricate)
|
||||
fabricated_tablet.battery_module = new/obj/item/weapon/computer_hardware/battery_module/nano(fabricated_tablet)
|
||||
if(2) // Upgraded(500C)
|
||||
if(fabricate)
|
||||
fabricated_tablet.battery_module = new/obj/item/weapon/computer_hardware/battery_module/micro(fabricated_tablet)
|
||||
total_price += 199
|
||||
if(3) // Advanced(750C)
|
||||
if(fabricate)
|
||||
fabricated_tablet.battery_module = new/obj/item/weapon/computer_hardware/battery_module(fabricated_tablet)
|
||||
total_price += 499
|
||||
switch(dev_disk)
|
||||
if(1) // Basic(32GQ)
|
||||
if(fabricate)
|
||||
fabricated_tablet.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/micro(fabricated_tablet)
|
||||
if(2) // Upgraded(64GQ)
|
||||
if(fabricate)
|
||||
fabricated_tablet.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/small(fabricated_tablet)
|
||||
total_price += 99
|
||||
if(3) // Advanced(128GQ)
|
||||
if(fabricate)
|
||||
fabricated_tablet.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive(fabricated_tablet)
|
||||
total_price += 299
|
||||
switch(dev_netcard)
|
||||
if(1) // Basic(Short-Range)
|
||||
if(fabricate)
|
||||
fabricated_tablet.network_card = new/obj/item/weapon/computer_hardware/network_card(fabricated_tablet)
|
||||
total_price += 99
|
||||
if(2) // Advanced (Long Range)
|
||||
if(fabricate)
|
||||
fabricated_tablet.network_card = new/obj/item/weapon/computer_hardware/network_card/advanced(fabricated_tablet)
|
||||
total_price += 299
|
||||
if(dev_nanoprint)
|
||||
total_price += 99
|
||||
if(fabricate)
|
||||
fabricated_tablet.nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(fabricated_tablet)
|
||||
if(dev_card)
|
||||
total_price += 199
|
||||
if(fabricate)
|
||||
fabricated_tablet.card_slot = new/obj/item/weapon/computer_hardware/card_slot(fabricated_tablet)
|
||||
return total_price
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/obj/machinery/lapvend/ui_act(action, params)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
switch(action)
|
||||
if("pick_device")
|
||||
if(state) // We've already picked a device type
|
||||
return 0
|
||||
devtype = text2num(params["pick"])
|
||||
state = 1
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
if("clean_order")
|
||||
reset_order()
|
||||
return 1
|
||||
if((state != 1) && devtype) // Following IFs should only be usable when in the Select Loadout mode
|
||||
return 0
|
||||
switch(action)
|
||||
if("confirm_order")
|
||||
state = 2 // Wait for ID swipe for payment processing
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
if("hw_cpu")
|
||||
dev_cpu = text2num(params["cpu"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
if("hw_battery")
|
||||
dev_battery = text2num(params["battery"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
if("hw_disk")
|
||||
dev_disk = text2num(params["disk"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
if("hw_netcard")
|
||||
dev_netcard = text2num(params["netcard"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
if("hw_tesla")
|
||||
dev_tesla = text2num(params["tesla"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
if("hw_nanoprint")
|
||||
dev_nanoprint = text2num(params["print"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
if("hw_card")
|
||||
dev_card = text2num(params["card"])
|
||||
fabricate_and_recalc_price(0)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/machinery/lapvend/attack_hand(mob/user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/lapvend/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = default_state)
|
||||
if(stat & (BROKEN | NOPOWER | MAINT))
|
||||
if(ui)
|
||||
ui.close()
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "computer_fabricator", "Personal Computer Vendor", 500, 400, state = state)
|
||||
ui.open()
|
||||
ui.set_autoupdate(state = 1)
|
||||
|
||||
|
||||
obj/machinery/lapvend/attackby(obj/item/I as obj, mob/user as mob)
|
||||
|
||||
if(istype(I,/obj/item/stack/spacecash))
|
||||
var/obj/item/stack/spacecash/c = I
|
||||
|
||||
if(!user.drop_item(c))
|
||||
return
|
||||
credits += c.value
|
||||
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.cpu.battery_module.charge_to_full()
|
||||
fabricated_laptop.forceMove(src.loc)
|
||||
fabricated_laptop.close_laptop()
|
||||
fabricated_laptop = null
|
||||
else if((devtype == 2) && fabricated_tablet)
|
||||
fabricated_tablet.battery_module.charge_to_full()
|
||||
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)
|
||||
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()
|
||||
data["state"] = state
|
||||
if(state == 1)
|
||||
data["devtype"] = devtype
|
||||
data["hw_battery"] = dev_battery
|
||||
data["hw_disk"] = dev_disk
|
||||
data["hw_netcard"] = dev_netcard
|
||||
data["hw_tesla"] = dev_tesla
|
||||
data["hw_nanoprint"] = dev_nanoprint
|
||||
data["hw_card"] = dev_card
|
||||
data["hw_cpu"] = dev_cpu
|
||||
if(state == 1 || state == 2)
|
||||
data["totalprice"] = total_price
|
||||
|
||||
return data
|
||||
Reference in New Issue
Block a user