This is a small items.otb program for read/write and is compatible with TFS master written in Python and packaged with pyinstaller to make it portable.
Only works on Windows x64
Prepare your main.lua
file for the task you need and then run LuaOTB.exe
Read and Write - Header
local otb = OTB()
otb:load("items.otb")
print(otb.majorVersion)
print(otb.minorVersion)
print(otb.buildVersion)
print(otb.description)
The console output should look something like this:
You can also modify these variables to customize the file header:
local otb = OTB()
otb:load("items.otb")
otb.minorVersion = 10
otb.majorVersion = 20
otb.buildVersion = 1
otb.description = "My Custom OTB"
otb:save("items_out.otb")
How to see if the changes happened?
local otb = OTB()
otb:load("items_out.otb")
print(otb.minorVersion)
print(otb.majorVersion)
print(otb.buildVersion)
print(otb.description)
Read and Write - ItemTypes
local otb = OTB()
otb:load("items.otb")
local itemType = otb:getItemType(2160)
print(itemType)
-- modify the item
itemType.NAME = "My new name"
itemType.CLIENT_ID = 6666
otb:save("items_out.otb")
The console output should look something like this:
You should also see a new items_out.otb file in the directory.
You can open the new OTB and review it.
local otb = OTB()
otb:load("items_out.otb")
local itemType = otb:getItemType(2160)
print(itemType)
The console output should look something like this:
local otb = OTB()
otb:load("items_out.otb")
local itemType = ItemType()
itemType.GROUP = 1
itemType.FLAGS = 0
itemType.NAME = "My new item"
itemType.SERVER_ID = 6666
itemType.CLIENT_ID = 6666
otb:addItemType(itemType)
otb:save("items_out.otb")
To remove them you can use the method removeItemType
local otb = OTB()
otb:load("items_out.otb")
otb:removeItemType(2160)
otb:save("items_out.otb")
local otb = OTB()
otb:load("items_out.otb")
print(otb:getItemTypesCount())
local otb = OTB()
otb:load("items_out.otb")
local items = {}
for itemType in python.iter(otb.itemTypes) do
if itemType.GROUP == 1 then
items[#items + 1] = itemType
end
end
print(string.format("Found %d items", #items))
ItemType - Variables
It is worth mentioning that you cannot add new attributes, only modify existing ones!
GROUP - number
FLAGS - number
SERVER_ID - number
CLIENT_ID - number
NAME - string
DESCRIPTION - string
SPEED - number
SLOT - number
CONTAINER_SIZE - number
WEIGHT - number
WEAPON - number
AMMUNITION - number
ARMOR - number
MAGIC_LEVEL - number
MAGIC_FIELD_TYPE - number
WRITABLE - number
ROTATE_TO - number
DECAY - number
SPRITE_HASH - table
MINIMAP_COLOR - number
MAX_TEXT_LENGTH - number
MAX_TEXT_LENGTH_ONCE - number
LIGHT - number
DECAY2 - number
WEAPON2 - number
AMMUNITION2 - number
ARMOR2 - number
WRITABLE2 - number
LIGHT2 - table
TOP_ORDER - number
WRITABLE3 - number
WARE_ID - number
CLASSIFICATION - number
ARTICLE - string
CATEGORY - number
If you are interested in a more complete program you can choose to use LapisItemEditor