Files
Bubberstation/code/datums/components/paintable.dm
Rob Bailey 2029163d33 playsound vary boolean define conversion (#46254)
About The Pull Request

Converts every single usage of playsound's vary parameter to use the boolean define instead of 1 or 0. I'm tired of people copypasting the incorrect usage.
Also changes a couple of places where a list was picked from instead of using get_sfx internal calls

This was done via regex:
(playsound\(.+,.+,.+, ?)1( ?\)| ?,.+\)) to match 1
(playsound\(.+,.+,.+, ?)0( ?\)| ?,.+\)) to match 0
full sed commands:
/(playsound\(.+,.+,.+, ?)1( ?\)| ?,.+\))/\1TRUE\2/ 1 to TRUE
/(playsound\(.+,.+,.+, ?)0( ?\)| ?,.+\))/\1FALSE\2/ 0 to FALSE

I'm not very good with regex and these could probably be optimized, but they worked.
Why It's Good For The Game

Code usability
2019-08-30 18:45:20 +12:00

30 lines
1.0 KiB
Plaintext

/datum/component/spraycan_paintable
var/current_paint
/datum/component/spraycan_paintable/Initialize()
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, .proc/Repaint)
/datum/component/spraycan_paintable/Destroy()
RemoveCurrentCoat()
return ..()
/datum/component/spraycan_paintable/proc/RemoveCurrentCoat()
var/atom/A = parent
A.remove_atom_colour(FIXED_COLOUR_PRIORITY, current_paint)
/datum/component/spraycan_paintable/proc/Repaint(datum/source, obj/item/toy/crayon/spraycan/spraycan, mob/living/user)
if(!istype(spraycan) || user.a_intent == INTENT_HARM)
return
. = COMPONENT_NO_AFTERATTACK
if(spraycan.is_capped)
to_chat(user, "<span class='warning'>Take the cap off first!</span>")
return
RemoveCurrentCoat()
if(spraycan.use_charges(user, 2))
var/colour = spraycan.paint_color
current_paint = colour
var/atom/A = parent
A.add_atom_colour(colour, FIXED_COLOUR_PRIORITY)
playsound(spraycan, 'sound/effects/spray.ogg', 5, TRUE, 5)
to_chat(user, "<span class='notice'>You spray [spraycan] on [A], painting it.</span>")