changeset 6580 | 6155187bf599 |
parent 6578 | d4ad42283125 |
child 6700 | e04da46ee43c |
6579:fc52f7c22c9b | 6580:6155187bf599 |
---|---|
110 if lua_gettop(L) <> 2 then |
110 if lua_gettop(L) <> 2 then |
111 begin |
111 begin |
112 LuaError('Lua: Wrong number of parameters passed to band!'); |
112 LuaError('Lua: Wrong number of parameters passed to band!'); |
113 lua_pushnil(L); |
113 lua_pushnil(L); |
114 end |
114 end |
115 else lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)); |
115 else |
116 lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)); |
|
116 lc_band := 1; |
117 lc_band := 1; |
117 end; |
118 end; |
118 |
119 |
119 function lc_bor(L: PLua_State): LongInt; Cdecl; |
120 function lc_bor(L: PLua_State): LongInt; Cdecl; |
120 begin |
121 begin |
121 if lua_gettop(L) <> 2 then |
122 if lua_gettop(L) <> 2 then |
122 begin |
123 begin |
123 LuaError('Lua: Wrong number of parameters passed to bor!'); |
124 LuaError('Lua: Wrong number of parameters passed to bor!'); |
124 lua_pushnil(L); |
125 lua_pushnil(L); |
125 end |
126 end |
126 else lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)); |
127 else |
128 lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)); |
|
127 lc_bor := 1; |
129 lc_bor := 1; |
128 end; |
130 end; |
129 |
131 |
130 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
132 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
131 begin |
133 begin |
132 if lua_gettop(L) <> 1 then |
134 if lua_gettop(L) <> 1 then |
133 begin |
135 begin |
134 LuaError('Lua: Wrong number of parameters passed to bnot!'); |
136 LuaError('Lua: Wrong number of parameters passed to bnot!'); |
135 lua_pushnil(L); |
137 lua_pushnil(L); |
136 end |
138 end |
137 else lua_pushinteger(L, not lua_tointeger(L, 1)); |
139 else |
140 lua_pushinteger(L, not lua_tointeger(L, 1)); |
|
138 lc_bnot := 1; |
141 lc_bnot := 1; |
139 end; |
142 end; |
140 |
143 |
141 function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
144 function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
142 begin |
145 begin |
143 if lua_gettop(L) <> 0 then |
146 if lua_gettop(L) <> 0 then |
144 LuaError('Lua: Wrong number of parameters passed to GetInputMask!') |
147 LuaError('Lua: Wrong number of parameters passed to GetInputMask!') |
145 else lua_pushinteger(L, InputMask); |
148 else |
149 lua_pushinteger(L, InputMask); |
|
146 lc_getinputmask:= 1 |
150 lc_getinputmask:= 1 |
147 end; |
151 end; |
148 |
152 |
149 function lc_setinputmask(L : Plua_State) : LongInt; Cdecl; |
153 function lc_setinputmask(L : Plua_State) : LongInt; Cdecl; |
150 begin |
154 begin |
151 if lua_gettop(L) <> 1 then |
155 if lua_gettop(L) <> 1 then |
152 LuaError('Lua: Wrong number of parameters passed to SetInputMask!') |
156 LuaError('Lua: Wrong number of parameters passed to SetInputMask!') |
153 else InputMask:= lua_tointeger(L, 1); |
157 else |
158 InputMask:= lua_tointeger(L, 1); |
|
154 lc_setinputmask:= 0 |
159 lc_setinputmask:= 0 |
155 end; |
160 end; |
156 |
161 |
157 function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
162 function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
158 begin |
163 begin |
230 end; |
235 end; |
231 |
236 |
232 function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; |
237 function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; |
233 var gear: PGear; |
238 var gear: PGear; |
234 begin |
239 begin |
235 if lua_gettop(L) <> 4 then begin |
240 if lua_gettop(L) <> 4 then |
241 begin |
|
236 LuaError('Lua: Wrong number of parameters passed to SpawnFakeHealthCrate!'); |
242 LuaError('Lua: Wrong number of parameters passed to SpawnFakeHealthCrate!'); |
237 lua_pushnil(L); |
243 lua_pushnil(L); |
238 end |
244 end |
239 else begin |
245 else |
246 begin |
|
240 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
247 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
241 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
248 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
242 lua_pushinteger(L, gear^.uid); |
249 lua_pushinteger(L, gear^.uid); |
243 end; |
250 end; |
244 lc_spawnfakehealthcrate := 1; |
251 lc_spawnfakehealthcrate := 1; |
245 end; |
252 end; |
246 |
253 |
247 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
254 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
248 var gear: PGear; |
255 var gear: PGear; |
249 begin |
256 begin |
250 if lua_gettop(L) <> 4 then begin |
257 if lua_gettop(L) <> 4 then |
258 begin |
|
251 LuaError('Lua: Wrong number of parameters passed to SpawnFakeAmmoCrate!'); |
259 LuaError('Lua: Wrong number of parameters passed to SpawnFakeAmmoCrate!'); |
252 lua_pushnil(L); |
260 lua_pushnil(L); |
253 end |
261 end |
254 else begin |
262 else |
263 begin |
|
255 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
264 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
256 AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
265 AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
257 lua_pushinteger(L, gear^.uid); |
266 lua_pushinteger(L, gear^.uid); |
258 end; |
267 end; |
259 lc_spawnfakeammocrate := 1; |
268 lc_spawnfakeammocrate := 1; |
260 end; |
269 end; |
261 |
270 |
262 function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; |
271 function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; |
263 var gear: PGear; |
272 var gear: PGear; |
264 begin |
273 begin |
265 if lua_gettop(L) <> 4 then begin |
274 if lua_gettop(L) <> 4 then |
275 begin |
|
266 LuaError('Lua: Wrong number of parameters passed to SpawnFakeUtilityCrate!'); |
276 LuaError('Lua: Wrong number of parameters passed to SpawnFakeUtilityCrate!'); |
267 lua_pushnil(L); |
277 lua_pushnil(L); |
268 end |
278 end |
269 else begin |
279 else |
280 begin |
|
270 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
281 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
271 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
282 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
272 lua_pushinteger(L, gear^.uid); |
283 lua_pushinteger(L, gear^.uid); |
273 end; |
284 end; |
274 lc_spawnfakeutilitycrate := 1; |
285 lc_spawnfakeutilitycrate := 1; |
275 end; |
286 end; |
276 |
287 |
277 function lc_spawnhealthcrate(L: Plua_State) : LongInt; Cdecl; |
288 function lc_spawnhealthcrate(L: Plua_State) : LongInt; Cdecl; |
278 var gear: PGear; |
289 var gear: PGear; |
279 var health: LongInt; |
290 var health: LongInt; |
280 begin |
291 begin |
281 if (lua_gettop(L) < 2) or (lua_gettop(L) > 3) then begin |
292 if (lua_gettop(L) < 2) or (lua_gettop(L) > 3) then |
293 begin |
|
282 LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!'); |
294 LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!'); |
283 lua_pushnil(L); |
295 lua_pushnil(L); |
284 end |
296 end |
285 else begin |
297 else |
286 if lua_gettop(L) = 3 then health:= lua_tointeger(L, 3) |
298 begin |
287 else health:= cHealthCaseAmount; |
299 if lua_gettop(L) = 3 then |
300 health:= lua_tointeger(L, 3) |
|
301 else |
|
302 health:= cHealthCaseAmount; |
|
288 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health); |
303 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health); |
289 if gear <> nil then lua_pushinteger(L, gear^.uid) |
304 if gear <> nil then |
290 else lua_pushnil(L); |
305 lua_pushinteger(L, gear^.uid) |
291 end; |
306 else |
307 lua_pushnil(L); |
|
308 end; |
|
292 lc_spawnhealthcrate := 1; |
309 lc_spawnhealthcrate := 1; |
293 end; |
310 end; |
294 |
311 |
295 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl; |
312 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl; |
296 var gear: PGear; |
313 var gear: PGear; |
297 begin |
314 begin |
298 if lua_gettop(L) <> 3 then begin |
315 if lua_gettop(L) <> 3 then |
316 begin |
|
299 LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!'); |
317 LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!'); |
300 lua_pushnil(L); |
318 lua_pushnil(L); |
301 end |
319 end |
302 else begin |
320 else |
321 begin |
|
303 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3)); |
322 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3)); |
304 if gear <> nil then lua_pushinteger(L, gear^.uid) |
323 if gear <> nil then |
305 else lua_pushnil(L); |
324 lua_pushinteger(L, gear^.uid) |
306 end; |
325 else |
326 lua_pushnil(L); |
|
327 end; |
|
307 lc_spawnammocrate := 1; |
328 lc_spawnammocrate := 1; |
308 end; |
329 end; |
309 |
330 |
310 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl; |
331 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl; |
311 var gear: PGear; |
332 var gear: PGear; |
312 begin |
333 begin |
313 if lua_gettop(L) <> 3 then begin |
334 if lua_gettop(L) <> 3 then |
335 begin |
|
314 LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!'); |
336 LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!'); |
315 lua_pushnil(L); |
337 lua_pushnil(L); |
316 end |
338 end |
317 else begin |
339 else |
340 begin |
|
318 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
341 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
319 UtilityCrate, lua_tointeger(L, 3)); |
342 UtilityCrate, lua_tointeger(L, 3)); |
320 if gear <> nil then lua_pushinteger(L, gear^.uid) |
343 if gear <> nil then |
321 else lua_pushnil(L); |
344 lua_pushinteger(L, gear^.uid) |
322 end; |
345 else |
346 lua_pushnil(L); |
|
347 end; |
|
323 lc_spawnutilitycrate := 1; |
348 lc_spawnutilitycrate := 1; |
324 end; |
349 end; |
325 |
350 |
326 function lc_addgear(L : Plua_State) : LongInt; Cdecl; |
351 function lc_addgear(L : Plua_State) : LongInt; Cdecl; |
327 var gear : PGear; |
352 var gear : PGear; |
359 LuaError('Lua: Wrong number of parameters passed to DeleteGear!'); |
384 LuaError('Lua: Wrong number of parameters passed to DeleteGear!'); |
360 end |
385 end |
361 else |
386 else |
362 begin |
387 begin |
363 gear:= GearByUID(lua_tointeger(L, 1)); |
388 gear:= GearByUID(lua_tointeger(L, 1)); |
364 if gear <> nil then DeleteGear(gear); |
389 if gear <> nil then |
390 DeleteGear(gear); |
|
365 end; |
391 end; |
366 lc_deletegear:= 0 |
392 lc_deletegear:= 0 |
367 end; |
393 end; |
368 |
394 |
369 function lc_addvisualgear(L : Plua_State) : LongInt; Cdecl; |
395 function lc_addvisualgear(L : Plua_State) : LongInt; Cdecl; |
389 if vg <> nil then |
415 if vg <> nil then |
390 begin |
416 begin |
391 lastVisualGearByUID:= vg; |
417 lastVisualGearByUID:= vg; |
392 lua_pushinteger(L, vg^.uid) |
418 lua_pushinteger(L, vg^.uid) |
393 end |
419 end |
394 else lua_pushinteger(L, 0) |
420 else |
421 lua_pushinteger(L, 0) |
|
395 end; |
422 end; |
396 lc_addvisualgear:= 1; // 1 return value |
423 lc_addvisualgear:= 1; // 1 return value |
397 end; |
424 end; |
398 |
425 |
399 function lc_deletevisualgear(L : Plua_State) : LongInt; Cdecl; |
426 function lc_deletevisualgear(L : Plua_State) : LongInt; Cdecl; |
404 LuaError('Lua: Wrong number of parameters passed to DeleteVisualGear!'); |
431 LuaError('Lua: Wrong number of parameters passed to DeleteVisualGear!'); |
405 end |
432 end |
406 else |
433 else |
407 begin |
434 begin |
408 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
435 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
409 if vg <> nil then DeleteVisualGear(vg); |
436 if vg <> nil then |
437 DeleteVisualGear(vg); |
|
410 end; |
438 end; |
411 lc_deletevisualgear:= 0 |
439 lc_deletevisualgear:= 0 |
412 end; |
440 end; |
413 |
441 |
414 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
442 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
462 vg^.Y:= lua_tointeger(L, 3); |
490 vg^.Y:= lua_tointeger(L, 3); |
463 vg^.dX:= lua_tonumber(L, 4); |
491 vg^.dX:= lua_tonumber(L, 4); |
464 vg^.dY:= lua_tonumber(L, 5); |
492 vg^.dY:= lua_tonumber(L, 5); |
465 vg^.Angle:= lua_tonumber(L, 6); |
493 vg^.Angle:= lua_tonumber(L, 6); |
466 vg^.Frame:= lua_tointeger(L, 7); |
494 vg^.Frame:= lua_tointeger(L, 7); |
467 if lua_tointeger(L, 8) <> 0 then vg^.FrameTicks:= lua_tointeger(L, 8); // find a better way to do this. maybe need to break all these up. |
495 if lua_tointeger(L, 8) <> 0 then |
496 vg^.FrameTicks:= lua_tointeger(L, 8); // find a better way to do this. maybe need to break all these up. |
|
468 vg^.State:= lua_tointeger(L, 9); |
497 vg^.State:= lua_tointeger(L, 9); |
469 vg^.Timer:= lua_tointeger(L, 10); |
498 vg^.Timer:= lua_tointeger(L, 10); |
470 vg^.Tint:= lua_tointeger(L, 11); |
499 vg^.Tint:= lua_tointeger(L, 11); |
471 end |
500 end |
472 end; |
501 end; |
595 function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
624 function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
596 var gear : PGear; |
625 var gear : PGear; |
597 begin |
626 begin |
598 if lua_gettop(L) <> 1 then |
627 if lua_gettop(L) <> 1 then |
599 LuaError('Lua: Wrong number of parameters passed to GetHogLevel!') |
628 LuaError('Lua: Wrong number of parameters passed to GetHogLevel!') |
600 else begin |
629 else |
630 begin |
|
601 gear := GearByUID(lua_tointeger(L, 1)); |
631 gear := GearByUID(lua_tointeger(L, 1)); |
602 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
632 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
603 lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
633 lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
604 else |
634 else |
605 lua_pushnil(L); |
635 lua_pushnil(L); |
757 else |
787 else |
758 begin |
788 begin |
759 gear:= GearByUID(lua_tointeger(L, 1)); |
789 gear:= GearByUID(lua_tointeger(L, 1)); |
760 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
790 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
761 |
791 |
762 hogName:= lua_tostring(L, 2); |
792 hogName:= lua_tostring(L, 2); |
763 gear^.Hedgehog^.Name:= hogName; |
793 gear^.Hedgehog^.Name:= hogName; |
764 |
794 |
765 FreeTexture(gear^.Hedgehog^.NameTagTex); |
795 FreeTexture(gear^.Hedgehog^.NameTagTex); |
766 gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16); |
796 gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16); |
767 |
797 |
768 end; |
798 end; |
769 lc_sethogname:= 0; |
799 lc_sethogname:= 0; |
770 end; |
800 end; |
883 function lc_hogsay(L : Plua_State) : LongInt; Cdecl; |
913 function lc_hogsay(L : Plua_State) : LongInt; Cdecl; |
884 var gear : PGear; |
914 var gear : PGear; |
885 vgear : PVisualGear; |
915 vgear : PVisualGear; |
886 s : LongWord; |
916 s : LongWord; |
887 begin |
917 begin |
888 if lua_gettop(L) = 4 then s:= lua_tointeger(L, 4) |
918 if lua_gettop(L) = 4 then |
889 else s:= 0; |
919 s:= lua_tointeger(L, 4) |
920 else |
|
921 s:= 0; |
|
890 |
922 |
891 if (lua_gettop(L) = 4) or (lua_gettop(L) = 3) then |
923 if (lua_gettop(L) = 4) or (lua_gettop(L) = 3) then |
892 begin |
924 begin |
893 gear:= GearByUID(lua_tointeger(L, 1)); |
925 gear:= GearByUID(lua_tointeger(L, 1)); |
894 if gear <> nil then |
926 if gear <> nil then |
897 if vgear <> nil then |
929 if vgear <> nil then |
898 begin |
930 begin |
899 vgear^.Text:= lua_tostring(L, 2); |
931 vgear^.Text:= lua_tostring(L, 2); |
900 vgear^.Hedgehog:= gear^.Hedgehog; |
932 vgear^.Hedgehog:= gear^.Hedgehog; |
901 vgear^.FrameTicks:= lua_tointeger(L, 3); |
933 vgear^.FrameTicks:= lua_tointeger(L, 3); |
902 if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then vgear^.FrameTicks:= 1; |
934 if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then |
935 vgear^.FrameTicks:= 1; |
|
903 lua_pushinteger(L, vgear^.Uid) |
936 lua_pushinteger(L, vgear^.Uid) |
904 end |
937 end |
905 end |
938 end |
906 else lua_pushnil(L) |
939 else |
940 lua_pushnil(L) |
|
907 end |
941 end |
908 else LuaError('Lua: Wrong number of parameters passed to HogSay!'); |
942 else LuaError('Lua: Wrong number of parameters passed to HogSay!'); |
909 lc_hogsay:= 1 |
943 lc_hogsay:= 1 |
910 end; |
944 end; |
911 |
945 |
945 var gear : PGear; |
979 var gear : PGear; |
946 begin |
980 begin |
947 |
981 |
948 if lua_gettop(L) = 3 then |
982 if lua_gettop(L) = 3 then |
949 begin |
983 begin |
950 gear:= GearByUID(lua_tointeger(L, 1)); |
984 gear:= GearByUID(lua_tointeger(L, 1)); |
951 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
985 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
952 AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) ); |
986 AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) ); |
953 end else |
987 end else |
954 |
988 |
955 if lua_gettop(L) = 2 then |
989 if lua_gettop(L) = 2 then |
956 begin |
990 begin |
957 gear:= GearByUID(lua_tointeger(L, 1)); |
991 gear:= GearByUID(lua_tointeger(L, 1)); |
958 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
992 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
959 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
993 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
960 end else |
994 end else |
961 begin |
995 begin |
962 LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
996 LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
963 end; |
997 end; |
964 |
998 |
965 lc_addammo:= 0; |
999 lc_addammo:= 0; |
966 |
1000 |
967 end;} |
1001 end;} |
971 begin |
1005 begin |
972 if (lua_gettop(L) = 3) or (lua_gettop(L) = 2) then |
1006 if (lua_gettop(L) = 3) or (lua_gettop(L) = 2) then |
973 begin |
1007 begin |
974 gear:= GearByUID(lua_tointeger(L, 1)); |
1008 gear:= GearByUID(lua_tointeger(L, 1)); |
975 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1009 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
976 if lua_gettop(L) = 2 then AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))) |
1010 if lua_gettop(L) = 2 then |
977 else AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3)) |
1011 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))) |
1012 else |
|
1013 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3)) |
|
978 end |
1014 end |
979 else LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
1015 else LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
980 lc_addammo:= 0 |
1016 lc_addammo:= 0 |
981 end; |
1017 end; |
982 |
1018 |
988 begin |
1024 begin |
989 gear:= GearByUID(lua_tointeger(L, 1)); |
1025 gear:= GearByUID(lua_tointeger(L, 1)); |
990 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1026 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
991 begin |
1027 begin |
992 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
1028 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
993 if ammo^.AmmoType = amNothing then lua_pushinteger(L, 0) |
1029 if ammo^.AmmoType = amNothing then |
994 else lua_pushinteger(L, ammo^.Count) |
1030 lua_pushinteger(L, 0) |
1031 else |
|
1032 lua_pushinteger(L, ammo^.Count) |
|
995 end |
1033 end |
996 else lua_pushinteger(L, 0) |
1034 else lua_pushinteger(L, 0) |
997 end |
1035 end |
998 else |
1036 else |
999 begin |
1037 begin |
1015 gear:= GearByUID(lua_tointeger(L, 1)); |
1053 gear:= GearByUID(lua_tointeger(L, 1)); |
1016 if gear <> nil then |
1054 if gear <> nil then |
1017 begin |
1055 begin |
1018 gear^.Health:= lua_tointeger(L, 2); |
1056 gear^.Health:= lua_tointeger(L, 2); |
1019 |
1057 |
1020 if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1058 if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1021 begin |
1059 begin |
1022 RenderHealth(gear^.Hedgehog^); |
1060 RenderHealth(gear^.Hedgehog^); |
1023 end; |
1061 end; |
1024 |
1062 |
1025 SetAllToActive; |
1063 SetAllToActive; |
1026 end |
1064 end |
1027 end; |
1065 end; |
1149 begin |
1187 begin |
1150 gear:= GearByUID(lua_tointeger(L, 1)); |
1188 gear:= GearByUID(lua_tointeger(L, 1)); |
1151 fall:= lua_toboolean(L, 2); |
1189 fall:= lua_toboolean(L, 2); |
1152 left:= lua_tointeger(L, 3); |
1190 left:= lua_tointeger(L, 3); |
1153 right:= lua_tointeger(L, 4); |
1191 right:= lua_tointeger(L, 4); |
1154 if lua_gettop(L) = 5 then tryhard:= lua_toboolean(L, 5); |
1192 if lua_gettop(L) = 5 then |
1193 tryhard:= lua_toboolean(L, 5); |
|
1155 if gear <> nil then |
1194 if gear <> nil then |
1156 FindPlace(gear, fall, left, right, tryhard); |
1195 FindPlace(gear, fall, left, right, tryhard); |
1157 if gear <> nil then lua_pushinteger(L, gear^.uid) |
1196 if gear <> nil then |
1158 else lua_pushnil(L); |
1197 lua_pushinteger(L, gear^.uid) |
1198 else |
|
1199 lua_pushnil(L); |
|
1159 end; |
1200 end; |
1160 lc_findplace:= 1 |
1201 lc_findplace:= 1 |
1161 end; |
1202 end; |
1162 |
1203 |
1163 function lc_playsound(L : Plua_State) : LongInt; Cdecl; |
1204 function lc_playsound(L : Plua_State) : LongInt; Cdecl; |
1271 if gear <> nil then |
1312 if gear <> nil then |
1272 begin |
1313 begin |
1273 col:= gear^.CollisionIndex >= 0; |
1314 col:= gear^.CollisionIndex >= 0; |
1274 x:= lua_tointeger(L, 2); |
1315 x:= lua_tointeger(L, 2); |
1275 y:= lua_tointeger(L, 3); |
1316 y:= lua_tointeger(L, 3); |
1276 if col then DeleteCI(gear); |
1317 if col then |
1318 DeleteCI(gear); |
|
1277 gear^.X:= int2hwfloat(x); |
1319 gear^.X:= int2hwfloat(x); |
1278 gear^.Y:= int2hwfloat(y); |
1320 gear^.Y:= int2hwfloat(y); |
1279 if col then AddGearCI(gear); |
1321 if col then |
1322 AddGearCI(gear); |
|
1280 SetAllToActive |
1323 SetAllToActive |
1281 end |
1324 end |
1282 end; |
1325 end; |
1283 lc_setgearposition:= 0 |
1326 lc_setgearposition:= 0 |
1284 end; |
1327 end; |
1370 if lua_gettop(L) <> 1 then |
1413 if lua_gettop(L) <> 1 then |
1371 LuaError('Lua: Wrong number of parameters passed to SetZoom!') |
1414 LuaError('Lua: Wrong number of parameters passed to SetZoom!') |
1372 else |
1415 else |
1373 begin |
1416 begin |
1374 ZoomValue:= lua_tonumber(L, 1); |
1417 ZoomValue:= lua_tonumber(L, 1); |
1375 if ZoomValue < cMaxZoomLevel then ZoomValue:= cMaxZoomLevel; |
1418 if ZoomValue < cMaxZoomLevel then |
1376 if ZoomValue > cMinZoomLevel then ZoomValue:= cMinZoomLevel; |
1419 ZoomValue:= cMaxZoomLevel; |
1420 if ZoomValue > cMinZoomLevel then |
|
1421 ZoomValue:= cMinZoomLevel; |
|
1377 end; |
1422 end; |
1378 lc_setzoom:= 0 |
1423 lc_setzoom:= 0 |
1379 end; |
1424 end; |
1380 |
1425 |
1381 function lc_getzoom(L : Plua_State) : LongInt; Cdecl; |
1426 function lc_getzoom(L : Plua_State) : LongInt; Cdecl; |
1605 WriteLnToConsole('Lua: ' + inttostr(i) + ': false'); |
1650 WriteLnToConsole('Lua: ' + inttostr(i) + ': false'); |
1606 end; |
1651 end; |
1607 |
1652 |
1608 procedure ScriptClearStack; |
1653 procedure ScriptClearStack; |
1609 begin |
1654 begin |
1610 lua_settop(luaState, 0) |
1655 lua_settop(luaState, 0) |
1611 end; |
1656 end; |
1612 |
1657 |
1613 procedure ScriptSetNil(name : shortstring); |
1658 procedure ScriptSetNil(name : shortstring); |
1614 begin |
1659 begin |
1615 lua_pushnil(luaState); |
1660 lua_pushnil(luaState); |
1616 lua_setglobal(luaState, Str2PChar(name)); |
1661 lua_setglobal(luaState, Str2PChar(name)); |
1617 end; |
1662 end; |
1618 |
1663 |
1619 procedure ScriptSetInteger(name : shortstring; value : LongInt); |
1664 procedure ScriptSetInteger(name : shortstring; value : LongInt); |
1620 begin |
1665 begin |
1621 lua_pushinteger(luaState, value); |
1666 lua_pushinteger(luaState, value); |
1622 lua_setglobal(luaState, Str2PChar(name)); |
1667 lua_setglobal(luaState, Str2PChar(name)); |
1623 end; |
1668 end; |
1624 |
1669 |
1625 procedure ScriptSetString(name : shortstring; value : shortstring); |
1670 procedure ScriptSetString(name : shortstring; value : shortstring); |
1626 begin |
1671 begin |
1627 lua_pushstring(luaState, Str2PChar(value)); |
1672 lua_pushstring(luaState, Str2PChar(value)); |
1628 lua_setglobal(luaState, Str2PChar(name)); |
1673 lua_setglobal(luaState, Str2PChar(name)); |
1629 end; |
1674 end; |
1630 |
1675 |
1631 function ScriptGetInteger(name : shortstring) : LongInt; |
1676 function ScriptGetInteger(name : shortstring) : LongInt; |
1632 begin |
1677 begin |
1633 lua_getglobal(luaState, Str2PChar(name)); |
1678 lua_getglobal(luaState, Str2PChar(name)); |
1634 ScriptGetInteger:= lua_tointeger(luaState, -1); |
1679 ScriptGetInteger:= lua_tointeger(luaState, -1); |
1635 lua_pop(luaState, 1); |
1680 lua_pop(luaState, 1); |
1636 end; |
1681 end; |
1637 |
1682 |
1638 function ScriptGetString(name : shortstring) : shortstring; |
1683 function ScriptGetString(name : shortstring) : shortstring; |
1639 begin |
1684 begin |
1640 lua_getglobal(luaState, Str2PChar(name)); |
1685 lua_getglobal(luaState, Str2PChar(name)); |
1641 ScriptGetString:= lua_tostring(luaState, -1); |
1686 ScriptGetString:= lua_tostring(luaState, -1); |
1642 lua_pop(luaState, 1); |
1687 lua_pop(luaState, 1); |
1643 end; |
1688 end; |
1644 |
1689 |
1645 procedure ScriptOnGameInit; |
1690 procedure ScriptOnGameInit; |
1646 var i, j, k: LongInt; |
1691 var i, j, k: LongInt; |
1647 begin |
1692 begin |
1752 procedure ScriptLoad(name : shortstring); |
1797 procedure ScriptLoad(name : shortstring); |
1753 var ret : LongInt; |
1798 var ret : LongInt; |
1754 s : shortstring; |
1799 s : shortstring; |
1755 begin |
1800 begin |
1756 s:= UserPathz[ptData] + '/' + name; |
1801 s:= UserPathz[ptData] + '/' + name; |
1757 if not FileExists(s) then s:= Pathz[ptData] + '/' + name; |
1802 if not FileExists(s) then |
1758 if not FileExists(s) then exit; |
1803 s:= Pathz[ptData] + '/' + name; |
1804 if not FileExists(s) then |
|
1805 exit; |
|
1759 |
1806 |
1760 ret:= luaL_loadfile(luaState, Str2PChar(s)); |
1807 ret:= luaL_loadfile(luaState, Str2PChar(s)); |
1761 if ret <> 0 then |
1808 if ret <> 0 then |
1762 begin |
1809 begin |
1763 LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |
1810 LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |
1805 end; |
1852 end; |
1806 |
1853 |
1807 function ParseCommandOverride(key, value : shortstring) : shortstring; |
1854 function ParseCommandOverride(key, value : shortstring) : shortstring; |
1808 begin |
1855 begin |
1809 ParseCommandOverride:= value; |
1856 ParseCommandOverride:= value; |
1810 if not ScriptExists('ParseCommandOverride') then exit; |
1857 if not ScriptExists('ParseCommandOverride') then |
1858 exit; |
|
1811 lua_getglobal(luaState, Str2PChar('ParseCommandOverride')); |
1859 lua_getglobal(luaState, Str2PChar('ParseCommandOverride')); |
1812 lua_pushstring(luaState, Str2PChar(key)); |
1860 lua_pushstring(luaState, Str2PChar(key)); |
1813 lua_pushstring(luaState, Str2PChar(value)); |
1861 lua_pushstring(luaState, Str2PChar(value)); |
1814 if lua_pcall(luaState, 2, 1, 0) <> 0 then |
1862 if lua_pcall(luaState, 2, 1, 0) <> 0 then |
1815 begin |
1863 begin |