IDE hinting: extract several classes into separate files

This commit is contained in:
Alexander Chibrikin
2022-12-27 03:43:26 +03:00
commit f8b932d5f9
8 changed files with 2641 additions and 0 deletions

56
classes/AreaStore.lua Normal file
View File

@@ -0,0 +1,56 @@
--- @class AreaStore
--- `AreaStore` is a data structure to calculate intersections of 3D cuboid volumes and points.
--- Despite its name, mods must take care of persisting AreaStore data. They may use the provided load and write functions for this.
--- @field data string may be used to store and retrieve any mod-relevant information to the specified area.
AreaStore = {}
---@param type_name string|nil optional, forces the internally used API. Possible values: "LibSpatial" (default). When other values are specified, or SpatialIndex is not available, the custom Minetest functions are used.
---@return AreaStore Returns a new AreaStore instance
function AreaStore:AreaStore(type_name) end
---@param id any type not specified in docs
---@param include_corners boolean whether to include corner info in return table or not
---@param include_data boolean whether to include data info in return table or not
---@return nil|boolean|table Returns the area information about the specified ID.
---Returned values are either of these:
---```lua
---nil -- Area not found
---true -- Without `include_corners` and `include_data`
---{
--- min = pos, max = pos -- `include_corners == true`
--- data = string -- `include_data == true`
---}
---```
function AreaStore:get_area(id, include_corners, include_data) end
---Returns all areas as table, indexed by the area ID.
---Table values: see get_area.
function AreaStore:get_areas_for_pos(pos, include_corners, include_data) end
---Returns all areas that contain all nodes inside the area specified bycorner1 and corner2 (inclusive).
---accept_overlap: if true, areas are returned that have nodes in common (intersect) with the specified area.
---Returns the same values as get_areas_for_pos.
function AreaStore:get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data) end
---inserts an area into the store.
---
---Returns the new area's ID, or nil if the insertion failed.
--- The (inclusive) positions corner1 and corner2 describe the area.
--- data is a string stored with the area.
--- id (optional): will be used as the internal area ID if it is a unique number between 0 and 2^32-2.
function AreaStore:insert_area(corner1, corner2, data, id) end
---Requires SpatialIndex, no-op function otherwise.
--- Reserves resources for count many contained areas to improve efficiency when working with many area entries. Additional areas can still be inserted afterwards at the usual complexity.
function AreaStore:reserve(count) end
---removes the area with the given id from the store, returns success.
function AreaStore:remove_area(id) end
---sets params for the included prefiltering cache. Calling invalidates the cache, so that its elements have to be newly generated.
---
--- params is a table with the following fields:
---
--- enabled = boolean, -- Whether to enable, default true block_radius = int, -- The radius (in nodes) of the areas the cache -- generates prefiltered lists for, minimum 16, -- default 64 limit = int, -- The cache size, minimum 20, default 1000 * to_string(): Experimental. Returns area store serialized as a (binary) string. * to_file(filename): Experimental. Like to_string(), but writes the data to a file. * from_string(str): Experimental. Deserializes string and loads it into the AreaStore. Returns success and, optionally, an error message. * from_file(filename): Experimental. Like from_string(), but reads the data from a file.
function AreaStore:set_cache_params(params) end

48
classes/InvRef.lua Normal file
View File

@@ -0,0 +1,48 @@
--- @class InvRef
InvRef = {}
--- return true if list is empty
--- @param list_name string
--- @return boolean
function InvRef:is_empty(list_name) end
--- get size of a list
--- @param list_name string
function InvRef:get_size(list_name) end
--- set size of a list, avoid e.g. , 7*3), use , 21) --7*3 instead to avoid confusion with formspec#list
--- @param list_name string
function InvRef:set_size(list_name, size) end
--- get width of a list
--- @param list_name string
function InvRef:get_width(list_name) end
--- set width of list; currently used for crafting
--- @param list_name string
function InvRef:set_width(list_name, width) end
--- get a copy of stack index i in list
--- @param list_name string
function InvRef:get_stack(list_name, i) end
--- copy stack to index i in list
--- @param list_name string
function InvRef:set_stack(list_name, i, stack) end
--- return full list
--- @param list_name string
function InvRef:get_list(list_name) end
--- set full list (size will not change)
--- @param list_name string
function InvRef:set_list(list_name, list) end
--- return full lists. Ex: {main={ItemStack,ItemStack...}, craft={..},hand={..}...}
function InvRef:get_lists() end
--- set full lists. Ex: {main={ItemStack,ItemStack...}, craft={..},hand={..}...}
--- @param lists table
function InvRef:set_lists(lists) end
--- add item somewhere in list, returns leftover ItemStack
--- @param list_name string
function InvRef:add_item(list_name, stack) end
--- returns true if the stack of items can be fully added to the list
--- @param list_name string
function InvRef:room_for_item(list_name, stack) end
--- returns true if the stack of items can be fully taken from the list
--- @param list_name string
function InvRef:contains_item(list_name, stack) end
--- take as many items as specified from the list, returns the items that were actually removed (as an ItemStack)
--- @param list_name string
function InvRef:remove_item(list_name, stack) end

