Page 1 of 1

How to pass a parameter to a ControlScript?

Posted: Sat May 03, 2008 8:47 am
by timginter
Hi.
I wrote a script for an item which, when used by a character, creates another item. This created item has a ControlScript and I need to pass the character who used the previous script to that ControlScript. I've tried SetObjProperty(item, "Creator", who); in the first script, and creator := GetObjProperty(item, "Creator"); in the ControlScript, but, when I want to create another item (through the ControlScript) using CreateItemInContainer(creator.backpack, [hex-type], [amount]); it doesn't seem to work :/ I think the method in itself is OK and who isn't correct. I've tried who.serial, but it doesn't seem to work either :/
Any suggestions?

Posted: Sat May 03, 2008 9:01 am
by Pierce
I would suggest this way.

First script (item creation):

Code: Select all

...
SetObjProperty(item, "Creator", who.serial); 
...
Second script (control script):

Code: Select all

...
var createdbyserial := GetObjProperty(item, "Creator");
var creator := SystemFindObjectBySerial(createdbyserial,SYSFIND_SEARCH_OFFLINE_MOBILES);
if(creator)
 ...
endif
...

Posted: Sat May 03, 2008 11:10 am
by timginter
Thanks a lot, works fine now :)

Posted: Sat May 03, 2008 9:17 pm
by CWO
Yes never set an object reference to a prop. Always set its serial and do SystemFindObjectBySerial.