PDA

View Full Version : Item pickup Scripts?



beefster09
11-18-2006, 08:22 PM
How do you access them? Are they implemented in b14?

I'm asking this because I saw this in the documentation.

beefster09
12-01-2006, 06:33 PM
How do you use/make them in b15, now that it's out?

C-Dawg
12-05-2006, 01:20 PM
The code to give Link an item is just:

Link->Item[#];

The # is going to be a number that matches the item you want to give Link. Open the std_lib.z file that comes with b15, you'll find a list of item numbers there. Don't use itemclass - use item numbers (further down).

Picking apart that command for you:
Link = This is the "Link" object. He carries around a whole bunch of information regarding his inventory and health.
-> = This is a pointer command. It tells the engine to look at the Link object, and then specifically look at a particular piece of information he's carrying around.
Item[#] = This is a piece of information Link is carrying around. It's true if Link has the item numbered #, and false if he does not. So set it to true to give him an item, set it to false to take it away. Or you can check if he has an item or not: if(Link->Item[#])

I think it works a little differently for items like small hearts and bombs, that have counters, however.

beefster09
12-05-2006, 06:28 PM
No, I think it means a script that runs when you pick up an item. That's what I want to know.

C-Dawg
12-06-2006, 12:19 AM
Same answer.
1. Set a variable to zero.
2. Check Link->Item[#] to see if Link has that item.
3. When Link has the item and the variable is zero, run the script you want to activate on pickup.
4. Then, set the variable to a nonzero value to prevent it from happening again.