This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
item_pickup_tutorial [2018/03/07 16:11] – justin | item_pickup_tutorial [2018/03/07 20:58] (current) – justin | ||
---|---|---|---|
Line 1: | Line 1: | ||
======Item Pickups====== | ======Item Pickups====== | ||
+ | This tutorial will explain how to set up map [[object|objects]] as [[item|items]] for the [[player_character|player]] to pick up, for example a key that the [[player_character|player]] can pick up by walking into/over it and then use to open a door or treasure chest. | ||
- | (WIP) | + | **Note:** This tutorial assumes that you already understand the basics of using the RPG in a Box editors, in particular the [[Map Editor]] and [[Voxel Editor]]. |
- | + | ||
- | This tutorial will explain how to set up map objects as items for the player to pick up, for example a key that the player can pick up by walking into/over it and then use to open a door or treasure chest. | + | |
- | + | ||
- | **Note:** This tutorial assumes that you already understand the basics of using the RPG in a Box editors, in particular the [[Map Editor]] and [[Script | + | |
=====Creating the Object Model===== | =====Creating the Object Model===== | ||
- | + | Open the [[New Resource Dialog]] and create a new [[object]]. Once the [[Voxel Editor]] opens for the new [[object]] model, use the [[voxel]] tools to build a key as shown below (or whatever will best visually represent the [[item]]). | |
- | Create model for key object | + | |
{{: | {{: | ||
+ | |||
+ | After the model is complete, be sure to enable the " | ||
{{: | {{: | ||
- | Optional: Default | + | Before proceeding to the next section, you can optionally create a " |
- | [[floating_anim_tutorial|Creating a Simple Floating Animation]] | + | |
- | Create | + | =====Defining the Item===== |
+ | In addition to the [[object]] model, you'll also need to define the corresponding [[item]] that the [[player_character|player]] will receive | ||
{{: | {{: | ||
- | Optional: create sound effect for picking | + | Remember the name you used for your item (including case) as it will be referenced in a [[quick script]] later on. Click the " |
+ | |||
+ | =====Creating a Sound Effect===== | ||
+ | Optionally, you can create | ||
{{: | {{: | ||
- | Place object into map in desired location | + | Once you are happy with the [[sound]], click the "Save Sound" button ({{: |
+ | |||
+ | =====Setting Up the Object in a Map===== | ||
+ | Open the [[map]] where you'd like to have the [[item]] pickup. Select the [[object]] model you created earlier from the resource container on the right, then place the [[object]] onto an open [[tile]] | ||
{{: | {{: | ||
- | Open properties dialog for object and assign an entity | + | Switch into " |
{{: | {{: | ||
- | Open properties | + | Double-click the [[tile]] underneath the [[object]] (or right-click on it and select " |
+ | |||
+ | Copy and paste the [[script]] source code below into the dialog as shown. You may need to make a few adjustments according to the names you chose earlier on, in particular the entity ID for the [[object]] (" | ||
<code lua> | <code lua> | ||
Line 45: | Line 51: | ||
{{: | {{: | ||
- | Finished! Save map and export game, player | + | To better understand what the [[script]] is doing, I've included explanations for each line. |
+ | |||
+ | <code lua> | ||
+ | set_entity_script(self, | ||
+ | </ | ||
+ | |||
+ | This line removes the [[script]] from the [[entity]] that activated it (" | ||
+ | |||
+ | <code lua> | ||
+ | remove_entity(entity["key_01"]); | ||
+ | </ | ||
+ | |||
+ | This line removes the physical | ||
+ | |||
+ | <code lua> | ||
+ | play_sound(" | ||
+ | </ | ||
+ | |||
+ | This line plays the [[sound|sound effect]] named " | ||
+ | |||
+ | <code lua> | ||
+ | give_item(" | ||
+ | </ | ||
+ | |||
+ | This line puts the [[item]] named "Gold Key" into the [[player_character|player' | ||
+ | |||
+ | Click the " | ||
+ | |||
+ | =====Testing the Pickup In-Game===== | ||
+ | [[exporting_your_game|Export the game]] to try out your new [[item]] pickup. The [[player_character|player]] should now receive a Gold Key in their [[inventory]] | ||
{{: | {{: | ||