Jump to content

Issue Finding Working Item.Type For My Mod. Advice?


Pravus

Recommended Posts

I’m an amateur scripter at best but I had an idea for a couple of mods I wanted to try my hand at creating for the community so I decided to give mod making a shot.  One of them (a mod that adds a .30-30 rifle plus ammunition to the vanilla game), I managed to get to work near flawlessly by studying the mod structure of other available mods made by more experienced modders here on the forum (I’ve never touched LUA before this so I’m kind of learning as I go by trial and error).  The other one however has been one headache after the other.  I had it working somewhat last night, but I hadn’t written the distribution lua or finished the custom art yet so I moved on to work on that portion of my mod.  Unfortunately, while tweaking and playing with things around that time I must have changed something and it has never fully correctly worked again since.  I can’t for the life of me remember what I changed and most of the errors I’m experiencing now seem to be directed toward what I set the new items Type property to at this point.

 

Basically my intention is to create a mod that creates “hydration packs.”  Without referencing any specific brand names (most people recognize these by one particular manufacturer’s namesake, ie. how some people call any and all tissues a “Kleenex”), a hydration pack is a type of backpack or rucksack with a built in water reservoir designed to be used by hikers, survivalists, and the military.  They usually have a tube and valve system that runs over the shoulder so that the wearer can simply turn their head and suck water from the tube anytime they get thirsty while wearing the gear.  I own one in real life and it’s been *fantastically* convenient for long outdoor adventures.

 

The issue I’ve run into at this point is this: I can get a fully functional “empty hydration pack” item implemented that can be equipped to primary, secondary, or back slots, has proper capacity and weight reduction, and gives the option to fill the pack from a water source via context menu.  Currently I have this type of item set to “Type = Container,”  The problem I’m now experiencing comes when I attempt to actually fill from that water source and convert the item to a “filled hydration pack.”

 

If I set the filled pack to “Type = Container, “ the compiler gives the following error everytime:

attempted index: setUsedDelta of non-table: null

-----------------------------------------

STACK TRACE

-----------------------------------------

function: onTakeWater –- file: ISWorldObjectContextMenu.lua line #774

function: onMouseUp –- file: ISContextMenu.lua line #78

 

If I set the filled pack (or the unfilled pack for that matter, I’ve tried combinations of both) to either “Type = Drainable,” or “Type = DrainableComboItem,” I can get the item to fill and convert from “empty” to “filled” versions in game but using this setting on either item immediately causes it to lose the ability to be equipped to the players’ back (despite having “CanBeEquipped = Back,” scripted for each item and not flagging any errors).

 

I’ve tried everything I could think of for the past several hours and I’m afraid I’m at the limit of my ability now.  Can anyone explain to me where I might be making a mistake or suggest revisions to the script to potentially get this working?

 

Here's a link to download the mod in its current state of development if you'd like to take a closer look at my work so far: http://www.mediafire.com/download/kfiadf3ulfz2i0d/hpackmodWIP.rar

 

Thanks in advance!

Link to comment
Share on other sites

  • 4 weeks later...

im going to be a bit cautious in my reply because i havent been fiddling around with items that much, except for the drainable ones for the last project...

however, i think what youre trying to do simply isnt possible via the items.txt file.. this due to the fact that drainable and container types are both different classes that extent inventory item:

54376a3dba139ebd2c72d3028905154a.png

Thats the reason you get the error "attempted index: setUsedDelta of non-table: null" with containers, as they dont have that function, on the other hand drainables dont have the equip on back functionality.

So you have to choose between one of them.

 

Alternativly you could resort to lua and script the functionality needed in there, or example using the container, setting its capacity to 0 so no items can be put in it, then controlling the water amount with the item's moddata. Im afriad tho that if you go that way youll have to include context menus etc yourself as it will not automatically be compatible with the game as a drainable water source would be.

Other then that a solution would be to simply drop the equip option and have it be carried around in the players in the inventory.

 

Regards,

Turbo

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...