Simple Inventory Management?

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

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

Post Reply
User avatar
growlly
Cave Troll
Posts: 32
Joined: Fri Jul 10, 2015 11:35 am
Location: United States

Simple Inventory Management?

Post by growlly »

Hi, I'm a new user trying to build a simple homebrew RPG, and I think inventory management is going to be the main challenge. My system is probably 10% as complicated as D&D/Pathfinder overall though, so I think I'm within the realm of reason. Here are my optimal requirements for the system:
1) Players can have up to, say, 5 weapons on a token at a time. Perhaps their stats are stored in fields like Weap1Accuracy, Weapon1Damage, Weapon2Accuracy, Weapon2Damage, etc. I suppose those would have to be token properties.
2) The ability to view a list of weapons on the token and their associated stats.
3) Only one weapon is "equipped" at a time (we'll call the others "stowed").
4) Ideally the player would click an EquipWeapon macro and choose the weapon he wants to equip from a list of weapons on his token. Perhaps a set of fields like EquippedAccuracy, EquippedDamage now take the values of the chosen weapon.
5) The weapons have persistent stats and states that remain when they are stowed. Example: Weapon1 is damaged, so player equips Weapon2. Weapon1 is stowed but is still damaged.
6) The ability to "pick up" a weapon by clicking a macro that adds a weapon, ideally from a dropdown list of all weapons in the game, to the token's inventory.
7) Likewise, the ability to "drop" a weapon by clearing it from the token's inventory.
8 ) The ability to modify weapons somehow. For example, I would want a player to be able to equip/unequip a scope on a weapon, thereby modifying the weapon's stats. Perhaps the player "picks up" a modification like a scope from a dropdown which then gives the player "EquipScope" and "UnequipScope" macro buttons that modify the weapon's stats? Then "dropping" the scope would unequip it and remove those buttons.
9) Finally, a way to create a master list of all the weapons and modifications for the tokens to reference. Ideally I (GM) would be able to edit which items are visible on the list. There are 100+ weapons that I have stats for in Excel, so I'd love to automate somehow... but I would be willing to resort to dialog box or table data entry if necessary.

I looked at the example Pathfinder campaign file that does all or nearly all of the things mentioned above (and more), but I don't think I can reverse engineer it. Does anyone have advice? I think I have a good idea of what I want conceptually, but I'm not sure where to start in terms of translating it into macro code. I also think #2 would be solved by the Introduction to Dialogs and Frames tutorial, but I can't get it to work. Thanks.

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Simple Inventory Management?

Post by aliasmask »

You might find this code useful. I created a generic attack macro that handles weapons, spells or whatever. It's designed for 5th edition, but can be easily tweaked.

http://forums.rptools.net/viewtopic.php ... 92#p225246

User avatar
growlly
Cave Troll
Posts: 32
Joined: Fri Jul 10, 2015 11:35 am
Location: United States

Re: Simple Inventory Management?

Post by growlly »

