Do to request I have added user defined functions to the inventory system to make it easier to use. Now you can simply do function calls like other functions without all the bulking [macro():] commands. The old way still works and in the interest of saving time I left most of my examples still using the macro call method but it does effect anything cause it's calling the same macro just in a different way.
Also to help limit the need for changing of several macros when setting a new system I added 4 location macros which simply return the name of the variable where they inventory is stored. This allows for up to 4 different inventory properties to be used and more can easily be added if need be.
In the campaign I also added a Player Macro which has the 6 main macros a player needs on their token to get started. The most important is of course the new "Call Declare Inventory User Functions" macro which the player needs to run in order for the user defined functions to work.
I also updated the Setup description to reflect the changes.
Here are the new files which I also updated at the end of the post as well.
Campaign
http://rapidshare.com/files/228507059/U ... V1_1.cmpgn
Token
http://rapidshare.com/files/228507010/U ... y1_1.rptok
-----------------------------
When it comes to making a token for any system one of the biggest challenges is creating the inventory system. To help would be coders over come this problem of how to manage lots of items in a dynamic way along with keeping track of what items are equipped I have created what I refer to as the Universal Inventory System. I call it this because it is completely independent of any framework setup or token properties. The Lib:Token can be put into any game and after running the quick setup the system is ready for use.
Besides the setup macro it comes with simple item editor and character equip macros for a demonstration. But the key thing to the system is it has several macros which you use like functions to get information and set items. This way you don't need to worry about how it is manipulating the json objects behind the scenes. All you need to do is run the macro to get an Item and it will return a Json Object of that it's properties which you can then use in custom macros.
SETTING UP
Setting it up is very easy and only takes a few quick Steps. I've included a few screen shots from the various example Inventory setups I included in the campaign file as examples.
IMPORTANT: The setup uses user defined functions which will automatically load from the onCampaignLoad macro when a campaign is loaded that has the Lib:Token in it. However if you are just starting out and copy the Lib:Token into a current campaign you will need to run the "Call Declare Inventory User Functions" macro in order to set the functions. If you get lots of error messages saying undefined function this is the cause and running the macro should fix it.
1) The Lib:Token contains a few default macros for interacting with the Inventory system. You need to either copy the "Call Inventory Setup" over to the Token you wish to add an inventory to or copy it to Campaign macros and then you can run it on the token from there.
2) Before you run the "Call Inventory Setup" macro you need to make a quick edit to it. You will notice where the arguments should be is a function called "inventory.location1()" in the [macro():] call. This function calls a macro on the Lib:Token named "location1". The macro only contains one line setting the macro.return equal to the variable name that holds the inventory. Simply change the name here and all other macros that use it as a reference will be changed as well. The line in "location1" looks like the following.
Code: Select all
[macro.return = "Inventory"]
3) Next you simply need to run the "Call Inventory Setup" the macro and you will be prompted to enter the types of items your inventory system can handle. The items are entered in list format with a comma separating each. Below is a screen shot of the setting up for some of the example inventory setups I included.
4) The new prompt will allow you to enter a list of all the item properties or each type of item. The order is slightly important for a few reasons. The property located in the first slot will be used when some of the functions return a list of items by Name or whatever property you choose to enter first. Also when the functions return what properties an item has it will return that list in the same order.
5) Next up is the slots which you can equip. This list order doesn't really matter except that when you use the macros to call list of all slots it returns them in this order. Other then that you can simply enter whatever slots you want to keep track of.
6) This step is one of the things that makes the inventory system so useful. You will be prompted which types of items can be equipped in each slot. Simply check which item types you wish to allow and it's even possible to choose all.
7) Your almost done now. While the inventory system is technically setup at this point you need a way to interact with it so you can edit your items and equip character. Copy all the macros on Lib:Token in the section "Z: Calling Macros (Copy to Main Token)" onto your token macros or campaign macros. . Once this is done you will be able to experiment with your new inventory.
Here is a picture of the Dialog window for 2 of the setup examples I made. In the picture you'll note the Dialog windows have different names. This is because it is setup to use the name of the variable where the inventory is stored as the Dialog window name.
Examples
I've included 4 example tokens in the campaign file to show how things work and give a starting point for those who wish to use it to make more of their own macros.
UPDATE: The examples of calling macros on all of the 4 example systems have been updated to include the new user defined functions. I left the old style macro and the new function call in them to show off how the two setups differ for those who wanna choose which to use.
I also changed it so they use the new location functions to refer to the variable where their inventory is thus reducing the need for editing should the inventory be moved.
Example 4E System
This token has the most macros on it because it is showing off all the macro calls for the system.
The first section is called "Example Data Calls". The macros in this section of the token are simply showing off what types of data are returned by the various call functions. All the arguments that are passed into them are directly coded into the macros but you can change them to see how it effects what returns. This is a good place to experiment to learn what to pass in and what comes out of the macro arguments.
Next are the Example Interfaces which are the basic interfaces that come with the system. They call macros on the Lib:Token so you can view how they are setup if your interested in creating your own.
Then there is the "Example Set Calls" section which are all the macros that allow you to set various things in inventory like which items are equipped, item's stats, and etc. These macros help show off the format so you can get a better idea of how to use them in your own macros.
Lastly is the Setup Inventory Macro which allows is standard for all setups. It allows you to edit the inventory layout.
Misc Fantasy System
This is a very basic setup which demonstrates you can use more refined groups like different weapon types as well as different armor types and still allow them to be selectable as equipment to a particular slot. For those wanting to have a more defined inventory instead of simple types like "Weapon" and "Armor".
Other then that and a simple Get Equipped Item macro being shown off there is not much to see.
Misc Military System
This setup also shows off the ability to refine items into more precise types while still having them equipable to chosen slots. Though it also shows an example of the inventory system being stored in "Gear" on the token properties instead of "Inventory" like the previous two.
Multiple Inventories
This setup shows how to do 2 inventory systems on a single token and how they can have different Item Types and Equipment Slots. This one also has 2 useful examples for doing usable items. The first example is Use Potion which allows you to select a potion you have and drink it. The other example is Used Equipped which simply uses the item that is equipped in that slot, which in the case of the example is ammo equipped in a quiver.
UPDATED version 1.1
Campaign
http://rapidshare.com/files/228507059/U ... V1_1.cmpgn
Token
http://rapidshare.com/files/228507010/U ... y1_1.rptok