mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-21 15:51:31 +00:00
/tg/ varedit improvements
- Ports tgstation/-tg-station#9630 -- Makes it possible to varedit associative lists (armor values on clothing, for example). - Adds step_x and step_y to the list of vars locked from being varedited. - An admin trying to varedit a very large list will be warned before the list is opened that it may crash the server and prompted to abort. - Changed a BYOND text macro to a span class.
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
for(var/p in forbidden_varedit_object_types)
|
for(var/p in forbidden_varedit_object_types)
|
||||||
if( istype(O,p) )
|
if( istype(O,p) )
|
||||||
usr << "\red It is forbidden to edit this object's variables."
|
usr << "<span class='danger'>It is forbidden to edit this object's variables.</span>"
|
||||||
return
|
return
|
||||||
|
|
||||||
var/list/names = list()
|
var/list/names = list()
|
||||||
|
|||||||
@@ -130,16 +130,40 @@ var/list/forbidden_varedit_object_types = list(
|
|||||||
|
|
||||||
if(!istype(L,/list)) src << "Not a List."
|
if(!istype(L,/list)) src << "Not a List."
|
||||||
|
|
||||||
var/list/locked = list("vars", "key", "ckey", "client", "firemut", "ishulk", "telekinesis", "xray", "virus", "viruses", "cuffed", "ka", "last_eaten", "urine", "poo", "icon", "icon_state")
|
if(L.len > 1000)
|
||||||
var/list/names = sortList(L)
|
var/confirm = alert(src, "The list you're trying to edit is very long, continuing may crash the server.", "Warning", "Continue", "Abort")
|
||||||
|
if(confirm != "Continue")
|
||||||
|
return
|
||||||
|
|
||||||
var/variable = input("Which var?","Var") as null|anything in names + "(ADD VAR)"
|
var/list/locked = list("vars", "key", "ckey", "client", "firemut", "ishulk", "telekinesis", "xray", "virus", "viruses", "cuffed", "ka", "last_eaten", "urine", "poo", "icon", "icon_state", "step_x", "step_y")
|
||||||
|
|
||||||
|
var/assoc = 0
|
||||||
|
if(L.len > 0)
|
||||||
|
var/a = L[1]
|
||||||
|
if(istext(a) && L[a] != null)
|
||||||
|
assoc = 1 //This is pretty weak test but i can't think of anything else
|
||||||
|
usr << "List appears to be associative."
|
||||||
|
|
||||||
|
var/list/names = null
|
||||||
|
if(!assoc)
|
||||||
|
names = sortList(L)
|
||||||
|
|
||||||
|
var/variable
|
||||||
|
var/assoc_key
|
||||||
|
if(assoc)
|
||||||
|
variable = input("Which var?","Var") as null|anything in L + "(ADD VAR)"
|
||||||
|
else
|
||||||
|
variable = input("Which var?","Var") as null|anything in names + "(ADD VAR)"
|
||||||
|
|
||||||
if(variable == "(ADD VAR)")
|
if(variable == "(ADD VAR)")
|
||||||
mod_list_add(L)
|
mod_list_add(L)
|
||||||
return
|
return
|
||||||
|
|
||||||
if(!variable)
|
if(assoc)
|
||||||
|
assoc_key = variable
|
||||||
|
variable = L[assoc_key]
|
||||||
|
|
||||||
|
if(!assoc && !variable || assoc && !assoc_key)
|
||||||
return
|
return
|
||||||
|
|
||||||
var/default
|
var/default
|
||||||
@@ -231,6 +255,9 @@ var/list/forbidden_varedit_object_types = list(
|
|||||||
mod_list(variable)
|
mod_list(variable)
|
||||||
|
|
||||||
if("restore to default")
|
if("restore to default")
|
||||||
|
if(assoc)
|
||||||
|
L[assoc_key] = initial(variable)
|
||||||
|
else
|
||||||
L[L.Find(variable)]=initial(variable)
|
L[L.Find(variable)]=initial(variable)
|
||||||
|
|
||||||
if("edit referenced object")
|
if("edit referenced object")
|
||||||
@@ -241,27 +268,51 @@ var/list/forbidden_varedit_object_types = list(
|
|||||||
return
|
return
|
||||||
|
|
||||||
if("text")
|
if("text")
|
||||||
|
if(assoc)
|
||||||
|
L[assoc_key] = input("Enter new text:","Text") as text
|
||||||
|
else
|
||||||
L[L.Find(variable)] = input("Enter new text:","Text") as text
|
L[L.Find(variable)] = input("Enter new text:","Text") as text
|
||||||
|
|
||||||
if("num")
|
if("num")
|
||||||
|
if(assoc)
|
||||||
|
L[assoc_key] = input("Enter new number:","Num") as num
|
||||||
|
else
|
||||||
L[L.Find(variable)] = input("Enter new number:","Num") as num
|
L[L.Find(variable)] = input("Enter new number:","Num") as num
|
||||||
|
|
||||||
if("type")
|
if("type")
|
||||||
|
if(assoc)
|
||||||
|
L[assoc_key] = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
|
||||||
|
else
|
||||||
L[L.Find(variable)] = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
|
L[L.Find(variable)] = input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf)
|
||||||
|
|
||||||
if("reference")
|
if("reference")
|
||||||
|
if(assoc)
|
||||||
|
L[assoc_key] = input("Select reference:","Reference") as mob|obj|turf|area in world
|
||||||
|
else
|
||||||
L[L.Find(variable)] = input("Select reference:","Reference") as mob|obj|turf|area in world
|
L[L.Find(variable)] = input("Select reference:","Reference") as mob|obj|turf|area in world
|
||||||
|
|
||||||
if("mob reference")
|
if("mob reference")
|
||||||
|
if(assoc)
|
||||||
|
L[assoc_key] = input("Select reference:","Reference") as mob in world
|
||||||
|
else
|
||||||
L[L.Find(variable)] = input("Select reference:","Reference") as mob in world
|
L[L.Find(variable)] = input("Select reference:","Reference") as mob in world
|
||||||
|
|
||||||
if("file")
|
if("file")
|
||||||
|
if(assoc)
|
||||||
|
L[assoc_key] = input("Pick file:","File") as file
|
||||||
|
else
|
||||||
L[L.Find(variable)] = input("Pick file:","File") as file
|
L[L.Find(variable)] = input("Pick file:","File") as file
|
||||||
|
|
||||||
if("icon")
|
if("icon")
|
||||||
|
if(assoc)
|
||||||
|
L[assoc_key] = input("Pick icon:","Icon") as icon
|
||||||
|
else
|
||||||
L[L.Find(variable)] = input("Pick icon:","Icon") as icon
|
L[L.Find(variable)] = input("Pick icon:","Icon") as icon
|
||||||
|
|
||||||
if("marked datum")
|
if("marked datum")
|
||||||
|
if(assoc)
|
||||||
|
L[assoc_key] = holder.marked_datum
|
||||||
|
else
|
||||||
L[L.Find(variable)] = holder.marked_datum
|
L[L.Find(variable)] = holder.marked_datum
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user