Universal Inventory System (API)

These are tools and utilities that make it easier to run games. This includes Lib: macro tokens dropped into MapTool to manage the game, a conversion file for CharacterTool to allow use in MapTool, or just about anything else you can think of -- except graphics with macros and anything specific to a particular campaign framework. Those are already covered by the Tilesets subforum and the Links and External Resources forum.

Moderators: dorpond, trevor, Azhrei, giliath, Gamerdude, jay, Mr.Ice

User avatar
Sir Flak
Dragon
Posts: 344
Joined: Thu Sep 28, 2006 4:20 pm
Location: Oklahoma, US

Re: Universal Inventory System (API)

Post by Sir Flak »

Excellent Tool Pyro. I created a cleanup macro. If you have a item type and change your mind later and want to get rid of that type, it leaves residual data in the Items area. For instance, while messing around with the your tool and trying to figure out how I wanted to organize the items I started with a type "weapon". Later I decided to break it into 2 types "melee weapon" and "range weapon". Even though the editor seemingly allowed me to delete that type, it only removed it from "ItemTypes" not the "Items" area. This macro goes through all the "Items" and if they are not in the Item types it removes them. It could be easily rewritten to use your functions, but when I wrote it I was still unfamiliar with them. It spits out the names of any cleaned Items as it's going.

Cleaner:

Code: Select all

[h: InventoryType = macro.args]
[h: Subtypes = json.get(eval(InventoryType), "ItemTypes")]
[h: Items = json.get(eval(InventoryType), "Items")]
[h: Fields = json.fields(Items,"json")]
[h: json.fields(Items,"json")]

[foreach(curItem, Fields, ""), code:
{
	[if(json.contains(Subtypes,curItem) == 0), code:
	{
		[curItem]
		[h: Items = json.remove(Items,curItem)]
	};{}]
}]
[setProperty(InventoryType,json.set(eval(InventoryType), "Items", Items))]
I also added a couple macros to also allow it to be a general json editor as well (basically another cleaner that strips out the "EquipSlots","EquipSlotTypes" and "Equipped") your dialog editor still works without these and it I like this gui better than your other json editor. At the moment I plan on your Lib as a Master DataBase that the player tokens reference to get their equipment data. So a player token might only reference a name and id# for a weapon on their actual token, and its data is all kept securely on the lib token. Then if i make a change or whatever it automatically is propagated to all of the players without them doing anything. At least that's my plan at the moment. We'll see if it works out.

Cleaner & Make Generic:

Code: Select all

[h: InventoryType = macro.args]
[h: Subtypes = json.get(eval(InventoryType), "ItemTypes")]
[h: Items = json.get(eval(InventoryType), "Items")]
[h: Fields = json.fields(Items,"json")]
[h: json.fields(Items,"json")]

[h: setProperty(InventoryType,json.remove(eval(InventoryType),"EquipSlots"))]
[h: setProperty(InventoryType,json.remove(eval(InventoryType),"EquipSlotTypes"))]
[h: setProperty(InventoryType,json.remove(eval(InventoryType),"Equiped"))]

[foreach(curItem, Fields, ""), code:
{
	[if(json.contains(Subtypes,curItem) == 0), code:
	{
		[curItem]
		[h: Items = json.remove(Items,curItem)]
	};{}]
}]
[h: setProperty(InventoryType,json.set(eval(InventoryType), "Items", Items))]

User avatar
PyroMancer2k
Dragon
Posts: 925
Joined: Thu Sep 11, 2008 2:04 pm

Re: Universal Inventory System (API)

Post by PyroMancer2k »

Sir Flak wrote:Excellent Tool Pyro. I created a cleanup macro. If you have a item type and change your mind later and want to get rid of that type, it leaves residual data in the Items area.
Yea I knew it would do that ;). I threw it together when I finally had some spare time though I had been thinking about it for sometime. I planned to add a cleaner along with more functions later when I had more time but just wasn't able to get around to it. And I hadn't given the API much thought lately as I've barely have time to even check up on forums these days :P.
Sir Flak wrote: I also added a couple macros to also allow it to be a general json editor as well (basically another cleaner that strips out the "EquipSlots","EquipSlotTypes" and "Equipped") your dialog editor still works without these and it I like this gui better than your other json editor.
Well I actually got the idea for the dialog editor from making my Json and StrProp editors which work on a similar setup. And even the item editor on my 4e Token was setup in a similar manner. The generic Json editor though was designed to be able to track down to an unlimited number of nested Json Objects and didn't have to for knowledge of this one to know what each object should hold and thus organize it in a nice neat fashion. So the Json Editor is actually much more powerful in that regard even though it doesn't look that nice.

The Equip stuff is easy enough to strip out because it's completely independent of the Item tracking. I originally debated on if I would use 2 different Json Objects which would mean having 2 variables on the token but figured it would be easier from the end users point of view to only have to worry about setting up 1 variable. But they would also have a way to track which items are equipped. Since an Inventory tracker is nice but most times you wanna know what weapon/armor is actually equipped so you can call that info for attack macros and displaying defenses.

As for customizations you've made the tool is suppose to be very open ended to allow people to quickly modify it and even things like the Dialog Editor is only one example for how to setup a user interface. I could just as easily have made a Dialog Interface that is more fancy like some of the other 4e Frameworks. The idea was to have a quick and easy way to store the data and access it without the player needing to worry about all the complex data structure organization which is often the problem for people with limited coding experience. And those who wanted to make a more elaborate Dialog Interface could but keep the example simple enough that they can decode how it is setup for a starting point.