80
classes/ItemStack.lua Normal file
View File

@@ -0,0 +1,80 @@
---@class ItemStack
ItemStack = {}
--- put some item or stack onto this stack, returns leftover ItemStack
function ItemStack:add_item(item) end
--- increases wear by amount if the item is a tool
---@param amount number
function ItemStack:add_wear(amount) end
--- removes all items from the stack, making it empty
function ItemStack:clear() end
--- returns number of items on the stack
---@return number
function ItemStack:get_count() end
--- returns true/false (success), clears item on failure
---@param count number
function ItemStack:set_count(count) end
--- returns the item definition table
function ItemStack:get_definition() end
--- returns get_stack_max() - get_count()
function ItemStack:get_free_space() end
--- returns a MetaDataRef
function ItemStack:get_meta() end
--- returns a string, for compatibility reasons this is equal to get_meta():get_string("")
---@deprecated
function ItemStack:get_metadata() end
--- returns item name (e.g. "default:stone")
---@return string
function ItemStack:get_name() end
--- returns true/false (success), clears item on failure
---@param item_name string
function ItemStack:set_name(item_name) end
--- returns the maximum size of the stack (depends on the item)
function ItemStack:get_stack_max() end
--- returns the digging properties of the item, or those of the hand if none are defined for this item type
function ItemStack:get_tool_capabilities() end
--- returns tool wear (0-65535), 0 for non-tools
function ItemStack:get_wear() end
--- returns true/false (success), clears item on failure
function ItemStack:set_wear(wear) end
--- return true if stack is empty
---@return boolean
function ItemStack:is_empty() end
--- returns true if the item name refers to a defined item type
---@return boolean
function ItemStack:is_known() end
--- returns true if item or stack can be fully added to this one
function ItemStack:item_fits(item) end
--- copy (don't remove) up to n items from this stack; returns copied ItemStack; if n is omitted, n=1 is used
function ItemStack:peek_item(n) end
--- replace the contents of this stack (item can also be an itemstring or table)
function ItemStack:replace(item) end
--- take (and remove) up to n items from this stack; returns taken ItemStack; if n is omitted, n=1 is used
function ItemStack:take_item(n) end
--- returns the stack in itemstring form
function ItemStack:to_string() end
--- returns the stack in Lua table form
---@return table
function ItemStack:to_table() end

48
classes/NodeMetaRef.lua Normal file
View File

@@ -0,0 +1,48 @@
---@class NodeMetaRef
NodeMetaRef = {}
---@param key string
---@return boolean|nil
function NodeMetaRef:contains(key) end
---@param key string
---@return string|nil
function NodeMetaRef:get(key) end
---@param key string
---@param value string
---@return number
function NodeMetaRef:set_string(key, value) end
---@param key string
---@return number
function NodeMetaRef:get_string(key) end
---@param key string
---@param value number
---@return number
function NodeMetaRef:set_int(key, value) end
---@param key string
---@return number
function NodeMetaRef:get_int(key) end
---@param key string
---@param value number
---@return number
function NodeMetaRef:set_float(key, value) end
---@param key string
---@return number
function NodeMetaRef:get_float(key) end
---@return table|nil
function NodeMetaRef:to_table() end
---@param value table|nil
---@return boolean
function NodeMetaRef:from_table(value) end
---@param other NodeMetaRef
---@return boolean
function NodeMetaRef:equals(other) end

6
classes/ObjectRef.lua Normal file
View File

@@ -0,0 +1,6 @@
--- @class ObjectRef
ObjectRef = {}
--- @return Position
function ObjectRef:get_pos() end
--- @param pos Position
function ObjectRef:set_pos(pos) end

6
classes/Player.lua Normal file
View File

@@ -0,0 +1,6 @@
---@class Player : ObjectRef
Player = {}
---@return string
function Player:get_player_name() end
function Player:get_inventory() end

5
classes/VoxelArea.lua Normal file
View File

@@ -0,0 +1,5 @@
---@class VoxelArea
VoxelArea = {}
---@param cuboid { MinEdge: any, MaxEdge: any }
function VoxelArea:new(cuboid) end