From a65634a003f3e16e95930e6d68aa72bff24957c5 Mon Sep 17 00:00:00 2001 From: OverDriveZ <64517916+OverDriveZ@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:21:05 +0200 Subject: [PATCH] objs variable edit - iteration I --- code/game/objects/objs.dm | 3 + code/game/objects/objs_set_vars_verbs.dm | 106 +++++++++++++++++++++++ fortune13.dme | 1 + 3 files changed, 110 insertions(+) create mode 100644 code/game/objects/objs_set_vars_verbs.dm diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index 726b3f9f631..504c74224ec 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -37,6 +37,9 @@ var/renamedByPlayer = FALSE //set when a player uses a pen on a renamable object + //Was this item rotated? if so, how much? (only working with Edit Vars verb for now) + var/is_tilted + /obj/vv_edit_var(vname, vval) switch(vname) if("anchored") diff --git a/code/game/objects/objs_set_vars_verbs.dm b/code/game/objects/objs_set_vars_verbs.dm new file mode 100644 index 00000000000..1f9d1c512f4 --- /dev/null +++ b/code/game/objects/objs_set_vars_verbs.dm @@ -0,0 +1,106 @@ +GLOBAL_LIST_INIT(obj_vars_allowed_to_modify, list( + //"None" = 0, + "Pixel Offset" = 1, + "Rotate" = 2, + "Layer" = 3)) + + +/mob/verb/objs_edit_vars(atom/A as obj in view(1)) + set name = "Edit Vars (Shift, Rotate, Layer)." + set category = "Object" + + //Blacklist of stuff that isn't allowed to be modified, such as trees + if( istype(A, /obj/structure/flora) || \ + istype(A, /obj/machinery/door/poddoor/shutters)) + + to_chat(src, span_danger("You can't move that!")) + return + + var/do_after_delay = 1 SECONDS + var/playsound_volume = 50 + var/playsound_audio = 'sound/effects/stonedoor_openclose.ogg' + var/max_pixel_shift_allowed = 16 + var/max_tilt_shift_allowed = 180 + var/max_layer_shift_allowed = 40 + + var/input = input("Choose the variable you would like to edit", "Edit Variables: [src]") as null|anything in GLOB.obj_vars_allowed_to_modify + if(input) + input = GLOB.obj_vars_allowed_to_modify[input] + + switch(input) + if(0) + return + + if(1) //Edit pixel shift + input = input("Choose between coordinate X or Y", "Pixel Shift of: [src]") as null|anything in list("Edit X", "Edit Y", "Reset to initial") + + if(input == "Edit X") + input = input("Insert new pixel offset (-[max_pixel_shift_allowed] to +[max_pixel_shift_allowed]) \nCurrent X: [A.pixel_x]", "[input]:") as null|num + if(input && (input >= -max_pixel_shift_allowed && input <= max_pixel_shift_allowed)) + playsound(A.loc, playsound_audio, playsound_volume, TRUE) + if(do_after(src, do_after_delay, target = A)) + visible_message(span_notice("[src] pushes \the [A] to off-center it to the perfect spot!")) + A.pixel_x = input + else if(input < -max_pixel_shift_allowed || input > max_pixel_shift_allowed) + to_chat(src, span_danger("Selected value is out of allowed bounds!")) + return + return + + else if(input == "Edit Y") + input = input("Insert new pixel offset (-[max_pixel_shift_allowed] to +[max_pixel_shift_allowed]) \nCurrent Y: [A.pixel_y]", "[input]:") as null|num + if(input && (input >= -max_pixel_shift_allowed && input <= max_pixel_shift_allowed)) + playsound(A.loc, playsound_audio, playsound_volume, TRUE) + if(do_after(src, do_after_delay, target = A)) + visible_message(span_notice("[src] pushes \the [A] to off-center it to the perfect spot!")) + A.pixel_y = input + else if(input < -max_pixel_shift_allowed || input > max_pixel_shift_allowed) + to_chat(src, span_danger("Selected value is out of allowed bounds!")) + return + return + + else if(input == "Reset to initial") + playsound(A.loc, playsound_audio, playsound_volume, TRUE) + if(do_after(src, do_after_delay, target = A)) + visible_message(span_notice("[src] pushes \the [A] to its original place!")) + A.pixel_x = initial(A.pixel_x) + A.pixel_y = initial(A.pixel_y) + return + + if(2) //Edit rotation + if(istype(A, /obj)) //let's actually be super sure this is an object + var/obj/O = A + input = input("What angle would you like to rotate \the [O] to? (-[max_tilt_shift_allowed] to +[max_tilt_shift_allowed]) \nCurrent rotation: [O.is_tilted]", "Rotation of: [src]") as null|num + if(input >= -max_tilt_shift_allowed && input <= max_tilt_shift_allowed) + playsound(O.loc, playsound_audio, playsound_volume, TRUE) + if(do_after(src, do_after_delay, target = O)) + visible_message(span_notice("[src] rotates [O] [input] degrees.")) + O.transform = O.transform.Turn(-O.is_tilted) + O.transform = O.transform.Turn(input) + O.is_tilted = input + else if(input < -max_tilt_shift_allowed || input > max_tilt_shift_allowed) + to_chat(src, span_danger("Selected value is out of allowed bounds!")) + return + + if(3) //Edit Layer + input = input("Choose if you'd like to change layer value or reset:", "Layer of: [src]") as null|anything in list("Change Layer", "Reset to initial") + + if(input == "Change Layer") + input = input("Insert new layer offset (-[max_layer_shift_allowed] to +[max_layer_shift_allowed]) \nCurrent layer: [A.layer]", "[input]:") as null|num + if(input && (input >= -max_layer_shift_allowed && input <= max_layer_shift_allowed)) + playsound(A.loc, playsound_audio, playsound_volume, TRUE) + if(do_after(src, do_after_delay, target = A)) + visible_message(span_notice("[src] shifts \the [A] to the perfect spot!")) + A.layer = initial(A.layer) + A.layer += input + else if(input < -max_layer_shift_allowed || input > max_layer_shift_allowed) + to_chat(src, span_danger("Selected value is out of allowed bounds!")) + return + return + + else if(input == "Reset to initial") + playsound(A.loc, playsound_audio, playsound_volume, TRUE) + if(do_after(src, do_after_delay, target = A)) + visible_message(span_notice("[src] pushes \the [A] to its original layer!")) + A.layer = initial(A.layer) + return + diff --git a/fortune13.dme b/fortune13.dme index aad521cfba0..1a6cd62185f 100644 --- a/fortune13.dme +++ b/fortune13.dme @@ -1037,6 +1037,7 @@ #include "code\game\objects\items.dm" #include "code\game\objects\obj_defense.dm" #include "code\game\objects\objs.dm" +#include "code\game\objects\objs_set_vars_verbs.dm" #include "code\game\objects\structures.dm" #include "code\game\objects\effects\alien_acid.dm" #include "code\game\objects\effects\anomalies.dm"