mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-16 21:23:20 +00:00
Merge pull request #796 from cadyn/kassc-v2
New features for triggers and kbuttons
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
var/nothing_message = "Nothing happens." //Should we send a message if nothing happens when the button is pressed?
|
var/nothing_message = "Nothing happens." //Should we send a message if nothing happens when the button is pressed?
|
||||||
var/nothing_message_span_class = "warning" //Span class used for nothing message, normal ones include notice, warning, and danger.
|
var/nothing_message_span_class = "warning" //Span class used for nothing message, normal ones include notice, warning, and danger.
|
||||||
var/list/trig_targets = list()
|
var/list/trig_targets = list()
|
||||||
|
var/trig_target_is_trigerrer = FALSE //Should we use the button presser as the target?
|
||||||
|
|
||||||
/obj/kbutton/attackby(obj/item/weapon/W, mob/user as mob)
|
/obj/kbutton/attackby(obj/item/weapon/W, mob/user as mob)
|
||||||
return attack_hand(user)
|
return attack_hand(user)
|
||||||
@@ -24,6 +25,8 @@
|
|||||||
/obj/kbutton/attack_hand(mob/user as mob)
|
/obj/kbutton/attack_hand(mob/user as mob)
|
||||||
. = ..()
|
. = ..()
|
||||||
if(can_press(user))
|
if(can_press(user))
|
||||||
|
if(trig_target_is_trigerrer)
|
||||||
|
trig_targets = list(user)
|
||||||
button_trigger()
|
button_trigger()
|
||||||
if(pressed_sound_file)
|
if(pressed_sound_file)
|
||||||
playsound(src, pressed_sound_file, pressed_sound_volume, 1)
|
playsound(src, pressed_sound_file, pressed_sound_volume, 1)
|
||||||
@@ -97,6 +100,17 @@
|
|||||||
/obj/kbutton/single_use/can_press(mob/user)
|
/obj/kbutton/single_use/can_press(mob/user)
|
||||||
return !has_been_pressed
|
return !has_been_pressed
|
||||||
|
|
||||||
|
/obj/kbutton/single_use_per_mob
|
||||||
|
name = "button"
|
||||||
|
var/list/been_triggered_by = list()
|
||||||
|
|
||||||
|
/obj/kbutton/single_use_per_mob/can_press(mob/user)
|
||||||
|
if(user in been_triggered_by)
|
||||||
|
return FALSE
|
||||||
|
else
|
||||||
|
been_triggered_by |= user
|
||||||
|
return TRUE
|
||||||
|
|
||||||
/obj/kbutton/toggle
|
/obj/kbutton/toggle
|
||||||
name = "toggle button"
|
name = "toggle button"
|
||||||
var/toggled = FALSE
|
var/toggled = FALSE
|
||||||
|
|||||||
@@ -1,20 +1,25 @@
|
|||||||
/turf/simulated
|
/turf/simulated
|
||||||
var/triggers = FALSE
|
var/triggers = FALSE
|
||||||
var/list/potential_triggerers = list() //What can set off our trigger?
|
var/list/potential_triggerers = list() //What can set off our trigger?
|
||||||
var/list/trig_target_paths = list() //What are the paths of whatever we want to call our proc on?
|
var/list/trig_target_paths = list() //What are the paths of whatever we want to call our proc on?
|
||||||
var/trig_target_trigger_uid //What is the trigger_uid of whatever we want to call our proc on?
|
var/trig_target_trigger_uid //What is the trigger_uid of whatever we want to call our proc on?
|
||||||
var/trig_proc //What proc do we want to call?
|
var/trig_proc //What proc do we want to call?
|
||||||
var/list/trig_args = list() //What are the arguments for said proc?
|
var/list/trig_args = list() //What are the arguments for said proc?
|
||||||
var/trig_message //Should we send a message to the person who stepped here?
|
var/trig_message //Should we send a message to the person who stepped here?
|
||||||
var/message_span_class = "notice" //If we're gonna send them a message, what span class to use?
|
var/message_span_class = "notice" //If we're gonna send them a message, what span class to use?
|
||||||
var/trig_single_use = FALSE //Is this only a single use trigger, or can it be used multiple times?
|
var/trig_single_use = FALSE //Is this only a single use trigger, or can it be used multiple times?
|
||||||
var/has_been_used = FALSE //Has this trigger been set off yet?
|
var/has_been_used = FALSE //Has this trigger been set off yet?
|
||||||
var/list/trig_targets = list() //This is set automatically if the other target vars are set.
|
var/list/trig_targets = list() //This is set automatically if the other target vars are set.
|
||||||
|
var/list/been_triggered_by = list() //Who has set this off so far?
|
||||||
|
var/trig_single_use_per_triggerer = FALSE //Do we want to make so each atom can only trigger this once?
|
||||||
|
var/trig_target_is_trigerrer = FALSE //Do we want to use the atom that trigerred us as the target?
|
||||||
|
|
||||||
|
|
||||||
/turf/simulated/proc/can_use_trigger(atom/movable/mover)
|
/turf/simulated/proc/can_use_trigger(atom/movable/mover)
|
||||||
if(trig_single_use && has_been_used)
|
if(trig_single_use && has_been_used)
|
||||||
return FALSE
|
return FALSE
|
||||||
|
if(trig_single_use_per_triggerer && (mover in been_triggered_by))
|
||||||
|
return FALSE
|
||||||
if(!potential_triggerers.len)
|
if(!potential_triggerers.len)
|
||||||
return TRUE
|
return TRUE
|
||||||
else
|
else
|
||||||
@@ -29,6 +34,8 @@
|
|||||||
. = ..()
|
. = ..()
|
||||||
if(triggers && can_use_trigger(mover))
|
if(triggers && can_use_trigger(mover))
|
||||||
if(trig_proc)
|
if(trig_proc)
|
||||||
|
if(trig_target_is_trigerrer)
|
||||||
|
trig_targets = list(mover)
|
||||||
if(trig_targets.len)
|
if(trig_targets.len)
|
||||||
var/testname = trig_proc
|
var/testname = trig_proc
|
||||||
//Find one of the 3 possible ways they could have written /proc/PROCNAME
|
//Find one of the 3 possible ways they could have written /proc/PROCNAME
|
||||||
@@ -55,6 +62,7 @@
|
|||||||
if(trig_message)
|
if(trig_message)
|
||||||
to_chat(mover,"<span class='[message_span_class]'>"+trig_message+"</span>")
|
to_chat(mover,"<span class='[message_span_class]'>"+trig_message+"</span>")
|
||||||
has_been_used = TRUE
|
has_been_used = TRUE
|
||||||
|
been_triggered_by |= mover
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user