mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-09 16:07:40 +00:00
131 lines
4.1 KiB
Plaintext
131 lines
4.1 KiB
Plaintext
/obj/machinery/computer/launchpad
|
|
name = "launchpad control console"
|
|
desc = "Used to teleport objects to and from a launchpad."
|
|
icon_screen = "teleport"
|
|
icon_keyboard = "teleport_key"
|
|
circuit = /obj/item/circuitboard/computer/launchpad_console
|
|
ui_x = 475
|
|
ui_y = 260
|
|
|
|
var/selected_id
|
|
var/list/obj/machinery/launchpad/launchpads
|
|
var/maximum_pads = 4
|
|
|
|
/obj/machinery/computer/launchpad/Initialize()
|
|
launchpads = list()
|
|
. = ..()
|
|
|
|
/obj/machinery/computer/launchpad/attack_paw(mob/user)
|
|
to_chat(user, "<span class='warning'>You are too primitive to use this computer!</span>")
|
|
return
|
|
|
|
/obj/machinery/computer/launchpad/attackby(obj/item/W, mob/user, params)
|
|
if(W.tool_behaviour == TOOL_MULTITOOL)
|
|
if(!multitool_check_buffer(user, W))
|
|
return
|
|
var/obj/item/multitool/M = W
|
|
if(M.buffer && istype(M.buffer, /obj/machinery/launchpad))
|
|
if(LAZYLEN(launchpads) < maximum_pads)
|
|
launchpads |= M.buffer
|
|
M.buffer = null
|
|
to_chat(user, "<span class='notice'>You upload the data from the [W.name]'s buffer.</span>")
|
|
else
|
|
to_chat(user, "<span class='warning'>[src] cannot handle any more connections!</span>")
|
|
else
|
|
return ..()
|
|
|
|
/obj/machinery/computer/launchpad/proc/pad_exists(number)
|
|
var/obj/machinery/launchpad/pad = launchpads[number]
|
|
if(QDELETED(pad))
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/obj/machinery/computer/launchpad/proc/teleport(mob/user, obj/machinery/launchpad/pad, sending)
|
|
if(QDELETED(pad))
|
|
to_chat(user, "<span class='warning'>ERROR: Launchpad not responding. Check launchpad integrity.</span>")
|
|
return
|
|
if(!pad.isAvailable())
|
|
to_chat(user, "<span class='warning'>ERROR: Launchpad not operative. Make sure the launchpad is ready and powered.</span>")
|
|
return
|
|
pad.doteleport(user, sending)
|
|
|
|
/obj/machinery/computer/launchpad/proc/get_pad(number)
|
|
var/obj/machinery/launchpad/pad = launchpads[number]
|
|
return pad
|
|
|
|
/obj/machinery/computer/launchpad/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
|
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
|
if(!ui)
|
|
ui = new(user, src, ui_key, "launchpad_console", name, ui_x, ui_y, master_ui, state)
|
|
ui.open()
|
|
|
|
/obj/machinery/computer/launchpad/ui_data(mob/user)
|
|
var/list/data = list()
|
|
var/list/pad_list = list()
|
|
for(var/i in 1 to LAZYLEN(launchpads))
|
|
if(pad_exists(i))
|
|
var/obj/machinery/launchpad/pad = get_pad(i)
|
|
var/list/this_pad = list()
|
|
this_pad["name"] = pad.display_name
|
|
this_pad["id"] = i
|
|
if(pad.stat & NOPOWER)
|
|
this_pad["inactive"] = TRUE
|
|
pad_list += list(this_pad)
|
|
else
|
|
launchpads -= get_pad(i)
|
|
data["launchpads"] = pad_list
|
|
data["selected_id"] = selected_id
|
|
if(selected_id)
|
|
var/obj/machinery/launchpad/current_pad = launchpads[selected_id]
|
|
data["x"] = current_pad.x_offset
|
|
data["y"] = current_pad.y_offset
|
|
data["pad_name"] = current_pad.display_name
|
|
data["range"] = current_pad.range
|
|
data["selected_pad"] = current_pad
|
|
if(QDELETED(current_pad) || (current_pad.stat & NOPOWER))
|
|
data["pad_active"] = FALSE
|
|
return data
|
|
data["pad_active"] = TRUE
|
|
|
|
return data
|
|
|
|
/obj/machinery/computer/launchpad/ui_act(action, params)
|
|
if(..())
|
|
return
|
|
var/obj/machinery/launchpad/current_pad = launchpads[selected_id]
|
|
switch(action)
|
|
if("select_pad")
|
|
selected_id = text2num(params["id"])
|
|
. = TRUE
|
|
if("set_pos")
|
|
var/new_x = text2num(params["x"])
|
|
var/new_y = text2num(params["y"])
|
|
current_pad.set_offset(new_x, new_y)
|
|
. = TRUE
|
|
if("move_pos")
|
|
var/plus_x = text2num(params["x"])
|
|
var/plus_y = text2num(params["y"])
|
|
current_pad.set_offset(
|
|
x = current_pad.x_offset + plus_x,
|
|
y = current_pad.y_offset + plus_y
|
|
)
|
|
. = TRUE
|
|
if("rename")
|
|
. = TRUE
|
|
var/new_name = params["name"]
|
|
if(!new_name)
|
|
return
|
|
current_pad.display_name = new_name
|
|
if("remove")
|
|
if(usr && alert(usr, "Are you sure?", "Unlink Launchpad", "I'm Sure", "Abort") != "Abort")
|
|
launchpads -= current_pad
|
|
selected_id = null
|
|
. = TRUE
|
|
if("launch")
|
|
teleport(usr, current_pad, TRUE)
|
|
. = TRUE
|
|
|
|
if("pull")
|
|
teleport(usr, current_pad, FALSE)
|
|
. = TRUE
|
|
. = TRUE |