How to pass a parameter to a ControlScript?

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
User avatar
timginter
Neophyte Poster
Posts: 37
Joined: Tue Apr 22, 2008 6:25 am

How to pass a parameter to a ControlScript?

Post 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?
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Post 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
...
User avatar
timginter
Neophyte Poster
Posts: 37
Joined: Tue Apr 22, 2008 6:25 am

Post by timginter »

Thanks a lot, works fine now :)
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

Yes never set an object reference to a prop. Always set its serial and do SystemFindObjectBySerial.
Post Reply