# World Container Management

Before using World Container API, you need to create a World Container API Management object as follows:

local WorldContainer = class.WorldContainer.new()

The specific function name and description are as follows:

Serial number Function name Description
1 addFurnace(...) Add Furnace
2 removeFurnace(...) Remove Furnace
3 checkFurnace(...) Check if it is a Furnace
4 getFurnaceHeatPercent(...) Get the Furnace heat percentage
5 getFurnaceMeltPercent(...) Get the melting percentage of the Furnace
6 addStorageBox(...) Add storage box
7 removeStorageBox(...) Remove storage box
8 checkStorage(...) Check if it is a storage box
9 clearStorageBox(...) Clear storage box
10 checkStorageEmptyGrid(...) Check the number of empty grids in storage box. When the item ID is passed in, check if the storage box is empty and if the item in the box
11 setStorageItem(...) Set storage item
12 getStorageItem(...) Get storage item ID
13 addStorageItem(...) Add items to the storage box
14 removeStorageItemByID(...) Remove storage box item by ID
15 removeStorageItemByIndex(...) Remove storage box item by index
16 addItemToContainer(...) Add container items to storage box
17 removeContainerItemByID(...) Remove container items from storage box
18 clearContainer(...) Clear the stirage box at the specified location

# addFurnace

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Add Furnace
  • The specific use cases are as follows:
--Generate a furnace at (0,0) height 7
--The parameters are the coordinates of the position where the furnace is to be generated
WorldContainer:addFurnace(0,7,0)
--Show in chat box
Chat:sendSystemMsg("A furnace was created at(0,0) height 7!")

# removeFurnace

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove Furnace
  • The specific use cases are as follows:
--Remove (0,0) height 7 furnace (or other blocks)
--The parameter is the coordinates of the furnace (or other block) to be removed
WorldContainer:removeFurnace(0,7,0)
--Show in chat box
Chat:sendSystemMsg("(0,0) furnace at height 7(or other block) was removed!")

# checkFurnace

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Check if it is a Furnace
  • The specific use cases are as follows:
--judge whether the position of (0,0) height 7 is the furnace,the parameters are the coordinates of the position to be judged
local result=WorldContainer:checkFurnace(0,7,0)
if result==0 then--if it is a furnace
	--Show in chat box
	Chat:sendSystemMsg("(0,0) height 7 position is the furnace")
else--if not a furnace
	--Show in chat box
	Chat:sendSystemMsg("(0,0) height 7 position is not a furnace")
end

# getFurnaceHeatPercent

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the Furnace heat percentage
  • The specific use cases are as follows:
--Obtain the remaining percentage of furnace fuel heat at the position of (0,0) height 7,the parameter is furnace coordinates
local result,val=WorldContainer:getFurnaceHeatPercent(0,7,0)
if result==0 then--If the acquisition is successful
	--Show in chat box
	Chat:sendSystemMsg("(0,0) the remaining percentage of furnace fuel heat at height 7 is:"..val)
else--if the acquisition fails
	--Show in chat box
	Chat:sendSystemMsg("Acquisition failed,maybe(0,0) height 7 position is not a furnace")
end

# getFurnaceMeltPercent

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get the melting percentage of the Furnace
  • The specific use cases are as follows:
--Get the (0,0) height 7 position of the furnace has been burned percentage,the parameters are furnace coordinates
local result,val=WorldContainer:getFurnaceMeltPercent(0,7,0)
if result==0 then--If the acquisition is successful
	--Show in chat box
	Chat:sendSystemMsg("(0,0) the height of the furnace at the height of 7 is currently burned percentage:"..val)
else--if the acquisition fails
	--Show in chat box
	Chat:sendSystemMsg("Acquisition failed,maybe(0,0) height 7 position is not a furnace")
end

# addStorageBox

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Add storage box
  • The specific use cases are as follows:
--Create a storage box at the position of (0,0) height 7,the parameters are the coordinates of the storage box to be generated
WorldContainer:addStorageBox(0,7,0)
--Show in chat box
Chat:sendSystemMsg("A storage box was created at(0,0) height 7!")

# removeStorageBox

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove storage box
  • The specific use cases are as follows:
--Remove (0,0) height 7 boxes (or other blocks)
--The parameter is the coordinates of the box (or other block) to be removed
WorldContainer:removeStorageBox(0,7,0)
--Show in chat box
Chat:sendSystemMsg("(0,0) the box(or other block) at height 7 is removed!")

# checkStorage

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Check if it is a storage box
  • The specific use cases are as follows:
--judge whether the position of (0,0) height 7 is a box,the parameter is the coordinates of the position to be judged
local result=WorldContainer:checkStorage(0,7,0)
if result==0 then--if it is a box
	--Show in chat box
	Chat:sendSystemMsg("(0,0) height 7 position is a box")
else--if not a box
	--Show in chat box
	Chat:sendSystemMsg("(0,0) height 7 position is not a box")
end

# clearStorageBox

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Clear storage box
  • The specific use cases are as follows:
--Empty the items in the box under the specified coordinates,the parameter is the coordinates of the box to be emptied
WorldContainer:clearStorageBox(0,7,0)
--Show in chat box
Chat:sendSystemMsg("Emptyed items of(0,0) height 7 boxes")