It's good to hear your making good use of the tool. If you got any more info others might found helpful in customizing their own setups feel free to post it.

wrathgon
Dragon
Posts: 735
Joined: Wed Feb 06, 2008 10:28 am
Location: Guildford, UK

Re: Universal Inventory System (API)

Post by wrathgon »

nice tool, will have to play with it... when i stop playing with the spell manager and the 3.5pathfinder framework, running custom rule systems is a bit of a pain heh.

jsharen
Giant
Posts: 196
Joined: Tue Feb 05, 2008 3:39 pm

Re: Universal Inventory System (API)

Post by jsharen »

Has anyone created a token for pathfinder/3.5? Would be great to get an example of what that would look like.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Universal Inventory System (API)

Post by Azhrei »

No, but it's on my list. (Granted, near the bottom but it is there!)

flynnkd
Cave Troll
Posts: 53
Joined: Sun Jun 04, 2006 11:07 pm
Location: Brisbane

Re: Universal Inventory System (API)

Post by flynnkd »

Ignore, I got a copy.
Kevin Flynn
Skype: flynnkd

DarkWiz58
Cave Troll
Posts: 82
Joined: Sun Nov 08, 2009 8:29 pm

Re: Universal Inventory System (API)

Post by DarkWiz58 »

Thank you for this!

You've taken a lot of sweat off my forehead. I'm in the middle of trying to convert myself and a bunch of players from another, weaker, network-game system and your stuff helps with one of the questions I get asked the most: Inventory et al.

-Regards,
Alex / DarkWiz58

flynnkd
Cave Troll
Posts: 53
Joined: Sun Jun 04, 2006 11:07 pm
Location: Brisbane

Re: Universal Inventory System (API)

Post by flynnkd »

If anyone has done any customising work of their own with this I would love to see what you have done. I am looking to include some tools that will tally up values like Weight, or to adjust character modifiers based on item properties (magical items) etc. (an update character button of some kind). At the moment i am just trying to get my head around how it works...
Kevin Flynn
Skype: flynnkd

User avatar
Cronk
Cave Troll
Posts: 36
Joined: Mon Apr 13, 2009 11:47 am

Re: Universal Inventory System (API)

Post by Cronk »

First of all: Cool stuff!

But I am having some trouble using it. Setup works fine, but as soon as I try to call "Call Dialog equip character" (which is copied over to campaign macros) it fails giving me "Unknown JSON type in function json.get."
Any ideas why and how to fix it?
The only valid measurement of code quality: WTFs / minute

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Universal Inventory System (API)

Post by Azhrei »

That sounds like you need a default property value that should be "{}" or "[]".

User avatar
Cronk
Cave Troll
Posts: 36
Joined: Mon Apr 13, 2009 11:47 am

Re: Universal Inventory System (API)

Post by Cronk »

Well, adding default property value {} at least helped a bit. Still it is not usable.
"Call Dialog Equip Character" just brings up a window, filled blank with a "Close" Button at the bottom of it. Same for Dialog Item Editor.
"Call Equip Char" and "Call Item Editor" bring up an "Input Values" Dialog with a dropdown, only containing "0".
The other two functions still return "Unknown JSON type in function json.get."
The only valid measurement of code quality: WTFs / minute

NezziR
Kobold
Posts: 16
Joined: Sat Dec 12, 2009 1:48 am

Re: Universal Inventory System (API)

Post by NezziR »

Is this hosted somewhere else? The current download location requires a 'Premium Account' to download the file.

User avatar
Paradox
Dragon
Posts: 724
Joined: Fri Feb 27, 2009 4:01 pm

Re: Universal Inventory System (API)

Post by Paradox »

NezziR wrote:Is this hosted somewhere else? The current download location requires a 'Premium Account' to download the file.

Keep trying. Rapidshare is kinda gimmicky.. but what it's actually telling you is
There are no more download slots available for free users right now. If you don't want to become a premium member, you might want to try again later.
Definitely try again. It might be annoying, but you're not being totally blocked, eventually it will let you download the file. It'll even start telling you how many minutes you have to wait until you can.

I know this from experience. Just keep trying.

That's not an optimal solution I realize, but until someone can post it elsewhere.. there's a light at the end of the tunnel.
I no longer believe that MapTools is usuable or intended just for programmers. MapTools is for everyone.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Universal Inventory System (API)

Post by Azhrei »

Perhaps someone can add it as an attachment here? Or PM me the file and I'll add it as an attachment to the OP.

User avatar
booga
Dragon
Posts: 365
Joined: Fri Dec 14, 2007 9:00 am

Re: Universal Inventory System (API)

Post by booga »

Really cool work !
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:
[macro.return = "Inventory"]

I've been testing this system and noticed that I had to manually add a Property in my campaign properties that would match the variable name I had chosen in the first step of your tutorial. So for example, after running the "Call Declare Inventory User Functions", I selected the Location1 Macro on the Lib:Token, and edited it to

Code: Select all

[H: macro.return = "Inventaire
"]

If I then create a new token and copy the "Call Inventory Setup" macro then run it, It first asks for the value of "inventaire", then goes on with the setup. At the end, no error is reported in the chat, but no json is added to the token properties to contain the data. If I add a property first in my campaign Properties (named inventaire in this exemple), it gets populated and works fine.

Is it a normal behavior, or am I doing something wrong ? the setup instructions do not mention that step, so I guess I'm doing something wrong, which would be fairly typical :)

Post Reply

Return to “Drop-In Macro Resources”