At one point in my game I want to have it so all your inventory is taken (temporairly) for a section and you get it from a container later. What I can do to make every item currently in your invetory move to the container?
XanMag
06 Dec 2015 23:32
Compliments of The Pixie.
foreach(obj, ScopeInventory()) { if (not obj = firstobjecttokeep and not obj = secondobjecttokeep) { obj.parent = somewhereelse } }
And you should replace 'somewhereelse' with a room that you want to move them too. Someone correct me if that is wrong please.
HegemonKhan
07 Dec 2015 00:05
also, note the difference from the game objects actual "physical" location~containment vs the Object's names stored in an Object List (such as the 'ScopeInventory' Objectlist).
the game objects initial location is the 'player' Player Object, but to manipulate them (such as moving them), you're using the 'ScopeInventory' Objectlist + 'foreach' Function (to iterate through all of them) to move them to another location, for example: 'data_storage_room' Room Object
so, now that you got your game objects "physically" located~contained (in~inside) the 'data_storage_room' Room Object, how would you then say move them back to the 'player' Player Object as their actual "physical" location?
answer: you can't (well unless you do them script individually via: objectX.parent = player), UNLESS you add those game objects' names to an Objectlist Attribute first and then use a 'foreach' Function on it!
aka: you can't iterate (cycle through) an Object Element, but you can iterate through an Objectlist (and the other List type, Stringlist, too, of course)
metalmario991
07 Dec 2015 00:45
Okay, so since I am not that sauvy with how Quest works, I might need more of an explanation but anyway,
I entered this and got this error: Error running script: Error compiling expression 'obj': Unknown object or variable 'obj'
So what am I doing wrong?
Also what, is the loop variable suppose to be?
(Also attaching a picture of what I have)
HegemonKhan
07 Dec 2015 01:01
for this:
For each loop variable _______________ in source [the inventory]
type in this:
obj
so, it should look like this:
For each loop variable obj in source [the inventory]
(my underlining is just to represent the empty text box that you need to type 'obj' into)
-----------------
explanation of the 'foreach' loop:
let's say we've got an Objectlist (named: myobjectlist), with the items (as Objects' names): ball, toy, hat
foreach (x, myobjectlist)
(hidden from you, the foreach sets each of the items in the list to the 'x' :
x = ball x = toy x = hat
then you got a (move~parent) Script (using your example):
x.parent = LaundryHamper
so, what happens is the script acts upon each item (through the 'x' temporary-placeholder variable):