# checkStorageEmptyGrid

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Check the number of empty grids in storage box. When the item ID is passed in, check if the storage box is empty and if the item in the box
  • The specific use cases are as follows:
--Determine whether the storage box at the height of (0,0) has a free grid or a designated item
--The first three parameters are the coordinates of the box to be judged
--The last parameter is the id of the item to be judged,0 represents the free grid
local result=checkStorageEmptyGrid(0,7,0,0)
if result==0 then--if there is
	--Show in chat box
	Chat:sendSystemMsg("(0,0) storage box at height 7 also has free grid")
else--if not
	--Show in chat box
	Chat:sendSystemMsg("(0,0) height 7 storage box has no free grid")
end
--Determine whether there is bedrock,id is 1
result=checkStorageEmptyGrid(0,7,0,1)
if result==0 then--if there is
	--Show in chat box
	Chat:sendSystemMsg("(0,0) at the height of 7 has a core in the storage box")
else--if not
	--Show in chat box
	Chat:sendSystemMsg("(0,0) storage box at height 7 has no geocentric foundation stone")
end

# setStorageItem

--Set the items of the specified grid of the box at the specified position
--The first three parameters are the coordinates of the box to be set
--The fourth parameter 0 is the number of the specified grid,and 0 is the first grid
--The fifth parameter is the item id to be placed,101 is the soil block
--The last parameter is the number of items to be placed
WorldContainer:setStorageItem(0,7,0,0,101,30)
--Show in chat box
Chat:sendSystemMsg("(0,0) the first box of the height 7 position,30 soil blocks were placed")

# getStorageItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Get storage item ID
  • The specific use cases are as follows:
--Get the item id and number of the specified grid of boxes under the specified coordinates
--The first three parameters are box coordinates
--The last parameter is the grid number,0 is the first grid
local result,itemid,itemNum=WorldContainer:getStorageItem(0,7,0,0)
--Show in chat box
Chat:sendSystemMsg("(0,0) the first grid of the box at height 7 with "..itemNum.." items with id "..itemid)

# addStorageItem

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Add items to the storage box
  • The specific use cases are as follows:
--Add specified items to the box with specified coordinates
--The first three parameters are box coordinates
--The fourth parameter is the id of the item to be added,101 is the soil block
--The last parameter is the quantity to be added
local result,relNum=WorldContainer:addStorageItem(0,7,0,101,99)
--Show in chat box
Chat:sendSystemMsg("Try to add 99 soil blocks in the box at(0,0) height 7 position,actually added "..relNum)

# removeStorageItemByID

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove storage box item by ID
  • The specific use cases are as follows:
--Remove the specified items in the box at the specified coordinates
--The first three parameters are box coordinates
--The fourth parameter is the id of the item to be removed,101 is the soil block
--The last parameter is the quantity to be removed
WorldContainer:removeStorageItemByID(0,7,0,101,10)
--Show in chat box
Chat:sendSystemMsg("Removed 10 soil blocks in a box at(0,0) height 7")

# removeStorageItemByIndex

  • Parameters and types:
    • x,y,z:numberStorage box location
    • offset:numberStorage box grid index, starting from 0
    • num:numberItem number
  • Return value and types:
  • The main role of this method: Remove storage box item by index
  • The specific use cases are as follows:
--Remove items in the specified grid of the box at the specified coordinates
--The first three parameters are box coordinates
--The fourth parameter is the number of the grid to be removed,0 is the first grid
--The last parameter is the quantity to be removed
WorldContainer:removeStorageItemByIndex(0,7,0,0,5)
--Show in chat box
Chat:sendSystemMsg("Remove 5 items from the first box in the box at(0,0) height 7")

# addItemToContainer

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Add container items to storage box
  • The specific use cases are as follows:
--Add specified items to the box with specified coordinates
--The first three parameters are box coordinates
--The fourth parameter is the id of the item to be added,101 is the soil block
--The last parameter is the quantity to be added
local result,relNum=WorldContainer:addItemToContainer(0,7,0,101,99)
--Show in chat box
Chat:sendSystemMsg("Try to add 99 soil blocks in the box at(0,0) height 7 position,actually added "..relNum)

# removeContainerItemByID

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Remove container items from storage box
  • The specific use cases are as follows:
--Remove the specified items in the box at the specified coordinates
--The first three parameters are box coordinates
--The fourth parameter is the id of the item to be removed,101 is the soil block
--The last parameter is the quantity to be removed
WorldContainer:removeContainerItemByID(0,7,0,101,10)
--Show in chat box
Chat:sendSystemMsg("Removed 10 soil blocks in a box at(0,0) height 7")

# clearContainer

  • Parameters and types:
  • Return value and types:
  • The main role of this method: Clear the stirage box at the specified location
  • The specific use cases are as follows:
--Empty the items in the box under the specified coordinates,the parameter is the coordinates of the box to be emptied
WorldContainer:clearContainer(0,7,0)
--Show in chat box
Chat:sendSystemMsg("Emptyed items of(0,0) height 7 boxes")
Last Update: 6/11/2020, 9:30:46 PM