Skip to content

Commit c05b0f5

Browse files
authored
Adds a lua typedefinitions file (#163)
1 parent 41cb02b commit c05b0f5

File tree

2 files changed

+174
-26
lines changed

2 files changed

+174
-26
lines changed

.luarc.json

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
11
{
2-
"diagnostics.globals": [
3-
"map_random",
4-
"map_randomseed",
5-
"add_keybearers",
6-
"set_current_room",
7-
"map",
8-
"CURRENT_LEVEL",
9-
"QUICK_MODE",
10-
"ARCADE_MODE",
11-
"get_random_seed",
12-
"info",
13-
"PlayerData",
14-
"create_map",
15-
"add_chest",
16-
"read_file",
17-
"add_texture",
18-
"create_shop_artifact",
19-
"add_tile",
20-
"add_decoration",
21-
"set_modifier",
22-
"add_wall",
23-
"add_door",
24-
"add_monster",
25-
"add_trap"
26-
]
27-
}
2+
"workspace.library": ["data/types"]
3+
}

data/types/breakhack.d.lua

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---@meta
2+
3+
---@class StatsData
4+
---@field hp integer
5+
---@field dmg integer
6+
---@field atk integer
7+
---@field def integer
8+
---@field speed integer
9+
10+
---@class TileData
11+
---@field textureIndex0 integer -- -1 = no texture
12+
---@field textureIndex1 integer -- -1 = no texture
13+
---@field tileClipX integer
14+
---@field tileClipY integer
15+
---@field isCollider boolean
16+
---@field isLightSource boolean
17+
---@field isLevelExit boolean
18+
---@field isLethal boolean
19+
---@field lockType integer -- 0=none, 1=gold, 2=silver
20+
21+
---@class TrapData
22+
---@field texturePath1 string
23+
---@field texturePath2 string
24+
---@field clipX integer
25+
---@field clipY integer
26+
---@field damage integer
27+
28+
---@class ChestData
29+
---@field texturePath1 string
30+
---@field texturePath2 string
31+
---@field clipX integer
32+
---@field clipY integer
33+
34+
---@class MonsterData
35+
---@field label string
36+
---@field texturePath1 string
37+
---@field texturePath2 string
38+
---@field stats StatsData
39+
---@field clipX integer
40+
---@field clipY integer
41+
---@field behaviour integer
42+
---@field boss boolean
43+
44+
---@class PlayerDataTable
45+
---@field shopOwnerKiller boolean
46+
---@field level integer
47+
48+
---@alias Map userdata -- opaque C lightuserdata
49+
50+
---@alias RoomModifier "WINDY"|"FIRE"|"CRUMBLING"
51+
---@alias Direction "LEFT"|"RIGHT"|"UP"|"DOWN"
52+
53+
---@type Map
54+
map = nil
55+
56+
---@type integer
57+
CURRENT_LEVEL = nil
58+
59+
---@type boolean
60+
QUICK_MODE = nil
61+
62+
---@type boolean
63+
ARCADE_MODE = nil
64+
65+
---@type PlayerDataTable
66+
PlayerData = nil
67+
68+
--- Create a new map for the given dungeon level.
69+
---@param level integer
70+
---@return Map
71+
function create_map(level) end
72+
73+
--- Print an info message to the game log.
74+
---@param msg string
75+
function info(msg) end
76+
77+
--- Add a floor tile to the map.
78+
---@param m Map
79+
---@param x integer
80+
---@param y integer
81+
---@param tile TileData
82+
function add_tile(m, x, y, tile) end
83+
84+
--- Add a wall tile to the map.
85+
---@param m Map
86+
---@param x integer
87+
---@param y integer
88+
---@param tile TileData
89+
function add_wall(m, x, y, tile) end
90+
91+
--- Add a door tile to the map.
92+
---@param m Map
93+
---@param x integer
94+
---@param y integer
95+
---@param tile TileData
96+
function add_door(m, x, y, tile) end
97+
98+
--- Add a decoration tile to the map.
99+
---@param m Map
100+
---@param x integer
101+
---@param y integer
102+
---@param tile TileData
103+
function add_decoration(m, x, y, tile) end
104+
105+
--- Add a trap to the map.
106+
---@param m Map
107+
---@param x integer
108+
---@param y integer
109+
---@param trap TrapData
110+
function add_trap(m, x, y, trap) end
111+
112+
--- Add a chest to the map.
113+
---@param m Map
114+
---@param x integer
115+
---@param y integer
116+
---@param level integer
117+
---@param chest ChestData
118+
function add_chest(m, x, y, level, chest) end
119+
120+
--- Load a texture and return its index for use in TileData fields.
121+
---@param m Map
122+
---@param path string
123+
---@return integer
124+
function add_texture(m, path) end
125+
126+
--- Read the contents of a file relative to the data directory.
127+
---@param filename string
128+
---@return string
129+
function read_file(filename) end
130+
131+
--- Set the current room origin for subsequent monster/object placement.
132+
---@param m Map
133+
---@param x integer
134+
---@param y integer
135+
function set_current_room(m, x, y) end
136+
137+
--- Apply a modifier to the current room.
138+
---@param m Map
139+
---@param modifier RoomModifier
140+
---@param direction Direction
141+
function set_modifier(m, modifier, direction) end
142+
143+
--- Add a monster to the map.
144+
---@param m Map
145+
---@param x integer
146+
---@param y integer
147+
---@param monster MonsterData
148+
function add_monster(m, x, y, monster) end
149+
150+
--- Assign a key to a random monster already on the map.
151+
---@param m Map
152+
function add_keybearers(m) end
153+
154+
--- Get the seeded random value for this dungeon level (used to seed math.random).
155+
---@param level integer
156+
---@return number
157+
function get_random_seed(level) end
158+
159+
--- Seed the map's internal PRNG.
160+
---@param seed integer
161+
function map_randomseed(seed) end
162+
163+
--- Return a random integer in the range [1, max].
164+
---@param max integer
165+
---@return integer
166+
function map_random(max) end
167+
168+
--- Place a shop artifact at the given position.
169+
---@param m Map
170+
---@param x integer
171+
---@param y integer
172+
function create_shop_artifact(m, x, y) end

0 commit comments

Comments
 (0)