Skip to content

This is a small items.otb program for read/write and is compatible with TFS master written in phyton and packaged with pyinstaller to make it portable.

Notifications You must be signed in to change notification settings

MillhioreBT/LuaOTB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LuaOTB

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

Usage

Prepare your main.lua file for the task you need and then run LuaOTB.exe

Read and Write - Header

How to open an OTB file?

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:

image

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)

image

Read and Write - ItemTypes

How to find an item to review or modify it?

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:

image

You should also see a new items_out.otb file in the directory.

image

How to know if the new file actually has the changes?

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:

image

How to add new items or maybe remove them?

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")

How to know the count of items?

local otb = OTB()
otb:load("items_out.otb")

print(otb:getItemTypesCount())

image

How to iterate over all items?

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))

image

ItemType - Variables

These are all the internal variables of ItemType

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

Notes

If you are interested in a more complete program you can choose to use LapisItemEditor

About

This is a small items.otb program for read/write and is compatible with TFS master written in phyton and packaged with pyinstaller to make it portable.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages