Library modApiFix


Recommended Posts

This is a very small library you can add you your mod which does the following:

 

Fixes:

mod_api:addItemDef( name, itemDef )

 

Adds:

mod_api:remItemDef( name )

 

Problem:

Adding items with addItemDef will correctly change base items in itemDefs, but incorrectly increases the available items in shops; instead of replacing the old one with identical name.

 

addItemDef:

This library changes addItemDef so shops will swap out items instead of adding to the list when a duplicate id is found.

 

remItemDef:

This function removes specified item from shops. The item will still exist in itemDef, in order to avoid errors from agents having said item as starting equipment.

 

TODO:

Figure out if items need to be removed from other places like drops, Monst3r, etc. Any tips would be greatly appreciated!

 

How to use:

This is not a full mod. If you want the functionality all you need to do is add the file lib_modApiFix.lua to your mod's scripts folder and add the following line to your modinit.lua's init function:

 

include( scriptPath .. "/lib_modApiFix" )( modApi )

 

Library download:

1.0.0 lib_modApiFix.lua

1.0.3 lib_modApiFix.lua

 

Version History:

1.0.0: first draft.

1.0.1: remItemDef now removes item from nanofabs, security dispatch missions, Monst3r's shop and guard drop tables as was intended. Agents starting with item will still have them, as intended.

1.0.2: bugfix

1.0.3: bugfix

Link to comment
Share on other sites

Figure out if items need to be removed from other places like drops, Monst3r, etc. Any tips would be greatly appreciated!

Isn't in shops appears only items with line "ItemList = true" (or weaponList etc)?

(I mean I not quite understand in what cases remItemDef could be used, can you explain it more?)

And in Security Dispatch only items with floorweight = 3 or more? And in guard's pockets only items coded in guarddefs.lua? and Monst3r sales should be in... ok I can't remember this one but there were lists of items that can appear, if I remember correctly even each own lists for any day when it triggers, so new added items shouldn't appear there.  

Link to comment
Share on other sites

Thanks for the pointers. I've found drops and security dispatch generation code. Monst3r's sold items seem to be all located in simdefs.ITEMS_SPECIAL_DAY_1, ...DAY_2, etc. so they will also be easy to filter.

 

Ok, I can explain what I want remItemDef to do.

 

In a case where you'd want an item like say Neural Disrupter to be removed from the game, you'd call remItemDef( "item_tazer"). It will then remove the item from any shop lists, guard drop tables, security dispatch (set floorWeight = 0) and hopefully Monst3r's sold items (if it is doable). It will *not* however remove the item from itemDefs, because any agent starting with a Neural Disrupter would cause all kinds of issues.

 

Edit:

Added v:1.0.1 which adds the intended functionality to remItemDef.

 

addItemDef might get functionality to add items to guard droptables and/or monst3r's shop, but I am unsure, so I'm holding off on that for now.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.