Is it possible to use the for loop to loop through the vars a mob has. Here is what I made but it dosn't work.
Lookatvars(mob/M in world)
for(var/mob/var/V in M)
for(V!=null||0)
Then how would I give the option to select a var that is more then 0 and alter its value.
Thank you for your time.
ID:175128
![]() Jun 8 2003, 7:57 am
|
|
Lummox JR wrote:
for(V!=null||0) I wanted to loop through all the vars that had a value of somesort. What would be a good way to do that? |
Ok, I combined what you guys told me to do. It didnt work =(. So I wrote usr<<"1" "2" ect to see where it's not working. Here is the code
Lookatvars(mob/M in world) usr<<"1" for(var/V in M.vars) usr<<"2" if(isnum(V)) usr<<"3" var/A=input("What do you wish to set [V] to?","[V]",0) as num|null V=A I get 1 "1" and about 34 "2" (There are 34 vars). I don't get any "3" So what would be the problem. Also, Instead of giving each V a different value, I would like to choose which var I wanne change, then change it. |
Well, if you're looking for Administrator verbs...such as "Edit" there's great libraries and demos already out there ready to just be plugged in ^_^
|
SSChicken wrote:
I wanted to loop through all the vars that had a value of somesort. What would be a good way to do that? This way: for(var/V in M.vars) for(var/V in M.vars) Lummox JR |
While we're on the topic, does anyone know how to access a list of vars like that for world vars, or vars that aren't declared under an object?
<code>world status</code> and <code>var/game_speed</code> For example? |
Foomer wrote:
While we're on the topic, does anyone know how to access a list of vars like that for world vars, or vars that aren't declared under an object? To my knowledge, these variables aren't stored in any pre-defined list. You'd have to make your own procedure to save them to a list, and then read them from there. var/list/WorldVars = list() Something like that, I'd guess. ~>Volte |
Foomer wrote:
While we're on the topic, does anyone know how to access a list of vars like that for world vars, or vars that aren't declared under an object? Nope. Some time back Deadron developed a very small debugging tool that had access to any datum's vars, but it wasn't able to handle world or global vars because of this one shortcoming in BYOND. Ideally I'd like to see a global vars list and a world.vars list to complement datums. Lummox JR |
"in M" is interpreted as "in M.contents", which is wrong. You just need to loop through var/V in M.vars.
What exactly were you hoping to accomplish with this line? The condition makes no sense, and putting it in a for statement makes even less.
Lummox JR