224 |
224 |
225 gear:= AddGear(x, y, gt, s, dx, dy, t); |
225 gear:= AddGear(x, y, gt, s, dx, dy, t); |
226 lua_pushnumber(L, gear^.uid) |
226 lua_pushnumber(L, gear^.uid) |
227 end; |
227 end; |
228 lc_addgear:= 1; // 1 return value |
228 lc_addgear:= 1; // 1 return value |
|
229 end; |
|
230 |
|
231 function lc_deletegear(L : Plua_State) : LongInt; Cdecl; |
|
232 var gear : PGear; |
|
233 begin |
|
234 if lua_gettop(L) <> 1 then |
|
235 begin |
|
236 LuaError('Lua: Wrong number of parameters passed to DeleteGear!'); |
|
237 end |
|
238 else |
|
239 begin |
|
240 gear:= GearByUID(lua_tointeger(L, 1)); |
|
241 if gear <> nil then DeleteGear(gear); |
|
242 end; |
|
243 lc_deletegear:= 0 |
|
244 end; |
|
245 |
|
246 function lc_addvisualgear(L : Plua_State) : LongInt; Cdecl; |
|
247 var vg : PVisualGear; |
|
248 x, y, s: LongInt; |
|
249 c: Boolean; |
|
250 vgt: TVisualGearType; |
|
251 begin |
|
252 if lua_gettop(L) <> 5 then |
|
253 begin |
|
254 LuaError('Lua: Wrong number of parameters passed to AddVisualGear!'); |
|
255 lua_pushnil(L); // return value on stack (nil) |
|
256 end |
|
257 else |
|
258 begin |
|
259 x:= lua_tointeger(L, 1); |
|
260 y:= lua_tointeger(L, 2); |
|
261 vgt:= TVisualGearType(lua_tointeger(L, 3)); |
|
262 s:= lua_tointeger(L, 4); |
|
263 c:= lua_toboolean(L, 5); |
|
264 |
|
265 vg:= AddVisualGear(x, y, vgt, s, c); |
|
266 lua_pushnumber(L, vg^.uid) |
|
267 end; |
|
268 lc_addvisualgear:= 1; // 1 return value |
|
269 end; |
|
270 |
|
271 function lc_deletevisualgear(L : Plua_State) : LongInt; Cdecl; |
|
272 var vg : PVisualGear; |
|
273 begin |
|
274 if lua_gettop(L) <> 1 then |
|
275 begin |
|
276 LuaError('Lua: Wrong number of parameters passed to DeleteVisualGear!'); |
|
277 end |
|
278 else |
|
279 begin |
|
280 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
|
281 if vg <> nil then DeleteVisualGear(vg); |
|
282 end; |
|
283 lc_deletevisualgear:= 0 |
|
284 end; |
|
285 |
|
286 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
|
287 var vg: PVisualGear; |
|
288 begin |
|
289 if lua_gettop(L) <> 1 then |
|
290 begin |
|
291 LuaError('Lua: Wrong number of parameters passed to GetVisualGearValues!'); |
|
292 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
|
293 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L) |
|
294 end |
|
295 else |
|
296 begin |
|
297 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
|
298 if vg <> nil then |
|
299 begin |
|
300 lua_pushinteger(L, round(vg^.X)); |
|
301 lua_pushinteger(L, round(vg^.Y)); |
|
302 lua_pushnumber(L, vg^.dX); |
|
303 lua_pushnumber(L, vg^.dY); |
|
304 lua_pushnumber(L, vg^.Angle); |
|
305 lua_pushinteger(L, vg^.Frame); |
|
306 lua_pushinteger(L, vg^.FrameTicks); |
|
307 lua_pushinteger(L, vg^.State); |
|
308 lua_pushinteger(L, vg^.Timer); |
|
309 lua_pushinteger(L, vg^.Tint); |
|
310 end |
|
311 end; |
|
312 lc_getvisualgearvalues:= 10; |
|
313 end; |
|
314 |
|
315 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
|
316 var vg : PVisualGear; |
|
317 begin |
|
318 if lua_gettop(L) <> 10 then |
|
319 begin |
|
320 LuaError('Lua: Wrong number of parameters passed to SetVisualGearValues!'); |
|
321 lua_pushnil(L); // return value on stack (nil) |
|
322 end |
|
323 else |
|
324 begin |
|
325 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
|
326 if vg <> nil then |
|
327 begin |
|
328 vg^.X:= lua_tointeger(L, 1); |
|
329 vg^.Y:= lua_tointeger(L, 2); |
|
330 vg^.dX:= lua_tonumber(L, 3); |
|
331 vg^.dY:= lua_tonumber(L, 4); |
|
332 vg^.Angle:= lua_tonumber(L, 5); |
|
333 vg^.Frame:= lua_tointeger(L, 6); |
|
334 vg^.FrameTicks:= lua_tointeger(L, 7); |
|
335 vg^.State:= lua_tointeger(L, 8); |
|
336 vg^.Timer:= lua_tointeger(L, 9); |
|
337 vg^.Tint:= lua_tointeger(L, 10); |
|
338 end |
|
339 end; |
|
340 lc_setvisualgearvalues:= 0; |
229 end; |
341 end; |
230 |
342 |
231 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
343 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
232 begin |
344 begin |
233 if lua_gettop(L) <> 0 then |
345 if lua_gettop(L) <> 0 then |
1184 for he:= Low(THogEffect) to High(THogEffect) do |
1296 for he:= Low(THogEffect) to High(THogEffect) do |
1185 ScriptSetInteger(EnumToStr(he), ord(he)); |
1297 ScriptSetInteger(EnumToStr(he), ord(he)); |
1186 |
1298 |
1187 // register functions |
1299 // register functions |
1188 lua_register(luaState, 'AddGear', @lc_addgear); |
1300 lua_register(luaState, 'AddGear', @lc_addgear); |
|
1301 lua_register(luaState, 'DeleteGear', @lc_deletegear); |
|
1302 lua_register(luaState, 'AddVisualGear', @lc_addvisualgear); |
|
1303 lua_register(luaState, 'DeleteVisualGear', @lc_deletevisualgear); |
|
1304 lua_register(luaState, 'GetVisualGearValues', @lc_getvisualgearvalues); |
|
1305 lua_register(luaState, 'SetVisualGearValues', @lc_setvisualgearvalues); |
1189 lua_register(luaState, 'SpawnHealthCrate', @lc_spawnhealthcrate); |
1306 lua_register(luaState, 'SpawnHealthCrate', @lc_spawnhealthcrate); |
1190 lua_register(luaState, 'SpawnAmmoCrate', @lc_spawnammocrate); |
1307 lua_register(luaState, 'SpawnAmmoCrate', @lc_spawnammocrate); |
1191 lua_register(luaState, 'SpawnUtilityCrate', @lc_spawnutilitycrate); |
1308 lua_register(luaState, 'SpawnUtilityCrate', @lc_spawnutilitycrate); |
1192 lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole); |
1309 lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole); |
1193 lua_register(luaState, 'GetGearType', @lc_getgeartype); |
1310 lua_register(luaState, 'GetGearType', @lc_getgeartype); |