ID:144509
 
Code:
mob/Host/verb/Set_Up_Variables()
set category = "Host Commands"
switch(alert("What do what want to do?","Set Up Variables","Add Variables","Remove Variables","Edit Variables"))
if("Add Variables")
var/varname = input("What will the variable be named?") as null|text
if(varname && varname != "")
var/default = input("What is the default value?")
for(var/obj/playervar/O in world)
O.variables[varname] = default
varslist[varname] = default
if("Remove Variables")
var/removethis = input("Remove which variable?") in varslist
var/ohnoes = alert("Delete [removethis]?","Remove Variables","No","Yes")
if(ohnoes == "Yes")
for(var/obj/playervar/O in world)
O.variables -= removethis
varslist -= removethis
if("Edit Variables")
var/editthis = input("Edit which variable?") in varslist
switch(alert("Edit [editthis]? It will mass-edit the default value of [editthis] AND all players' [editthis]!",,"Yes","No"))
if("Yes")
var/newvalue = input("What will the new default value be?")
for(var/obj/playervar/T in world)
T.variables[editthis] = newvalue
varslist[editthis] = newvalue

obj/playervar
var
list/variables = list()
New()
..()
variables = varslist

var/list/varslist = list()

mob/verb/Edit_Variable()
if(!players.Find(src.key))
alert("You can't use this verb unless the host allows you to play.")
return
for(var/obj/playervar/T in world) if(T.name == src.key)
if(T.variables.len >= 1)
var/editme = input("Which variable are you editing?","Edit Variable") in T.variables
var/editto = input("What is the new value?",editme,T.variables[editme])
T.variables[editme] = editto
world << "[src] edits their <B>[editme]</b> to <B>[editto]</B>"
else
alert("You have no variables to edit.")


Problem description:

When you use this, there will be one /obj/playervar on the map named after your key. However, I think that the line:
T.variables[editme] = editto
is screwing it up and making it edit every /obj/playervar's variables[editme] value.

I was trying to create a way so that the host of the game could make as many custom variables as they want and the players can edit them. Is that not the way I do that, or is there no good way to do what I want done? :(

EDIT: added more stuff up there

I'm beginning to believe I don't know as much about what I was doing as I thought I did :(

EDIT PART TWO: I think I figured out what it's doing (but not how to fix it :( )
When someone uses Edit Variables it edits the variable "varslist" for some reason, as if "T.variables" is just a reference to "varslist". Why is it doing this to poor Cow? :(