move object using expression
ender
05 Aug 2011, 00:50I've got a string called 'tempstring' that holds the name of an object I want to give to the player ... so I'm trying to use the 'move object to' function to move it to the player ...
my code looks like:
MoveObject (tempstring, player)
but when I run it, I get :
Error running script: Error compiling expression 'object': RootExpressionElement: Cannot convert type 'String' to expression result of 'Element'
since 'expression' is one of the options for the move object command I assume the problem is with my expression ... so what am I doing wrong with my expression?
Since this is just a "what can I do and how do I do it" test, tempstring only refers to one object ... 'sword' ... but eventually, I want to use a dictionary to assign a value to the tempstring ... for things like giving the player random objects or selecting and giving the player an object using a showmenu command ...
my code looks like:
MoveObject (tempstring, player)
but when I run it, I get :
Error running script: Error compiling expression 'object': RootExpressionElement: Cannot convert type 'String' to expression result of 'Element'
since 'expression' is one of the options for the move object command I assume the problem is with my expression ... so what am I doing wrong with my expression?
Since this is just a "what can I do and how do I do it" test, tempstring only refers to one object ... 'sword' ... but eventually, I want to use a dictionary to assign a value to the tempstring ... for things like giving the player random objects or selecting and giving the player an object using a showmenu command ...
ender
05 Aug 2011, 02:31Never mind. I figured this out ... but in case anyone wants to know ...
I solved this by creating an object attribute on the game object named tempobj ... then, in my script ... I set the value of game.tempobj to 'sword' ... and then I was able to use game.tempobj in the moveObject command ...
So my code is ...
game.tempobj = Sword
MoveObject (game.tempobj, player)
Which works brilliantly.
My next step is to use this and a dictionary to create a shop ... I'll probably switch to the 'CloneObjectAndMove' function for that though.
I solved this by creating an object attribute on the game object named tempobj ... then, in my script ... I set the value of game.tempobj to 'sword' ... and then I was able to use game.tempobj in the moveObject command ...
So my code is ...
game.tempobj = Sword
MoveObject (game.tempobj, player)
Which works brilliantly.
My next step is to use this and a dictionary to create a shop ... I'll probably switch to the 'CloneObjectAndMove' function for that though.
ender
05 Aug 2011, 03:14unfortunately, it doesn't seem to work with what is returned from a ShowMenu function ... so back to square one on that.

Pertex
05 Aug 2011, 06:37ender wrote:
my code looks like:
MoveObject (tempstring, player)
The first parameter of MoveObject must be an object not a string. with the function GetObject you get the right object:
MoveObject ( GetObject(tempstring), player)
ender
05 Aug 2011, 16:57I knew there had to be something like that... excellent. Thank you.