Scripting in inventories is very similar to conversations. There is no need for selecting an event, because the script attached to an item will only initialize when that item is actually used in-game. A max of four items can be placed in the inventory.
The Item Tag is the unique name that can be accessed by scripts.
The Thumbnail Image is the icon that is displayed in the game UI that represents that item. The images that are assigned to each indiviual iventory item need to be loaded into the Asset Panel as Textures.
The Script is what action takes place when the player clicks on the icon in the game UI.
NOTE: By allowing scripts on items, it gives the users to ability to create self modifying power-ups, abilities, or even teleportation items if desired. It only uses action scripts at the moment, the same through other scripting areas.
Inventory Script Process
Inventory scripting is very similar to conversation scripting, but with less steps.
- 1. To add a script to an item, first select an existing item, then use the "Script" drop down menu.
NOTE: As noted before, all "Script" drop down menus rely on the scripts in Story Object Panel to be populated. If there is no scripts in the Story Object panel, there will be no scripts to select from.
- 2. Depending on which script is selected in the drop down menu, parameters may be required. Similar to the parameters of the scripts in the Script Property panel, there are four text boxes that will enabled itself for each parameter of that selected script.
- 3. Since there is no way to delete a script from an item, users can use the "Do Nothing" script placeholder.
NOTE: Again, all action scripts are available to inventory just as anywhere else. Some of them can produce funky results.
Changing the UI Buttons
You can change what items are mapped to the UI buttons via scripts. Only four items can be loaded into the UI. The buttons are loaded not from the Inventory Map but in the order that they are collected. So if you have five items in the Inventory Map then the four buttons will display the first four items that the player collects. The fifth one will still be accounted for but will not be displayed. Only if displayed in a button can they be used. Any given scene should not have more than four inventory items. This functionality is built in to allow for the change of collectables from scene to scene.
- 1. Add additional items to the Inventory Map
- 2. Add asset script IN_ChangeButton.py to the library
- 3. On a game object, create an onScene event and load the IN_ChangeButton script into the event interface. For parameters, include the item tag and the button index (0-3)
If the item is in the UI already then nothing happens.
If the item is not in the Inventory Map an error is printed out
If any of the buttons are not in use then the item will load into the first available button.
If all buttons are in use then the item will replace the indexed button and the item that was there will still be tracked but not displayed.
Game Data is a collection of items like inventory but these items are not displayed in the game window's UI. They are setup and interacted with via action and condition scripts on game objects. They are useful for keeping track of if the player has a plot point item like "the gold key" or how many of a certain enemy they have killed.
Game Data has a string tag which is the name of the data entry and an integer value or count.