Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Trouble with Item Scripting

8 years ago

So, I'm trying to do a thing where, when a player clicks a specific link, they automatically obtain an item. I tried going into the link script page and inputting $ITEMSTATE01 := 1, but when I went to playtest all I got was a long error message. I tried using a = instead of a := too, but it wouldn't let me put that in. Am I doing something wrong? Thank you.

Trouble with Item Scripting

8 years ago

Unfortunately, there has been an off and on error with $ITEMSTATE. There is a workaround however somewhere in the advenced editor forum... I'll see if I can find it later today (if no one else does first).

Trouble with Item Scripting

8 years ago
The workaround is to give the items on the page script instead.

Just put the code on whatever page the link leads to.

Trouble with Item Scripting

8 years ago

Thank you!

Trouble with Item Scripting

8 years ago

Killa is correct. I wish it worked for links, though.

Trouble with Item Scripting

8 years ago
That'd be pretty nice, but at least we got a workaround that usually is just as good as giving the items in the links.

Trouble with Item Scripting

8 years ago

Here it is from 3 Years ago...

---

Here’s My Workaround for Script Dropping Items

If you want an Item that can be Dropped by Script:

1: Create the Item (say a Spoon, hereafter ITEM #1) and Set the Number of Uses to 2 Times

2: In the Global Page Script, add: IF $ITEMUSED1 = 1 THEN $ITEMUSED1 := 0 (this allows the Spoon to be used any number of times)

3: In Any Link (or Page) Script where you want to Script Drop the Spoon from the Inventory, add: $ITEMUSED1 := 2 (this will cause the Spoon to drop out of the Inventory when the Link (or Page) is selected)

Hope this helps until a proper code fix can be implemented  =)

Trouble with Item Scripting

8 years ago

So, the above shows how to drop items, but it works in reverse for picking them up too.

At the start of the game, you set all $ITEMSTATE(s) := 1 then immediately set all $ITEMUSED(s) := 2

^This will put all game items in the Inventory (in the order you want them to appear) then make them all invisible. To have someone 'pick up' and Item, all you have to do is put in the Link: $ITEMUSED(s) := 0 (and it pops back into the Inventory.

Trouble with Item Scripting

8 years ago

For Items you want to actually have limited uses for, you can either tweak their number of uses so they start above 2 when picked up - or track the number of uses with a separate Variable.