From d95f51618c1dc97c03babdda07fe3899b7282f75 Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Fri, 20 Mar 2026 08:26:33 +0100 Subject: [PATCH] Adds a lua typedefinitions file --- .luarc.json | 28 +----- data/types/breakhack.d.lua | 172 +++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+), 26 deletions(-) create mode 100644 data/types/breakhack.d.lua diff --git a/.luarc.json b/.luarc.json index f31e903..8e1454c 100644 --- a/.luarc.json +++ b/.luarc.json @@ -1,27 +1,3 @@ { - "diagnostics.globals": [ - "map_random", - "map_randomseed", - "add_keybearers", - "set_current_room", - "map", - "CURRENT_LEVEL", - "QUICK_MODE", - "ARCADE_MODE", - "get_random_seed", - "info", - "PlayerData", - "create_map", - "add_chest", - "read_file", - "add_texture", - "create_shop_artifact", - "add_tile", - "add_decoration", - "set_modifier", - "add_wall", - "add_door", - "add_monster", - "add_trap" - ] -} \ No newline at end of file + "workspace.library": ["data/types"] +} diff --git a/data/types/breakhack.d.lua b/data/types/breakhack.d.lua new file mode 100644 index 0000000..5356fc1 --- /dev/null +++ b/data/types/breakhack.d.lua @@ -0,0 +1,172 @@ +---@meta + +---@class StatsData +---@field hp integer +---@field dmg integer +---@field atk integer +---@field def integer +---@field speed integer + +---@class TileData +---@field textureIndex0 integer -- -1 = no texture +---@field textureIndex1 integer -- -1 = no texture +---@field tileClipX integer +---@field tileClipY integer +---@field isCollider boolean +---@field isLightSource boolean +---@field isLevelExit boolean +---@field isLethal boolean +---@field lockType integer -- 0=none, 1=gold, 2=silver + +---@class TrapData +---@field texturePath1 string +---@field texturePath2 string +---@field clipX integer +---@field clipY integer +---@field damage integer + +---@class ChestData +---@field texturePath1 string +---@field texturePath2 string +---@field clipX integer +---@field clipY integer + +---@class MonsterData +---@field label string +---@field texturePath1 string +---@field texturePath2 string +---@field stats StatsData +---@field clipX integer +---@field clipY integer +---@field behaviour integer +---@field boss boolean + +---@class PlayerDataTable +---@field shopOwnerKiller boolean +---@field level integer + +---@alias Map userdata -- opaque C lightuserdata + +---@alias RoomModifier "WINDY"|"FIRE"|"CRUMBLING" +---@alias Direction "LEFT"|"RIGHT"|"UP"|"DOWN" + +---@type Map +map = nil + +---@type integer +CURRENT_LEVEL = nil + +---@type boolean +QUICK_MODE = nil + +---@type boolean +ARCADE_MODE = nil + +---@type PlayerDataTable +PlayerData = nil + +--- Create a new map for the given dungeon level. +---@param level integer +---@return Map +function create_map(level) end + +--- Print an info message to the game log. +---@param msg string +function info(msg) end + +--- Add a floor tile to the map. +---@param m Map +---@param x integer +---@param y integer +---@param tile TileData +function add_tile(m, x, y, tile) end + +--- Add a wall tile to the map. +---@param m Map +---@param x integer +---@param y integer +---@param tile TileData +function add_wall(m, x, y, tile) end + +--- Add a door tile to the map. +---@param m Map +---@param x integer +---@param y integer +---@param tile TileData +function add_door(m, x, y, tile) end + +--- Add a decoration tile to the map. +---@param m Map +---@param x integer +---@param y integer +---@param tile TileData +function add_decoration(m, x, y, tile) end + +--- Add a trap to the map. +---@param m Map +---@param x integer +---@param y integer +---@param trap TrapData +function add_trap(m, x, y, trap) end + +--- Add a chest to the map. +---@param m Map +---@param x integer +---@param y integer +---@param level integer +---@param chest ChestData +function add_chest(m, x, y, level, chest) end + +--- Load a texture and return its index for use in TileData fields. +---@param m Map +---@param path string +---@return integer +function add_texture(m, path) end + +--- Read the contents of a file relative to the data directory. +---@param filename string +---@return string +function read_file(filename) end + +--- Set the current room origin for subsequent monster/object placement. +---@param m Map +---@param x integer +---@param y integer +function set_current_room(m, x, y) end + +--- Apply a modifier to the current room. +---@param m Map +---@param modifier RoomModifier +---@param direction Direction +function set_modifier(m, modifier, direction) end + +--- Add a monster to the map. +---@param m Map +---@param x integer +---@param y integer +---@param monster MonsterData +function add_monster(m, x, y, monster) end + +--- Assign a key to a random monster already on the map. +---@param m Map +function add_keybearers(m) end + +--- Get the seeded random value for this dungeon level (used to seed math.random). +---@param level integer +---@return number +function get_random_seed(level) end + +--- Seed the map's internal PRNG. +---@param seed integer +function map_randomseed(seed) end + +--- Return a random integer in the range [1, max]. +---@param max integer +---@return integer +function map_random(max) end + +--- Place a shop artifact at the given position. +---@param m Map +---@param x integer +---@param y integer +function create_shop_artifact(m, x, y) end