tgui backend
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* # Get Variable Component
|
||||
*
|
||||
* A component that gets a variable on an object
|
||||
*/
|
||||
/obj/item/circuit_component/get_variable
|
||||
display_name = "Get Variable"
|
||||
desc = "A component that gets a variable on an object."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL|CIRCUIT_FLAG_ADMIN
|
||||
|
||||
/// Entity to get variable of
|
||||
var/datum/port/input/entity
|
||||
|
||||
/// Variable name
|
||||
var/datum/port/input/variable_name
|
||||
|
||||
/// Variable value
|
||||
var/datum/port/output/output_value
|
||||
|
||||
|
||||
/obj/item/circuit_component/get_variable/Initialize()
|
||||
. = ..()
|
||||
entity = add_input_port("Target", PORT_TYPE_ATOM)
|
||||
variable_name = add_input_port("Variable Name", PORT_TYPE_STRING)
|
||||
|
||||
output_value = add_output_port("Output Value", PORT_TYPE_ANY)
|
||||
|
||||
/obj/item/circuit_component/get_variable/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
var/atom/object = entity.value
|
||||
var/var_name = variable_name.value
|
||||
if(!var_name || !object)
|
||||
output_value.set_output(null)
|
||||
return
|
||||
|
||||
if(!object.can_vv_get(var_name) || !(var_name in object.vars))
|
||||
output_value.set_output(null)
|
||||
return
|
||||
|
||||
output_value.set_output(object.vars[var_name])
|
||||
@@ -0,0 +1,72 @@
|
||||
#define COMP_PROC_GLOBAL "Global"
|
||||
#define COMP_PROC_OBJECT "Object"
|
||||
|
||||
|
||||
/**
|
||||
* # Proc Call Component
|
||||
*
|
||||
* A component that calls a proc on an object and outputs the return value
|
||||
*/
|
||||
/obj/item/circuit_component/proccall
|
||||
display_name = "Proc Call"
|
||||
desc = "A component that calls a proc on an object."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL|CIRCUIT_FLAG_ADMIN
|
||||
|
||||
var/datum/port/input/option/proccall_options
|
||||
|
||||
/// Entity to proccall on
|
||||
var/datum/port/input/entity
|
||||
|
||||
/// Proc to call
|
||||
var/datum/port/input/proc_name
|
||||
|
||||
/// Arguments
|
||||
var/datum/port/input/arguments
|
||||
|
||||
/// Returns the output from the proccall
|
||||
var/datum/port/output/output_value
|
||||
|
||||
/obj/item/circuit_component/proccall/populate_options()
|
||||
var/static/list/component_options = list(
|
||||
COMP_PROC_OBJECT,
|
||||
COMP_PROC_GLOBAL,
|
||||
)
|
||||
|
||||
proccall_options = add_option_port("Proccall Options", component_options)
|
||||
|
||||
/obj/item/circuit_component/proccall/Initialize()
|
||||
. = ..()
|
||||
entity = add_input_port("Target", PORT_TYPE_ATOM)
|
||||
proc_name = add_input_port("Proc Name", PORT_TYPE_STRING)
|
||||
arguments = add_input_port("Arguments", PORT_TYPE_LIST)
|
||||
|
||||
output_value = add_output_port("Output Value", PORT_TYPE_ANY)
|
||||
|
||||
/obj/item/circuit_component/proccall/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/called_on
|
||||
if(proccall_options.value == COMP_PROC_OBJECT)
|
||||
called_on = entity.value
|
||||
else
|
||||
called_on = GLOBAL_PROC
|
||||
|
||||
if(!called_on)
|
||||
return
|
||||
|
||||
var/to_invoke = proc_name.value
|
||||
var/params = arguments.value || list()
|
||||
|
||||
if(!to_invoke)
|
||||
return
|
||||
|
||||
GLOB.AdminProcCaller = "CHAT_[parent.display_name]" //_ won't show up in ckeys so it'll never match with a real admin
|
||||
var/result = WrapAdminProcCall(called_on, to_invoke, params)
|
||||
GLOB.AdminProcCaller = null
|
||||
|
||||
output_value.set_output(result)
|
||||
|
||||
#undef COMP_PROC_GLOBAL
|
||||
#undef COMP_PROC_OBJECT
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* # SDQL Component
|
||||
*
|
||||
* A component that performs an sdql operation
|
||||
*/
|
||||
/obj/item/circuit_component/sdql_operation
|
||||
display_name = "SDQL Operation"
|
||||
desc = "A component that performs an SDQL operation when invoked."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL|CIRCUIT_FLAG_ADMIN
|
||||
|
||||
/// SDQL Operation to invoke
|
||||
var/datum/port/input/sdql_operation
|
||||
|
||||
var/datum/port/output/results
|
||||
|
||||
|
||||
/obj/item/circuit_component/sdql_operation/Initialize()
|
||||
. = ..()
|
||||
sdql_operation = add_input_port("SDQL String", PORT_TYPE_STRING)
|
||||
results = add_output_port("Result", PORT_TYPE_LIST)
|
||||
|
||||
/obj/item/circuit_component/sdql_operation/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/operation = sdql_operation.value
|
||||
|
||||
if(GLOB.AdminProcCaller || !operation)
|
||||
return TRUE
|
||||
|
||||
GLOB.AdminProcCaller = "CHAT_[parent.display_name]" //_ won't show up in ckeys so it'll never match with a real admin
|
||||
var/list/result = world.SDQL2_query(operation, parent.get_creator_admin(), parent.get_creator())
|
||||
GLOB.AdminProcCaller = null
|
||||
|
||||
results.set_output(result)
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* # Set Variable Component
|
||||
*
|
||||
* A component that sets a variable on an object
|
||||
*/
|
||||
/obj/item/circuit_component/set_variable
|
||||
display_name = "Set Variable"
|
||||
desc = "A component that sets a variable on an object."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL|CIRCUIT_FLAG_ADMIN
|
||||
|
||||
/// Entity to set variable of
|
||||
var/datum/port/input/entity
|
||||
|
||||
/// Variable name
|
||||
var/datum/port/input/variable_name
|
||||
|
||||
/// New value to set the variable name to.
|
||||
var/datum/port/input/new_value
|
||||
|
||||
|
||||
/obj/item/circuit_component/set_variable/Initialize()
|
||||
. = ..()
|
||||
entity = add_input_port("Target", PORT_TYPE_ATOM)
|
||||
variable_name = add_input_port("Variable Name", PORT_TYPE_STRING)
|
||||
new_value = add_input_port("New Value", PORT_TYPE_ANY)
|
||||
|
||||
/obj/item/circuit_component/set_variable/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
var/atom/object = entity.value
|
||||
var/var_name = variable_name.value
|
||||
if(!var_name || !object)
|
||||
return
|
||||
|
||||
object.vv_edit_var(var_name, new_value.value)
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* # Spawn Atom Component
|
||||
*
|
||||
* Spawns an atom.
|
||||
*/
|
||||
/obj/item/circuit_component/spawn_atom
|
||||
display_name = "Spawn Atom"
|
||||
desc = "Spawns an atom at a desired location"
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL|CIRCUIT_FLAG_ADMIN
|
||||
|
||||
/// The input path to convert into a typepath
|
||||
var/datum/port/input/input_path
|
||||
|
||||
/// The turf to spawn them at
|
||||
var/datum/port/input/spawn_at
|
||||
|
||||
/// Parameters to pass to the atom being spawned
|
||||
var/datum/port/input/parameters
|
||||
|
||||
/// The result from the output
|
||||
var/datum/port/output/spawned_atom
|
||||
|
||||
/obj/item/circuit_component/spawn_atom/Initialize()
|
||||
. = ..()
|
||||
input_path = add_input_port("Type", PORT_TYPE_ANY)
|
||||
spawn_at = add_input_port("Spawn At", PORT_TYPE_ATOM)
|
||||
parameters = add_input_port("Parameters", PORT_TYPE_LIST)
|
||||
|
||||
spawned_atom = add_output_port("Spawned Atom", PORT_TYPE_ATOM)
|
||||
|
||||
/obj/item/circuit_component/spawn_atom/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/typepath = input_path.value
|
||||
|
||||
if(!ispath(typepath, /atom))
|
||||
return
|
||||
|
||||
var/list/params = parameters.value
|
||||
if(!params)
|
||||
params = list()
|
||||
|
||||
params.Insert(1, spawn_at.value)
|
||||
|
||||
spawned_atom.set_output(new typepath(arglist(params)))
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* # To Type Component
|
||||
*
|
||||
* Converts a string into a typepath. Useful for adding components.
|
||||
*/
|
||||
/obj/item/circuit_component/to_type
|
||||
display_name = "String To Type"
|
||||
desc = "Converts a string into a typepath. Useful for adding components."
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL|CIRCUIT_FLAG_ADMIN
|
||||
|
||||
/// The input path to convert into a typepath
|
||||
var/datum/port/input/input_path
|
||||
|
||||
/// The type output
|
||||
var/datum/port/output/type_output
|
||||
|
||||
/obj/item/circuit_component/to_type/Initialize()
|
||||
. = ..()
|
||||
input_path = add_input_port("Type", PORT_TYPE_STRING)
|
||||
type_output = add_output_port("Typepath", PORT_TYPE_ANY)
|
||||
|
||||
/obj/item/circuit_component/to_type/input_received(datum/port/input/port)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
type_output.set_output(text2path(input_path.value))
|
||||
|
||||
Reference in New Issue
Block a user