inventory items
So I'm having trouble figuring out how to go about doing this. Basically I have dink pick up a scroll and I'm wondering how to make the item do something when it's used. I want it to open up a sprite I made. So to put it simply, how do you go about scripting inventory items? I'm constantly confused when scripting so if it's something simple, don't laugh at me.
Well, to add the item to his inventory, you use:
For example, if you wanted to give Dink a sword, you would use:
All that does is add the item. To make the item do things, you would need to edit its script. Say the item script for your scroll is called "item-scroll.c", this is what it could look like.
Those are the main functions. The rest are:
pickup - When the item is added to Dink's inventory
drop - When the item is removed from Dink's inventory.
holdingdrop - When the item is removed from the player's inventory while it is armed.
So yeah, that's pretty much it. The graphic slots for the default magic and weapons are 437 and 438, respectively. Scroll graphics can be found in sequence 438, frames 14, 15, 16, and 17. Once again, if you named your scroll's script "item-scroll", the line to add it would look like:
Hope that helps!
add_item("scriptname",sequence, frame);
For example, if you wanted to give Dink a sword, you would use:
add_item("item-sw1", 438, 7);
All that does is add the item. To make the item do things, you would need to edit its script. Say the item script for your scroll is called "item-scroll.c", this is what it could look like.
void use(void) { //This is what happens when you press 'Ctrl' when the item is equipped. If you used it, Dink would say "I'm using a scroll!" say("I'm using a scroll!",1); } void arm(void) { //This is what happens when you select the item in your inventory. If you equipped it, Dink would say "I'm now equipping the scroll!" say("I'm now equipping the scroll!",1); } void disarm(void) { //Same as arm(), but it's when the item is unequipped. Dink would say "I'm putting the scroll away!" say("I'm putting the scroll away!",1); }
Those are the main functions. The rest are:
pickup - When the item is added to Dink's inventory
drop - When the item is removed from Dink's inventory.
holdingdrop - When the item is removed from the player's inventory while it is armed.
So yeah, that's pretty much it. The graphic slots for the default magic and weapons are 437 and 438, respectively. Scroll graphics can be found in sequence 438, frames 14, 15, 16, and 17. Once again, if you named your scroll's script "item-scroll", the line to add it would look like:
add_item("item-scroll",438,14);
Hope that helps!