removing entire inventory without 'missing parameter' errors
leftycool
24 Nov 2012, 03:42Hi, im looking for a script which will blanket-remove the players inventory. I have a script to remove them individually, but if the player doesnt have them it generates an 'unexpected missing parameter ' error. I think its a pretty simple thing to do but I cant see how to begin. thanks in advance.

jaynabonne
24 Nov 2012, 05:03Here is the basic pattern. Inventory objects are just children of the player. I'm not really sure what "remove an object" means to you, so I just wrote this to move the object to a room called "Limbo". But you should be able to adapt this for whatever you want.
foreach (child, GetDirectChildren(player)) {
MoveObject(child, Limbo)
}
leftycool
24 Nov 2012, 05:58Thanks, sorry to be a bother, but how would I implement this?
Is there an option in run script somewhere to run raw code?
Is there an option in run script somewhere to run raw code?
sgreig
24 Nov 2012, 08:16There's a button at the top of the Quest window near the right hand side that switches to the Quest code editor.
leftycool
24 Nov 2012, 12:54jaynabonne wrote:foreach (child, GetDirectChildren(player)) {
MoveObject(child, Limbo)
}
I added this in, but now when I try to load my game for editing, I get an error saying:
Failed to load game due to the following errors.
*error adding script. 'foreach ((child, GetDirectChildren(player), ScopeInventory())
{
}': Missing ")'

Pertex
24 Nov 2012, 14:01Careful, you have typed two brackets after foreach. change
to
foreach ((child,...
to
'foreach (child,...

jaynabonne
24 Nov 2012, 14:40You also have ScopeInventory in there, which wasn't part of it. If this helps:


leftycool
25 Nov 2012, 02:38My problem now is the program wont let me open my saved project for editing. how do I open it? Is there another way?

jaynabonne
25 Nov 2012, 04:52You can open it with any text editing program (e.g. notepad) to fix the typo. If you can't get it to work, post it here, and we can fix it.
leftycool
25 Nov 2012, 06:06Thanks for the help. I opened it in notepad, found the offending code and removed it, now it boots up fine. If you're curious, I'm aiming to release my game on the 24th dec, granted I have the music and art done by then 


jaynabonne
25 Nov 2012, 15:04Nice! Good luck. 
