Corby |
Hey, hopefully this will be the last question I ask in awhile... My character will leave her belongings behind for a short time and wander to other rooms. How can I remember what specific items my chracters owned before I give them back, in case different items were picked up or different items used? Kinda confusing... |
AGI1122 |
Set aside some flags to use to determine if they have the item or not. Then just put an if around each set/unset command like this: if (has(iA)) { Then just get rid of the users inventory. Then to get it back just do this: if (isset(f45)) { The more inventory objects you have the more flags it will require. |
Corby | Hmmm, would this work with variables? I'm pretty low on flags. |
Kon-Tiki |
It depends. If there're objects you can't drop or get without other objects, then you can use vars. If you have lots of vars that aren't used, you can use them too, but doing this won't work:
You'll have to use a different var for each object/group of objects, since the above is clearly one big bug. -Kon-Tiki- |
sonneveld |
The alternative is to set them to another "room". Each item can be set to exist in a particular room or in your inventory (room 255). Obviously you're not going to have 0-254 rooms filled up so pick a number like 254 and set all your inventory items to 254. Problem is that eval commands has() and obj.in.room() don't read in variables, so it makes it harder to loop. - Nick |
sonneveld |
okay, try this code. in defines.txt you NEED to set the number of objects in the #define num_invobjects, or it won't go through all the objects in the loop. Just need the variable move_to to some temporary room you wish to move all your inventory items in. I set it as a variable in case you want to have multiple spare rooms, like a cupboard, under your bed or the boot/trunk of your car. Wrap up each loop in it's own if(){} statement or it'll move your inventory and then back again each time! :) I hope this helps. Reply if it doesn't make much sense. - Nick
|
jelleghys | Use G |
Joel |
short answer, although it would mean more code than Nick's version: look for the put() command look for the has() command look for the obj.in.room() command if your character will be dropping their inventory items in a particular room, you can use put() to put the inventory items in the room (after you test if the character has the item by using has()). Then when your character comes back to the room later, you can test obj.in.room() to find out if the object is in the room (which it will only be if your character had the item in the first place). Nick's method would mean less code and it automatically works for all inventory objects that the character has, so I personally would recommend using that, but I'm just throwing out the simplest to understand (not the optimal) way of doing it. |
Corby | wow, lots of ways... i'll give them a shot and let you know. Thanks alot :) |