ID:175099
Jun 12 2003, 8:55 am
|
|
Is it possible to add an obj to a list. Then useing a for loop? pick one and change its vars. I didn't see anything about it in the demos, nor never heard of it, that's why I'm posting. All help is appreaciated.
|
Jun 12 2003, 11:44 am
|
|
I don't follow.
|
In response to Foomer
|
|
A list can contain variables. I want to know if a list can contain obj's. Then somewhere else in the code I want to loop through the list and check the obj's it contains.
If that's all possible I'd like to know how I would do it. [Edit]Or assign a variable the obj (Possible?) then add the varibale to the list..and so on. It's just an idea..[Edit] |
In response to SSChicken
|
|
SSChicken wrote:
A list can contain variables. I want to know if a list can contain obj's. Then somewhere else in the code I want to loop through the list and check the obj's it contains. Of course. var/list/ObjList = list(new /obj/MyObj, new /obj/YourObj) ~>Volte |
In response to Volte
|
|
Thank you ^_^ that's what I needed for the list. Now I'm trying something different. I'm trying to use a switch(input( thing. Here it is:
var/list/Foods= list (new /obj/apples) It dosn't give me any compile errors but nothing happens when I click on the verb during the game. P.S. I don't actually need to eat apples. This is just a subsititue to my real code. |
In response to SSChicken
|
|
is hunger defined? also, it should be src.hunger, usr is evil, you know! also, this may not be the problem, but you have no space between )in list. it should be ) in list(Foods)
I could be wrong about this, but I think it's right... |
In response to Dragon of Ice
|
|
Hunger is defined. I changed usr to src (It wouldn't make much of a difference since its a verb) and the in dosn't matter because it's blue either way (But I checked anyways, and it didn't make a difference).
|
In response to SSChicken
|
|
Does it show the stat hunger in a panel, otherwise this is all behind the scenes stuff....
|
In response to Dragon of Ice
|
|
Yes it is all behind the scenes. I don't have much of a map or anything. I'm trying to finish the base of my game first, then add the preety stuff.
|
In response to SSChicken
|
|
The reason this doesn't do anything is because it's all behind the scenes stuff. It should do exactly what it says, but you don't see any results. Try this for a hunger proc.
proc I'm not sure if this will work, but most of it should with a little tweaking! |
In response to Dragon of Ice
|
|
But that's not what I'm trying to acomplish, like I noted in one of my earlier posts. I'm useing apples as a substitue to make it simpler. Here is what I'm trying to make:
I will have a lot of obj's and they will all have different vars. I want every player in the game to be able to take them and alter their vars. If there is a better way of doing it them I'm trying to right now the please tell me. |
In response to SSChicken
|
|
Well, then why not make the vars global, and either have verbs or procs called to change them?
|
In response to SSChicken
|
|
SSChicken wrote:
> var/list/Foods= list (new /obj/apples) There are a few things I can say about this.. 1. You don't really need the 'list' part. You can just do 'in Foods'. 2. When using the switch, you're acting as if it's a string. It's an obj, so it won't do you any good to use a string. Try if(/obj/apples). 3. Since 'apples' is the only thing in the list, it won't bring up the list box. You need to add something else, or do: switch(input("Which object?") in Foods+"Cancel") ~>Volte |
In response to Volte
|
|
Volte wrote:
2. When using the switch, you're acting as if it's a string. It's an obj, so it won't do you any good to use a string. Try if(/obj/apples). Actually, that won't work - an object does not equal its type string. You'd have to do something like this: <code>var/atom/A=input("Which object?") in Foods switch(A.type) if(/obj/apples) if(/obj/banana) if(/obj/and_so_on)</code> |
In response to Crispy
|
|
Actually what he gave me worked ^_^. I only tried it with one item so far, and didn't really experiment much but it works to some extent. I'll be trying out both ways.
|
In response to SSChicken
|
|
Well, if it works, great. I wouldn't have expected it to, but hey. =)
|