container stuff
lyteside
23 Apr 2007, 16:36i want to create a script that works much like a "for each object in <place>" script, only for the container thing... but i can't figure out how to refer to it...
when an object is in a container, it is still in the same room according to quest, but a "for each object in <room>" will not refer to those objects... so how do i test for them?
when an object is in a container, it is still in the same room according to quest, but a "for each object in <room>" will not refer to those objects... so how do i test for them?
Elexxorine
24 Apr 2007, 08:23You could make a room with the name of the object and place whatever you want 'inside' it there. Then have a command for 'take #@thing# from #@object#' to look inside the 'object' room for the 'thing' (and if the object is where you are). Slayer did somethnig similar in his game 'The Shadow Project' for looting people. I can make up some codes for you later if you wish... Hope this helps.
paul_one
24 Apr 2007, 10:45I wish the list property actually returned a list of objects instead of specifying a string or action or whatever.
I'm not in the right mind for creating a demo right now, but I was certain that I was getting the exact reverse - seeing objects even if they were in a container.
I'd say use this option:
putting an object inside another object (obj1 inside obj2) means you add the first's name to a property in the second object (#obj2:contains# = obj1) and so you can list them out easily if the object is a container.
I'm not in the right mind for creating a demo right now, but I was certain that I was getting the exact reverse - seeing objects even if they were in a container.
I'd say use this option:
putting an object inside another object (obj1 inside obj2) means you add the first's name to a property in the second object (#obj2:contains# = obj1) and so you can list them out easily if the object is a container.
lyteside
24 Apr 2007, 15:24grrrr... yeah, this is what i was afraid of. i too wish the list command gave returned the list rather than output the hardcoded stuff, cause it makes things difficult. perhaps there is still a way to do it, though, and i'm just missing something?
elexxorine, how does the take objects from another room idea work while using the @, when the @ looks for objects in your current room? i tried something like this, but to no avail. will you help me? any code you come up with would so help with this.
that is true initially, but i figured out some round about ways to blow that all up. the only problem now is that i want to make it so you can put things in the container, but you yourself can also get into the container, which becomes a separate room... i want the objects to move to that room when you get in it so you can see them where you are. I already finished the code for when you get out of the room... it does a "for each object in room" thingie and does a "add <object; object thingie>" for them. that part works fine. the reverse seems impossible.
elexxorine, how does the take objects from another room idea work while using the @, when the @ looks for objects in your current room? i tried something like this, but to no avail. will you help me? any code you come up with would so help with this.
Tr0n wrote:
I'm not in the right mind for creating a demo right now, but I was certain that I was getting the exact reverse - seeing objects even if they were in a container.
that is true initially, but i figured out some round about ways to blow that all up. the only problem now is that i want to make it so you can put things in the container, but you yourself can also get into the container, which becomes a separate room... i want the objects to move to that room when you get in it so you can see them where you are. I already finished the code for when you get out of the room... it does a "for each object in room" thingie and does a "add <object; object thingie>" for them. that part works fine. the reverse seems impossible.
Elexxorine
25 Apr 2007, 08:06'@' doesn't look at objects in the room, it's a shortening of the function '$getobjectname(#thing#)$'. I'll throw some code together for you:
I haven't tested these codes, as I just typed them up now and I'm at school (no quest... grr). Hope this helps now...
command <loot #@person> {
if here <#person#> and property <#person#; person; lootable> then {
flag off <stolen>
for each object in <#person#.room> {
if property <#quest.thing#; takable> then move <#quest.thing#; inventory>
}
}
}
Also for containers:command <take #@object# from #@container#> {
if here <#container#> and property <#container#; container> then {
for each object in <#container#.room>
if property <#quest.thing#; takable> then move <#quest.thing#; inventory>
}
}
}
Now for putting some stuff into it:command <put #@object# in #@container#> {
if here <#container#> and property <#container#; container> and got <#object#> then {
move <#object#; #container#.room>
}
}
You prolly want to open the compound 'if's out so you have have neat little else msg's incase you can't do it.I haven't tested these codes, as I just typed them up now and I'm at school (no quest... grr). Hope this helps now...
paul_one
25 Apr 2007, 15:36There's an in-built container action called "add" which should make this easier.. Means for ANY command which would put an object into an object, then that script would be called.command <put #@object# in #@container#> {
- Unless I mis-read something.
I didn't know containers had rooms? .. or are you taking this from an example of having containers as rooms?for each object in <#container#.room>
Couldn't you simplify that down to just one if:
"if ( #object:parent# = #container# ) then {
Also, why not just use the built in container object commands, if you want specific containers to behave differently (ie, normal containers like bags and pockets - and then a SPECIFIC container like a tardis shoebox) ?
Elexxorine
27 Apr 2007, 09:00Because that's what Lyteside originally asked for...
lyteside
27 Apr 2007, 15:40i finally figured out what works best for me. when i move to the object room, i move the container object to the room and make it invisible. Then i can still see the things inside of it. when i leave the room, then anything picked up but dropped again gets added back into the container, and the container moves back to the original room and unhides.
it's a little mickey mouse, but took the least amount of code, which is a plus for me right now until i can find the appropriate way to do it.
it's a little mickey mouse, but took the least amount of code, which is a plus for me right now until i can find the appropriate way to do it.
Elexxorine
27 Apr 2007, 16:00Glad you found a way to do it that you like...