Just wanted you to know that I did indeed look at that, and it seems impressive. Unfortunately, I think it will be a while before I could begin to understand the code enough to adapt it to my game. I've come up with a barebones system that I think will work, and I'll describe it below (surely to the horror of anyone who actually knows what they're doing).

There are a series of campaign properties called EquipWeapName, EquipWeapDmg, EquipWeapCurrentAmmo, EquipWeapMaxAmmo, etc. There are also 5 sets for Weapon1Name, Weapon1Dmg, etc. When the player clicks "EquipWeapon1", the EquipWeap properties take the values of the Weapon1 properties (via a method using probably 10x as much code as necessary). All attack rolls and other actions only use the EquipWeap properties. When the player clicks "StowWeapon", the EquipWeap properties reset, enabling the player to equip any of the other weapons. By blacking out the buttons and using assert to stop the action if the player tries to do something they shouldn't, I think it will work well enough.

The main challenge I have now for inventory is figuring out how to give weapons to tokens without typing it in every time. Ideally I'd have some kind of database of weapons built. Then I, GM, click "GiveWeapon" to: 1) pick a target receiving token, 2) pick a weapon slot on that token (i.e. 1-5), 3) pick a weapon from the database, 4) the macro updates the weapon properties from the target slot with the selected weapon's properties. I'm hoping wolph's table stuff will be helpful for this purpose, but obviously I'm a little intimidated.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Simple Inventory Management?

Post by wolph42 »

You need to start learning json coding and that won't be easy, my table stuff takes away part of that pain as it employs json under the hood, but still...
You can try using it and retrieve stuff you need from the tables as is explained in the tables manual, but in the long run I think you're better off learning json objects. Start reading the wiki and start asking questions...

User avatar
growlly
Cave Troll
Posts: 32
Joined: Fri Jul 10, 2015 11:35 am
Location: United States

Re: Simple Inventory Management?

Post by growlly »

I looked at the JSON stuff and it seems like the main advantage for me would be that I could have 5 properties (for the 5 weapon slots) with a list of 10 variables inside each one instead of 50 properties. Is that about right?

I tried the tables thing in your sig and also, perhaps more relevant to my project, the stuff from this thread with the Lib:Lists token.

[EDIT: Ignore the following, I figured it out.]
Spoiler
I tried it out, but I keep getting errors.

When I try to test the tavern table list, I get this error:
Error in body of roll.
Statement options (if any): r
Statement Body : "The "+Tables("Taverns",first+2) + " " + Tables("Taverns",second+5)

The console output says undefined function: Tables. How can I fix that?

Finally, I saw that you list a way to look things up by column and row number. Is there a way to look up a row using, for example, the contents of the first item in the row?

User avatar
growlly
Cave Troll
Posts: 32
Joined: Fri Jul 10, 2015 11:35 am
Location: United States

Re: Simple Inventory Management?

Post by growlly »

wolph, I tried using the tables stuff in the thread linked above. The included test tables work fine (testWeapons, Test Get Tavern Name). I put in a test table that is 3 rows and 25 columns, but I can't seem to get it to work. When I click the blue button on Lib:Lists, it asks me to input a value for "end" and says:
   Error in body of roll.
      Statement options (if any): r
      Statement Body : Tables(chosenList)

If I try to get data out of my test table (just like the testWeapons button), it just tells me invalid path. Am I missing something?


EDIT: I cut it down to just 2 rows and 2 columns and still get errors. This is the data I'm pasting after clicking the red button. In Excel, the first two letters are in one column, and the weapon names are in the second column.
w1 Walther PPK
w3 SW Model 66

And here's the output after clicking save:
{"w3":{"Walther+PPK":"SW Model 66"}}

I notice that there's no mention of w1 and the + in the PPK name doesn't seem consistent with the other one. Any ideas?


User avatar
growlly
Cave Troll
Posts: 32
Joined: Fri Jul 10, 2015 11:35 am
Location: United States

Re: Simple Inventory Management?

Post by growlly »

No problem, I'm still going to do a little trial and error to see if I can narrow it down a little.

I copied the treasure table (the yellow one) from your Excel system, and oddly enough it works. I think some of my tests didn't work because they didn't have enough rows--that was the only difference between my last two tests. I'll edit this post if I find anything else.

EDIT: Ok, the source of the problem is definitely that I had too few rows in my early trials. I thought I would test the system with just 3 rows of data before putting in the whole 100+ rows, but apparently that was the wrong strategy for testing this. I don't know what the minimum number of rows is, but it's bigger than 3. The blue button still doesn't work for my data (and it still asks for an "end" value), but I'm not concerned about it. For my purposes, I just want to store the data and then be able to call the fields with macros, and that seems to work.

EDIT: More limitations - you can't call from the first row, and the column lookup reference has to be alloneword. Thus, I'll need to look up my weapons with an index number or abbreviation instead of their full names.

My next step is to set up a GetWeapon macro. I'm assuming I can use the first part of my targeting macro to pick which token is getting the weapon, but I'll need to modify it so that there's a second dropdown box that asks for the weapon slot (1-5) that the weapon is going to, then update the properties for that slot. I'll try that the next time I work on it, but I've never coded a dialog with multiple outcomes myself.

Post Reply

Return to “Macros”