changeset 9752 | 656c511ab0f3 |
parent 9751 | 7a6038c3faa2 |
child 9764 | 8dc9d268330f |
9751:7a6038c3faa2 | 9752:656c511ab0f3 |
---|---|
78 uDebug, |
78 uDebug, |
79 uCollisions, |
79 uCollisions, |
80 uRenderUtils, |
80 uRenderUtils, |
81 uTextures, |
81 uTextures, |
82 uLandGraphics, |
82 uLandGraphics, |
83 SysUtils, |
83 SysUtils, |
84 uIO, |
84 uIO, |
85 uVisualGearsList, |
85 uVisualGearsList, |
86 uGearsHandlersMess, |
86 uGearsHandlersMess, |
87 uPhysFSLayer, |
87 uPhysFSLayer, |
88 typinfo |
88 typinfo |
105 begin |
105 begin |
106 WriteLnToConsole(s); |
106 WriteLnToConsole(s); |
107 AddChatString(#5 + s); |
107 AddChatString(#5 + s); |
108 end; |
108 end; |
109 |
109 |
110 procedure LuaParameterCountError(call, paramsyntax: shortstring; wrongcount: LongInt); |
|
111 begin |
|
112 // TODO: i18n? |
|
113 LuaError('Lua: Wrong number of parameters (' + inttostr(wrongcount) + ') passed to ' + call + '! syntax: ' + call + ' ( ' + paramsyntax + ' )'); |
|
114 end; |
|
115 |
|
110 // wrapped calls // |
116 // wrapped calls // |
111 |
117 |
112 // functions called from Lua: |
118 // functions called from Lua: |
113 // function(L : Plua_State) : LongInt; Cdecl; |
119 // function(L : Plua_State) : LongInt; Cdecl; |
114 // where L contains the state, returns the number of return values on the stack |
120 // where L contains the state, returns the number of return values on the stack |
115 // call lua_gettop(L) to receive number of parameters passed |
121 // call lua_gettop(L) to receive number of parameters passed |
116 |
122 |
117 function lc_band(L: PLua_State): LongInt; Cdecl; |
123 function lc_band(L: PLua_State): LongInt; Cdecl; |
118 begin |
124 begin |
119 if lua_gettop(L) <> 2 then |
125 if lua_gettop(L) <> 2 then |
120 begin |
126 begin |
121 LuaError('Lua: Wrong number of parameters passed to band!'); |
127 LuaParameterCountError('band', 'value1, value2', lua_gettop(L)); |
122 lua_pushnil(L); |
128 lua_pushnil(L); |
123 end |
129 end |
124 else |
130 else |
125 lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)); |
131 lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)); |
126 lc_band := 1; |
132 lc_band := 1; |
127 end; |
133 end; |
128 |
134 |
129 function lc_bor(L: PLua_State): LongInt; Cdecl; |
135 function lc_bor(L: PLua_State): LongInt; Cdecl; |
130 begin |
136 begin |
131 if lua_gettop(L) <> 2 then |
137 if lua_gettop(L) <> 2 then |
132 begin |
138 begin |
133 LuaError('Lua: Wrong number of parameters passed to bor!'); |
139 LuaParameterCountError('bor', 'value1, value2', lua_gettop(L)); |
134 lua_pushnil(L); |
140 lua_pushnil(L); |
135 end |
141 end |
136 else |
142 else |
137 lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)); |
143 lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)); |
138 lc_bor := 1; |
144 lc_bor := 1; |
139 end; |
145 end; |
140 |
146 |
141 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
147 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
142 begin |
148 begin |
143 if lua_gettop(L) <> 1 then |
149 if lua_gettop(L) <> 1 then |
144 begin |
150 begin |
145 LuaError('Lua: Wrong number of parameters passed to bnot!'); |
151 LuaParameterCountError('bnot', 'value', lua_gettop(L)); |
146 lua_pushnil(L); |
152 lua_pushnil(L); |
147 end |
153 end |
148 else |
154 else |
149 lua_pushinteger(L, not lua_tointeger(L, 1)); |
155 lua_pushinteger(L, not lua_tointeger(L, 1)); |
150 lc_bnot := 1; |
156 lc_bnot := 1; |
151 end; |
157 end; |
152 |
158 |
153 function lc_div(L: PLua_State): LongInt; Cdecl; |
159 function lc_div(L: PLua_State): LongInt; Cdecl; |
154 begin |
160 begin |
155 if lua_gettop(L) <> 2 then |
161 if lua_gettop(L) <> 2 then |
156 begin |
162 begin |
157 LuaError('Lua: Wrong number of parameters passed to div!'); |
163 LuaParameterCountError('div', 'dividend, divisor', lua_gettop(L)); |
158 lua_pushnil(L); |
164 lua_pushnil(L); |
159 end |
165 end |
160 else |
166 else |
161 lua_pushinteger(L, lua_tointeger(L, 1) div lua_tointeger(L, 2)); |
167 lua_pushinteger(L, lua_tointeger(L, 1) div lua_tointeger(L, 2)); |
162 lc_div := 1; |
168 lc_div := 1; |
163 end; |
169 end; |
164 |
170 |
165 function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
171 function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
166 begin |
172 begin |
167 if lua_gettop(L) <> 0 then |
173 if lua_gettop(L) <> 0 then |
168 LuaError('Lua: Wrong number of parameters passed to GetInputMask!') |
174 LuaParameterCountError('GetInputMask', '', lua_gettop(L)) |
169 else |
175 else |
170 lua_pushinteger(L, InputMask); |
176 lua_pushinteger(L, InputMask); |
171 lc_getinputmask:= 1 |
177 lc_getinputmask:= 1 |
172 end; |
178 end; |
173 |
179 |
174 function lc_setinputmask(L : Plua_State) : LongInt; Cdecl; |
180 function lc_setinputmask(L : Plua_State) : LongInt; Cdecl; |
175 begin |
181 begin |
176 if lua_gettop(L) <> 1 then |
182 if lua_gettop(L) <> 1 then |
177 LuaError('Lua: Wrong number of parameters passed to SetInputMask!') |
183 LuaParameterCountError('SetInputMask', 'mask', lua_gettop(L)) |
178 else |
184 else |
179 InputMask:= lua_tointeger(L, 1); |
185 InputMask:= lua_tointeger(L, 1); |
180 lc_setinputmask:= 0 |
186 lc_setinputmask:= 0 |
181 end; |
187 end; |
182 |
188 |
185 if lua_gettop(L) = 1 then |
191 if lua_gettop(L) = 1 then |
186 begin |
192 begin |
187 WriteLnToConsole('Lua: ' + lua_tostring(L ,1)); |
193 WriteLnToConsole('Lua: ' + lua_tostring(L ,1)); |
188 end |
194 end |
189 else |
195 else |
190 LuaError('Lua: Wrong number of parameters passed to WriteLnToConsole!'); |
196 LuaParameterCountError('WriteLnToConsole', 'string', lua_gettop(L)); |
191 lc_writelntoconsole:= 0; |
197 lc_writelntoconsole:= 0; |
192 end; |
198 end; |
193 |
199 |
194 function lc_parsecommand(L : Plua_State) : LongInt; Cdecl; |
200 function lc_parsecommand(L : Plua_State) : LongInt; Cdecl; |
195 var t: PChar; |
201 var t: PChar; |
205 |
211 |
206 ParseCommand(s, true, true); |
212 ParseCommand(s, true, true); |
207 |
213 |
208 end |
214 end |
209 else |
215 else |
210 LuaError('Lua: Wrong number of parameters passed to ParseCommand!'); |
216 LuaParameterCountError('ParseCommand', 'string', lua_gettop(L)); |
211 lc_parsecommand:= 0; |
217 lc_parsecommand:= 0; |
212 end; |
218 end; |
213 |
219 |
214 function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
220 function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
215 begin |
221 begin |
216 if lua_gettop(L) = 5 then |
222 if lua_gettop(L) = 5 then |
217 begin |
223 begin |
218 ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
224 ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
219 end |
225 end |
220 else |
226 else |
221 LuaError('Lua: Wrong number of parameters passed to ShowMission!'); |
227 LuaParameterCountError('ShowMission', 'caption, subcaption, text, icon, time', lua_gettop(L)); |
222 lc_showmission:= 0; |
228 lc_showmission:= 0; |
223 end; |
229 end; |
224 |
230 |
225 function lc_hidemission(L : Plua_State) : LongInt; Cdecl; |
231 function lc_hidemission(L : Plua_State) : LongInt; Cdecl; |
226 begin |
232 begin |
263 else if lua_gettop(L) = 3 then |
269 else if lua_gettop(L) = 3 then |
264 begin |
270 begin |
265 AddCaption(lua_tostring(L, 1), lua_tointeger(L, 2) shr 8, TCapGroup(lua_tointeger(L, 3))); |
271 AddCaption(lua_tostring(L, 1), lua_tointeger(L, 2) shr 8, TCapGroup(lua_tointeger(L, 3))); |
266 end |
272 end |
267 else |
273 else |
268 LuaError('Lua: Wrong number of parameters passed to AddCaption!'); |
274 LuaParameterCountError('AddCaption', 'text[, color, captiongroup]', lua_gettop(L)); |
269 lc_addcaption:= 0; |
275 lc_addcaption:= 0; |
270 end; |
276 end; |
271 |
277 |
272 function lc_campaignlock(L : Plua_State) : LongInt; Cdecl; |
278 function lc_campaignlock(L : Plua_State) : LongInt; Cdecl; |
273 begin |
279 begin |
274 if lua_gettop(L) = 1 then |
280 if lua_gettop(L) = 1 then |
275 begin |
281 begin |
276 // to be done |
282 // to be done |
277 end |
283 end |
278 else |
284 else |
279 LuaError('Lua: Wrong number of parameters passed to CampaignLock!'); |
285 LuaParameterCountError('CampaignLock', 'TODO', lua_gettop(L)); |
280 lc_campaignlock:= 0; |
286 lc_campaignlock:= 0; |
281 end; |
287 end; |
282 |
288 |
283 function lc_campaignunlock(L : Plua_State) : LongInt; Cdecl; |
289 function lc_campaignunlock(L : Plua_State) : LongInt; Cdecl; |
284 begin |
290 begin |
285 if lua_gettop(L) = 1 then |
291 if lua_gettop(L) = 1 then |
286 begin |
292 begin |
287 // to be done |
293 // to be done |
288 end |
294 end |
289 else |
295 else |
290 LuaError('Lua: Wrong number of parameters passed to CampaignUnlock!'); |
296 LuaParameterCountError('CampaignUnlock', 'TODO', lua_gettop(L)); |
291 lc_campaignunlock:= 0; |
297 lc_campaignunlock:= 0; |
292 end; |
298 end; |
293 |
299 |
294 function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; |
300 function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; |
295 var gear: PGear; |
301 var gear: PGear; |
296 begin |
302 begin |
297 if lua_gettop(L) <> 4 then |
303 if lua_gettop(L) <> 4 then |
298 begin |
304 begin |
299 LuaError('Lua: Wrong number of parameters passed to SpawnFakeHealthCrate!'); |
305 LuaParameterCountError('SpawnFakeHealthCrate', 'x, y, explode, poison', lua_gettop(L)); |
300 lua_pushnil(L); |
306 lua_pushnil(L); |
301 end |
307 end |
302 else |
308 else |
303 begin |
309 begin |
304 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
310 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
305 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
311 HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
306 lua_pushinteger(L, gear^.uid); |
312 lua_pushinteger(L, gear^.uid); |
307 end; |
313 end; |
308 lc_spawnfakehealthcrate := 1; |
314 lc_spawnfakehealthcrate := 1; |
309 end; |
315 end; |
310 |
316 |
311 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
317 function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
312 var gear: PGear; |
318 var gear: PGear; |
313 begin |
319 begin |
314 if lua_gettop(L) <> 4 then |
320 if lua_gettop(L) <> 4 then |
315 begin |
321 begin |
316 LuaError('Lua: Wrong number of parameters passed to SpawnFakeAmmoCrate!'); |
322 LuaParameterCountError('SpawnFakeAmmoCrate', 'x, y, explode, poison', lua_gettop(L)); |
317 lua_pushnil(L); |
323 lua_pushnil(L); |
318 end |
324 end |
319 else |
325 else |
320 begin |
326 begin |
321 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
327 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
328 function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; |
334 function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; |
329 var gear: PGear; |
335 var gear: PGear; |
330 begin |
336 begin |
331 if lua_gettop(L) <> 4 then |
337 if lua_gettop(L) <> 4 then |
332 begin |
338 begin |
333 LuaError('Lua: Wrong number of parameters passed to SpawnFakeUtilityCrate!'); |
339 LuaParameterCountError('SpawnFakeUtilityCrate', 'x, y, explode, poison', lua_gettop(L)); |
334 lua_pushnil(L); |
340 lua_pushnil(L); |
335 end |
341 end |
336 else |
342 else |
337 begin |
343 begin |
338 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
344 gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
339 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
345 UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
340 lua_pushinteger(L, gear^.uid); |
346 lua_pushinteger(L, gear^.uid); |
341 end; |
347 end; |
342 lc_spawnfakeutilitycrate := 1; |
348 lc_spawnfakeutilitycrate := 1; |
346 var gear: PGear; |
352 var gear: PGear; |
347 var health: LongInt; |
353 var health: LongInt; |
348 begin |
354 begin |
349 if (lua_gettop(L) < 2) or (lua_gettop(L) > 3) then |
355 if (lua_gettop(L) < 2) or (lua_gettop(L) > 3) then |
350 begin |
356 begin |
351 LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!'); |
357 LuaParameterCountError('SpawnHealthCrate', 'x, y[, health]', lua_gettop(L)); |
352 lua_pushnil(L); |
358 lua_pushnil(L); |
353 end |
359 end |
354 else |
360 else |
355 begin |
361 begin |
356 if lua_gettop(L) = 3 then |
362 if lua_gettop(L) = 3 then |
361 if gear <> nil then |
367 if gear <> nil then |
362 lua_pushinteger(L, gear^.uid) |
368 lua_pushinteger(L, gear^.uid) |
363 else |
369 else |
364 lua_pushnil(L); |
370 lua_pushnil(L); |
365 end; |
371 end; |
366 lc_spawnhealthcrate := 1; |
372 lc_spawnhealthcrate := 1; |
367 end; |
373 end; |
368 |
374 |
369 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl; |
375 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl; |
370 var gear: PGear; |
376 var gear: PGear; |
371 begin |
377 begin |
372 if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then |
378 if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then |
373 begin |
379 begin |
374 LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!'); |
380 LuaParameterCountError('SpawnAmmoCrate', 'x, y, content[, amount]', lua_gettop(L)); |
375 lua_pushnil(L); |
381 lua_pushnil(L); |
376 end |
382 end |
377 else |
383 else |
378 begin |
384 begin |
379 if (lua_gettop(L) = 3) then |
385 if (lua_gettop(L) = 3) then |
380 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0) |
386 gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0) |
381 else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
387 else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
382 if gear <> nil then |
388 if gear <> nil then |
383 lua_pushinteger(L, gear^.uid) |
389 lua_pushinteger(L, gear^.uid) |
384 else |
390 else |
390 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl; |
396 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl; |
391 var gear: PGear; |
397 var gear: PGear; |
392 begin |
398 begin |
393 if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then |
399 if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then |
394 begin |
400 begin |
395 LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!'); |
401 LuaParameterCountError('SpawnUtilityCrate', 'x, y, content[, amount]', lua_gettop(L)); |
396 lua_pushnil(L); |
402 lua_pushnil(L); |
397 end |
403 end |
398 else |
404 else |
399 begin |
405 begin |
400 if (lua_gettop(L) = 3) then |
406 if (lua_gettop(L) = 3) then |
414 dx, dy: hwFloat; |
420 dx, dy: hwFloat; |
415 gt: TGearType; |
421 gt: TGearType; |
416 begin |
422 begin |
417 if lua_gettop(L) <> 7 then |
423 if lua_gettop(L) <> 7 then |
418 begin |
424 begin |
419 LuaError('Lua: Wrong number of parameters passed to AddGear!'); |
425 LuaParameterCountError('AddGear', 'x, y, gearType, state, dx, dy, timer', lua_gettop(L)); |
420 lua_pushnil(L); // return value on stack (nil) |
426 lua_pushnil(L); // return value on stack (nil) |
421 end |
427 end |
422 else |
428 else |
423 begin |
429 begin |
424 x:= lua_tointeger(L, 1); |
430 x:= lua_tointeger(L, 1); |
439 function lc_deletegear(L : Plua_State) : LongInt; Cdecl; |
445 function lc_deletegear(L : Plua_State) : LongInt; Cdecl; |
440 var gear : PGear; |
446 var gear : PGear; |
441 begin |
447 begin |
442 if lua_gettop(L) <> 1 then |
448 if lua_gettop(L) <> 1 then |
443 begin |
449 begin |
444 LuaError('Lua: Wrong number of parameters passed to DeleteGear!'); |
450 LuaParameterCountError('DeleteGear', 'gearUid', lua_gettop(L)); |
445 end |
451 end |
446 else |
452 else |
447 begin |
453 begin |
448 gear:= GearByUID(lua_tointeger(L, 1)); |
454 gear:= GearByUID(lua_tointeger(L, 1)); |
449 if gear <> nil then |
455 if gear <> nil then |
458 c: Boolean; |
464 c: Boolean; |
459 vgt: TVisualGearType; |
465 vgt: TVisualGearType; |
460 begin |
466 begin |
461 if lua_gettop(L) <> 5 then |
467 if lua_gettop(L) <> 5 then |
462 begin |
468 begin |
463 LuaError('Lua: Wrong number of parameters passed to AddVisualGear!'); |
469 LuaParameterCountError('AddVisualGear', 'x, y, visualGearType, state, critical', lua_gettop(L)); |
464 lua_pushnil(L); // return value on stack (nil) |
470 lua_pushnil(L); // return value on stack (nil) |
465 end |
471 end |
466 else |
472 else |
467 begin |
473 begin |
468 x:= lua_tointeger(L, 1); |
474 x:= lua_tointeger(L, 1); |
470 vgt:= TVisualGearType(lua_tointeger(L, 3)); |
476 vgt:= TVisualGearType(lua_tointeger(L, 3)); |
471 s:= lua_tointeger(L, 4); |
477 s:= lua_tointeger(L, 4); |
472 c:= lua_toboolean(L, 5); |
478 c:= lua_toboolean(L, 5); |
473 |
479 |
474 vg:= AddVisualGear(x, y, vgt, s, c); |
480 vg:= AddVisualGear(x, y, vgt, s, c); |
475 if vg <> nil then |
481 if vg <> nil then |
476 begin |
482 begin |
477 lastVisualGearByUID:= vg; |
483 lastVisualGearByUID:= vg; |
478 lua_pushinteger(L, vg^.uid) |
484 lua_pushinteger(L, vg^.uid) |
479 end |
485 end |
480 else |
486 else |
486 function lc_deletevisualgear(L : Plua_State) : LongInt; Cdecl; |
492 function lc_deletevisualgear(L : Plua_State) : LongInt; Cdecl; |
487 var vg : PVisualGear; |
493 var vg : PVisualGear; |
488 begin |
494 begin |
489 if lua_gettop(L) <> 1 then |
495 if lua_gettop(L) <> 1 then |
490 begin |
496 begin |
491 LuaError('Lua: Wrong number of parameters passed to DeleteVisualGear!'); |
497 LuaParameterCountError('DeleteVisualGear', 'vgUid', lua_gettop(L)); |
492 end |
498 end |
493 else |
499 else |
494 begin |
500 begin |
495 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
501 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
496 if vg <> nil then |
502 if vg <> nil then |
502 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
508 function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
503 var vg: PVisualGear; |
509 var vg: PVisualGear; |
504 begin |
510 begin |
505 if lua_gettop(L) <> 1 then |
511 if lua_gettop(L) <> 1 then |
506 begin |
512 begin |
507 LuaError('Lua: Wrong number of parameters passed to GetVisualGearValues!'); |
513 LuaParameterCountError('GetVisualGearValues', 'vgUid', lua_gettop(L)); |
508 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
514 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
509 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L) |
515 lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L) |
510 end |
516 end |
511 else |
517 else |
512 begin |
518 begin |
536 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
542 function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
537 var vg : PVisualGear; |
543 var vg : PVisualGear; |
538 begin |
544 begin |
539 if lua_gettop(L) <> 11 then |
545 if lua_gettop(L) <> 11 then |
540 begin |
546 begin |
541 LuaError('Lua: Wrong number of parameters passed to SetVisualGearValues!'); |
547 LuaParameterCountError('SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint', lua_gettop(L)); |
542 lua_pushnil(L); // return value on stack (nil) |
548 lua_pushnil(L); // return value on stack (nil) |
543 end |
549 end |
544 else |
550 else |
545 begin |
551 begin |
546 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
552 vg:= VisualGearByUID(lua_tointeger(L, 1)); |
564 |
570 |
565 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
571 function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
566 begin |
572 begin |
567 if lua_gettop(L) <> 0 then |
573 if lua_gettop(L) <> 0 then |
568 begin |
574 begin |
569 LuaError('Lua: Wrong number of parameters passed to GetFollowGear!'); |
575 LuaParameterCountError('GetFollowGear', '', lua_gettop(L)); |
570 lua_pushnil(L); // return value on stack (nil) |
576 lua_pushnil(L); // return value on stack (nil) |
571 end |
577 end |
572 else |
578 else |
573 if FollowGear = nil then |
579 if FollowGear = nil then |
574 lua_pushnil(L) |
580 lua_pushnil(L) |
580 function lc_getgeartype(L : Plua_State) : LongInt; Cdecl; |
586 function lc_getgeartype(L : Plua_State) : LongInt; Cdecl; |
581 var gear : PGear; |
587 var gear : PGear; |
582 begin |
588 begin |
583 if lua_gettop(L) <> 1 then |
589 if lua_gettop(L) <> 1 then |
584 begin |
590 begin |
585 LuaError('Lua: Wrong number of parameters passed to GetGearType!'); |
591 LuaParameterCountError('GetGearType', 'gearUid', lua_gettop(L)); |
586 lua_pushnil(L); // return value on stack (nil) |
592 lua_pushnil(L); // return value on stack (nil) |
587 end |
593 end |
588 else |
594 else |
589 begin |
595 begin |
590 gear:= GearByUID(lua_tointeger(L, 1)); |
596 gear:= GearByUID(lua_tointeger(L, 1)); |
599 function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl; |
605 function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl; |
600 var gear : PGear; |
606 var gear : PGear; |
601 begin |
607 begin |
602 if lua_gettop(L) <> 1 then |
608 if lua_gettop(L) <> 1 then |
603 begin |
609 begin |
604 LuaError('Lua: Wrong number of parameters passed to GetGearMessage!'); |
610 LuaParameterCountError('GetGearMessage', 'gearUid', lua_gettop(L)); |
605 lua_pushnil(L); // return value on stack (nil) |
611 lua_pushnil(L); // return value on stack (nil) |
606 end |
612 end |
607 else |
613 else |
608 begin |
614 begin |
609 gear:= GearByUID(lua_tointeger(L, 1)); |
615 gear:= GearByUID(lua_tointeger(L, 1)); |
618 function lc_getgearelasticity(L : Plua_State) : LongInt; Cdecl; |
624 function lc_getgearelasticity(L : Plua_State) : LongInt; Cdecl; |
619 var gear : PGear; |
625 var gear : PGear; |
620 begin |
626 begin |
621 if lua_gettop(L) <> 1 then |
627 if lua_gettop(L) <> 1 then |
622 begin |
628 begin |
623 LuaError('Lua: Wrong number of parameters passed to GetGearElasticity!'); |
629 LuaParameterCountError('GetGearElasticity', 'gearUid', lua_gettop(L)); |
624 lua_pushnil(L); // return value on stack (nil) |
630 lua_pushnil(L); // return value on stack (nil) |
625 end |
631 end |
626 else |
632 else |
627 begin |
633 begin |
628 gear:= GearByUID(lua_tointeger(L, 1)); |
634 gear:= GearByUID(lua_tointeger(L, 1)); |
636 |
642 |
637 function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
643 function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
638 var gear : PGear; |
644 var gear : PGear; |
639 begin |
645 begin |
640 if lua_gettop(L) <> 2 then |
646 if lua_gettop(L) <> 2 then |
641 LuaError('Lua: Wrong number of parameters passed to SetGearMessage!') |
647 LuaParameterCountError('SetGearMessage', 'gearUid, message', lua_gettop(L)) |
642 else |
648 else |
643 begin |
649 begin |
644 gear:= GearByUID(lua_tointeger(L, 1)); |
650 gear:= GearByUID(lua_tointeger(L, 1)); |
645 if gear <> nil then |
651 if gear <> nil then |
646 gear^.message:= lua_tointeger(L, 2); |
652 gear^.message:= lua_tointeger(L, 2); |
651 function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
657 function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
652 var gear : PGear; |
658 var gear : PGear; |
653 begin |
659 begin |
654 if lua_gettop(L) <> 1 then |
660 if lua_gettop(L) <> 1 then |
655 begin |
661 begin |
656 LuaError('Lua: Wrong number of parameters passed to GetGearPos!'); |
662 LuaParameterCountError('GetGearPos', 'gearUid', lua_gettop(L)); |
657 lua_pushnil(L); // return value on stack (nil) |
663 lua_pushnil(L); // return value on stack (nil) |
658 end |
664 end |
659 else |
665 else |
660 begin |
666 begin |
661 gear:= GearByUID(lua_tointeger(L, 1)); |
667 gear:= GearByUID(lua_tointeger(L, 1)); |
669 |
675 |
670 function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
676 function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
671 var gear : PGear; |
677 var gear : PGear; |
672 begin |
678 begin |
673 if lua_gettop(L) <> 2 then |
679 if lua_gettop(L) <> 2 then |
674 LuaError('Lua: Wrong number of parameters passed to SetGearPos!') |
680 LuaParameterCountError('SetGearPos', 'gearUid, value', lua_gettop(L)) |
675 else |
681 else |
676 begin |
682 begin |
677 gear:= GearByUID(lua_tointeger(L, 1)); |
683 gear:= GearByUID(lua_tointeger(L, 1)); |
678 if gear <> nil then |
684 if gear <> nil then |
679 gear^.Pos:= lua_tointeger(L, 2); |
685 gear^.Pos:= lua_tointeger(L, 2); |
684 function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
690 function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
685 var gear : PGear; |
691 var gear : PGear; |
686 begin |
692 begin |
687 if lua_gettop(L) <> 1 then |
693 if lua_gettop(L) <> 1 then |
688 begin |
694 begin |
689 LuaError('Lua: Wrong number of parameters passed to GetGearCollisionMask!'); |
695 LuaParameterCountError('GetGearCollisionMask', 'gearUid', lua_gettop(L)); |
690 lua_pushnil(L); // return value on stack (nil) |
696 lua_pushnil(L); // return value on stack (nil) |
691 end |
697 end |
692 else |
698 else |
693 begin |
699 begin |
694 gear:= GearByUID(lua_tointeger(L, 1)); |
700 gear:= GearByUID(lua_tointeger(L, 1)); |
702 |
708 |
703 function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
709 function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
704 var gear : PGear; |
710 var gear : PGear; |
705 begin |
711 begin |
706 if lua_gettop(L) <> 2 then |
712 if lua_gettop(L) <> 2 then |
707 LuaError('Lua: Wrong number of parameters passed to SetGearCollisionMask!') |
713 LuaParameterCountError('SetGearCollisionMask', 'gearUid, mask', lua_gettop(L)) |
708 else |
714 else |
709 begin |
715 begin |
710 gear:= GearByUID(lua_tointeger(L, 1)); |
716 gear:= GearByUID(lua_tointeger(L, 1)); |
711 if gear <> nil then |
717 if gear <> nil then |
712 gear^.CollisionMask:= lua_tointeger(L, 2); |
718 gear^.CollisionMask:= lua_tointeger(L, 2); |
716 |
722 |
717 function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
723 function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
718 var gear : PGear; |
724 var gear : PGear; |
719 begin |
725 begin |
720 if lua_gettop(L) <> 1 then |
726 if lua_gettop(L) <> 1 then |
721 LuaError('Lua: Wrong number of parameters passed to GetHogLevel!') |
727 LuaParameterCountError('GetHogLevel', 'gearUid', lua_gettop(L)) |
722 else |
728 else |
723 begin |
729 begin |
724 gear := GearByUID(lua_tointeger(L, 1)); |
730 gear := GearByUID(lua_tointeger(L, 1)); |
725 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
731 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
726 lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
732 lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
732 |
738 |
733 function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
739 function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
734 var gear : PGear; |
740 var gear : PGear; |
735 begin |
741 begin |
736 if lua_gettop(L) <> 2 then |
742 if lua_gettop(L) <> 2 then |
737 LuaError('Lua: Wrong number of parameters passed to SetHogLevel!') |
743 LuaParameterCountError('SetHogLevel', 'gearUid, level', lua_gettop(L)) |
738 else |
744 else |
739 begin |
745 begin |
740 gear:= GearByUID(lua_tointeger(L, 1)); |
746 gear:= GearByUID(lua_tointeger(L, 1)); |
741 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
747 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
742 gear^.Hedgehog^.BotLevel:= lua_tointeger(L, 2); |
748 gear^.Hedgehog^.BotLevel:= lua_tointeger(L, 2); |
747 function lc_gethogclan(L : Plua_State) : LongInt; Cdecl; |
753 function lc_gethogclan(L : Plua_State) : LongInt; Cdecl; |
748 var gear : PGear; |
754 var gear : PGear; |
749 begin |
755 begin |
750 if lua_gettop(L) <> 1 then |
756 if lua_gettop(L) <> 1 then |
751 begin |
757 begin |
752 LuaError('Lua: Wrong number of parameters passed to GetHogClan!'); |
758 LuaParameterCountError('GetHogClan', 'gearUid', lua_gettop(L)); |
753 lua_pushnil(L); // return value on stack (nil) |
759 lua_pushnil(L); // return value on stack (nil) |
754 end |
760 end |
755 else |
761 else |
756 begin |
762 begin |
757 gear:= GearByUID(lua_tointeger(L, 1)); |
763 gear:= GearByUID(lua_tointeger(L, 1)); |
767 |
773 |
768 function lc_getclancolor(L : Plua_State) : LongInt; Cdecl; |
774 function lc_getclancolor(L : Plua_State) : LongInt; Cdecl; |
769 begin |
775 begin |
770 if lua_gettop(L) <> 1 then |
776 if lua_gettop(L) <> 1 then |
771 begin |
777 begin |
772 LuaError('Lua: Wrong number of parameters passed to GetClanColor!'); |
778 LuaParameterCountError('GetClanColor', 'clan', lua_gettop(L)); |
773 lua_pushnil(L); // return value on stack (nil) |
779 lua_pushnil(L); // return value on stack (nil) |
774 end |
780 end |
775 else lua_pushinteger(L, ClansArray[lua_tointeger(L, 1)]^.Color shl 8 or $FF); |
781 else lua_pushinteger(L, ClansArray[lua_tointeger(L, 1)]^.Color shl 8 or $FF); |
776 lc_getclancolor:= 1 |
782 lc_getclancolor:= 1 |
777 end; |
783 end; |
781 team : PTeam; |
787 team : PTeam; |
782 hh : THedgehog; |
788 hh : THedgehog; |
783 i, j : LongInt; |
789 i, j : LongInt; |
784 begin |
790 begin |
785 if lua_gettop(L) <> 2 then |
791 if lua_gettop(L) <> 2 then |
786 LuaError('Lua: Wrong number of parameters passed to SetClanColor!') |
792 LuaParameterCountError('SetClanColor', 'clan, color', lua_gettop(L)) |
787 else |
793 else |
788 begin |
794 begin |
789 clan := ClansArray[lua_tointeger(L, 1)]; |
795 clan := ClansArray[lua_tointeger(L, 1)]; |
790 clan^.Color:= lua_tointeger(L, 2) shr 8; |
796 clan^.Color:= lua_tointeger(L, 2) shr 8; |
791 |
797 |
793 begin |
799 begin |
794 team:= clan^.Teams[i]; |
800 team:= clan^.Teams[i]; |
795 for j:= 0 to 7 do |
801 for j:= 0 to 7 do |
796 begin |
802 begin |
797 hh:= team^.Hedgehogs[j]; |
803 hh:= team^.Hedgehogs[j]; |
798 if (hh.Gear <> nil) or (hh.GearHidden <> nil) then |
804 if (hh.Gear <> nil) or (hh.GearHidden <> nil) then |
799 begin |
805 begin |
800 FreeTexture(hh.NameTagTex); |
806 FreeTexture(hh.NameTagTex); |
801 hh.NameTagTex:= RenderStringTex(hh.Name, clan^.Color, fnt16); |
807 hh.NameTagTex:= RenderStringTex(hh.Name, clan^.Color, fnt16); |
802 RenderHealth(hh); |
808 RenderHealth(hh); |
803 end; |
809 end; |
815 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
821 function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
816 var gear : PGear; |
822 var gear : PGear; |
817 begin |
823 begin |
818 if lua_gettop(L) <> 1 then |
824 if lua_gettop(L) <> 1 then |
819 begin |
825 begin |
820 LuaError('Lua: Wrong number of parameters passed to GetHogTeamName!'); |
826 LuaParameterCountError('GetHogTeamName', 'gearUid', lua_gettop(L)); |
821 lua_pushnil(L); // return value on stack (nil) |
827 lua_pushnil(L); // return value on stack (nil) |
822 end |
828 end |
823 else |
829 else |
824 begin |
830 begin |
825 gear:= GearByUID(lua_tointeger(L, 1)); |
831 gear:= GearByUID(lua_tointeger(L, 1)); |
836 function lc_gethogname(L : Plua_State) : LongInt; Cdecl; |
842 function lc_gethogname(L : Plua_State) : LongInt; Cdecl; |
837 var gear : PGear; |
843 var gear : PGear; |
838 begin |
844 begin |
839 if lua_gettop(L) <> 1 then |
845 if lua_gettop(L) <> 1 then |
840 begin |
846 begin |
841 LuaError('Lua: Wrong number of parameters passed to GetHogName!'); |
847 LuaParameterCountError('GetHogName', 'gearUid', lua_gettop(L)); |
842 lua_pushnil(L); // return value on stack (nil) |
848 lua_pushnil(L); // return value on stack (nil) |
843 end |
849 end |
844 else |
850 else |
845 begin |
851 begin |
846 gear:= GearByUID(lua_tointeger(L, 1)); |
852 gear:= GearByUID(lua_tointeger(L, 1)); |
857 function lc_sethogname(L : Plua_State) : LongInt; Cdecl; |
863 function lc_sethogname(L : Plua_State) : LongInt; Cdecl; |
858 var gear : PGear; |
864 var gear : PGear; |
859 begin |
865 begin |
860 if lua_gettop(L) <> 2 then |
866 if lua_gettop(L) <> 2 then |
861 begin |
867 begin |
862 LuaError('Lua: Wrong number of parameters passed to SetHogName!'); |
868 LuaParameterCountError('SetHogName', 'gearUid, name', lua_gettop(L)); |
863 lua_pushnil(L) |
869 lua_pushnil(L) |
864 end |
870 end |
865 else |
871 else |
866 begin |
872 begin |
867 gear:= GearByUID(lua_tointeger(L, 1)); |
873 gear:= GearByUID(lua_tointeger(L, 1)); |
879 function lc_gettimer(L : Plua_State) : LongInt; Cdecl; |
885 function lc_gettimer(L : Plua_State) : LongInt; Cdecl; |
880 var gear : PGear; |
886 var gear : PGear; |
881 begin |
887 begin |
882 if lua_gettop(L) <> 1 then |
888 if lua_gettop(L) <> 1 then |
883 begin |
889 begin |
884 LuaError('Lua: Wrong number of parameters passed to GetTimer!'); |
890 LuaParameterCountError('GetTimer', 'gearUid', lua_gettop(L)); |
885 lua_pushnil(L); // return value on stack (nil) |
891 lua_pushnil(L); // return value on stack (nil) |
886 end |
892 end |
887 else |
893 else |
888 begin |
894 begin |
889 gear:= GearByUID(lua_tointeger(L, 1)); |
895 gear:= GearByUID(lua_tointeger(L, 1)); |
898 function lc_gethealth(L : Plua_State) : LongInt; Cdecl; |
904 function lc_gethealth(L : Plua_State) : LongInt; Cdecl; |
899 var gear : PGear; |
905 var gear : PGear; |
900 begin |
906 begin |
901 if lua_gettop(L) <> 1 then |
907 if lua_gettop(L) <> 1 then |
902 begin |
908 begin |
903 LuaError('Lua: Wrong number of parameters passed to GetHealth!'); |
909 LuaParameterCountError('GetHealth', 'gearUid', lua_gettop(L)); |
904 lua_pushnil(L); // return value on stack (nil) |
910 lua_pushnil(L); // return value on stack (nil) |
905 end |
911 end |
906 else |
912 else |
907 begin |
913 begin |
908 gear:= GearByUID(lua_tointeger(L, 1)); |
914 gear:= GearByUID(lua_tointeger(L, 1)); |
917 function lc_getx(L : Plua_State) : LongInt; Cdecl; |
923 function lc_getx(L : Plua_State) : LongInt; Cdecl; |
918 var gear : PGear; |
924 var gear : PGear; |
919 begin |
925 begin |
920 if lua_gettop(L) <> 1 then |
926 if lua_gettop(L) <> 1 then |
921 begin |
927 begin |
922 LuaError('Lua: Wrong number of parameters passed to GetX!'); |
928 LuaParameterCountError('GetX', 'gearUid', lua_gettop(L)); |
923 lua_pushnil(L); // return value on stack (nil) |
929 lua_pushnil(L); // return value on stack (nil) |
924 end |
930 end |
925 else |
931 else |
926 begin |
932 begin |
927 gear:= GearByUID(lua_tointeger(L, 1)); |
933 gear:= GearByUID(lua_tointeger(L, 1)); |
936 function lc_gety(L : Plua_State) : LongInt; Cdecl; |
942 function lc_gety(L : Plua_State) : LongInt; Cdecl; |
937 var gear : PGear; |
943 var gear : PGear; |
938 begin |
944 begin |
939 if lua_gettop(L) <> 1 then |
945 if lua_gettop(L) <> 1 then |
940 begin |
946 begin |
941 LuaError('Lua: Wrong number of parameters passed to GetY!'); |
947 LuaParameterCountError('GetY', 'gearUid', lua_gettop(L)); |
942 lua_pushnil(L); // return value on stack (nil) |
948 lua_pushnil(L); // return value on stack (nil) |
943 end |
949 end |
944 else |
950 else |
945 begin |
951 begin |
946 gear:= GearByUID(lua_tointeger(L, 1)); |
952 gear:= GearByUID(lua_tointeger(L, 1)); |
955 function lc_copypv(L : Plua_State) : LongInt; Cdecl; |
961 function lc_copypv(L : Plua_State) : LongInt; Cdecl; |
956 var gears, geard : PGear; |
962 var gears, geard : PGear; |
957 begin |
963 begin |
958 if lua_gettop(L) <> 2 then |
964 if lua_gettop(L) <> 2 then |
959 begin |
965 begin |
960 LuaError('Lua: Wrong number of parameters passed to CopyPV!'); |
966 LuaParameterCountError('CopyPV', 'fromGearUid, toGearUid', lua_gettop(L)); |
961 end |
967 end |
962 else |
968 else |
963 begin |
969 begin |
964 gears:= GearByUID(lua_tointeger(L, 1)); |
970 gears:= GearByUID(lua_tointeger(L, 1)); |
965 geard:= GearByUID(lua_tointeger(L, 2)); |
971 geard:= GearByUID(lua_tointeger(L, 2)); |
976 |
982 |
977 function lc_followgear(L : Plua_State) : LongInt; Cdecl; |
983 function lc_followgear(L : Plua_State) : LongInt; Cdecl; |
978 var gear : PGear; |
984 var gear : PGear; |
979 begin |
985 begin |
980 if lua_gettop(L) <> 1 then |
986 if lua_gettop(L) <> 1 then |
981 LuaError('Lua: Wrong number of parameters passed to FollowGear!') |
987 LuaParameterCountError('FollowGear', 'gearUid', lua_gettop(L)) |
982 else |
988 else |
983 begin |
989 begin |
984 gear:= GearByUID(lua_tointeger(L, 1)); |
990 gear:= GearByUID(lua_tointeger(L, 1)); |
985 if gear <> nil then FollowGear:= gear |
991 if gear <> nil then FollowGear:= gear |
986 end; |
992 end; |
1014 end |
1020 end |
1015 end |
1021 end |
1016 else |
1022 else |
1017 lua_pushnil(L) |
1023 lua_pushnil(L) |
1018 end |
1024 end |
1019 else LuaError('Lua: Wrong number of parameters passed to HogSay!'); |
1025 else LuaParameterCountError('HogSay', 'gearUid, text, manner[, vgState]', lua_gettop(L)); |
1020 lc_hogsay:= 1 |
1026 lc_hogsay:= 1 |
1021 end; |
1027 end; |
1022 |
1028 |
1023 function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1029 function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1024 var gear, prevgear : PGear; |
1030 var gear, prevgear : PGear; |
1025 begin |
1031 begin |
1026 if lua_gettop(L) <> 1 then |
1032 if lua_gettop(L) <> 1 then |
1027 LuaError('Lua: Wrong number of parameters passed to SwitchHog!') |
1033 LuaParameterCountError('SwitchHog', 'gearUid', lua_gettop(L)) |
1028 else |
1034 else |
1029 begin |
1035 begin |
1030 gear:= GearByUID(lua_tointeger(L, 1)); |
1036 gear:= GearByUID(lua_tointeger(L, 1)); |
1031 // should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
1037 // should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
1032 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
1038 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
1037 prevgear^.Active := false; |
1043 prevgear^.Active := false; |
1038 prevgear^.State:= prevgear^.State and (not gstHHDriven); |
1044 prevgear^.State:= prevgear^.State and (not gstHHDriven); |
1039 prevgear^.Z := cHHZ; |
1045 prevgear^.Z := cHHZ; |
1040 prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; |
1046 prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; |
1041 end; |
1047 end; |
1042 |
1048 |
1043 SwitchCurrentHedgehog(gear^.Hedgehog); |
1049 SwitchCurrentHedgehog(gear^.Hedgehog); |
1044 CurrentTeam:= CurrentHedgehog^.Team; |
1050 CurrentTeam:= CurrentHedgehog^.Team; |
1045 |
1051 |
1046 gear^.State:= gear^.State or gstHHDriven; |
1052 gear^.State:= gear^.State or gstHHDriven; |
1047 gear^.Active := true; |
1053 gear^.Active := true; |
1060 begin |
1066 begin |
1061 gear:= GearByUID(lua_tointeger(L, 1)); |
1067 gear:= GearByUID(lua_tointeger(L, 1)); |
1062 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1068 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1063 AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) ); |
1069 AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) ); |
1064 end else |
1070 end else |
1065 |
1071 |
1066 if lua_gettop(L) = 2 then |
1072 if lua_gettop(L) = 2 then |
1067 begin |
1073 begin |
1068 gear:= GearByUID(lua_tointeger(L, 1)); |
1074 gear:= GearByUID(lua_tointeger(L, 1)); |
1069 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1075 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1070 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
1076 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
1071 end else |
1077 end else |
1072 begin |
1078 begin |
1073 LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
1079 LuaParameterCountError('AddAmmo', 'TODO', lua_gettop(L)); |
1074 end; |
1080 end; |
1075 |
1081 |
1076 lc_addammo:= 0; |
1082 lc_addammo:= 0; |
1077 |
1083 |
1078 end;} |
1084 end;} |
1087 if lua_gettop(L) = 2 then |
1093 if lua_gettop(L) = 2 then |
1088 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))) |
1094 AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))) |
1089 else |
1095 else |
1090 SetAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3)) |
1096 SetAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3)) |
1091 end |
1097 end |
1092 else LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
1098 else LuaParameterCountError('AddAmmo', 'gearUid, ammoType[, ammoCount]', lua_gettop(L)); |
1093 lc_addammo:= 0 |
1099 lc_addammo:= 0 |
1094 end; |
1100 end; |
1095 |
1101 |
1096 function lc_getammocount(L : Plua_State) : LongInt; Cdecl; |
1102 function lc_getammocount(L : Plua_State) : LongInt; Cdecl; |
1097 var gear : PGear; |
1103 var gear : PGear; |
1098 ammo : PAmmo; |
1104 ammo : PAmmo; |
1099 begin |
1105 begin |
1100 if (lua_gettop(L) = 2) then |
1106 if (lua_gettop(L) = 2) then |
1101 begin |
1107 begin |
1102 gear:= GearByUID(lua_tointeger(L, 1)); |
1108 gear:= GearByUID(lua_tointeger(L, 1)); |
1103 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1109 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1104 begin |
1110 begin |
1105 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
1111 ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
1106 if ammo^.AmmoType = amNothing then |
1112 if ammo^.AmmoType = amNothing then |
1107 lua_pushinteger(L, 0) |
1113 lua_pushinteger(L, 0) |
1108 else |
1114 else |
1109 lua_pushinteger(L, ammo^.Count) |
1115 lua_pushinteger(L, ammo^.Count) |
1110 end |
1116 end |
1111 else lua_pushinteger(L, 0) |
1117 else lua_pushinteger(L, 0) |
1112 end |
1118 end |
1113 else |
1119 else |
1114 begin |
1120 begin |
1115 LuaError('Lua: Wrong number of parameters passed to GetAmmoCount!'); |
1121 LuaParameterCountError('GetAmmoCount', 'gearUid, ammoType', lua_gettop(L)); |
1116 lua_pushnil(L) |
1122 lua_pushnil(L) |
1117 end; |
1123 end; |
1118 lc_getammocount:= 1 |
1124 lc_getammocount:= 1 |
1119 end; |
1125 end; |
1120 |
1126 |
1121 function lc_sethealth(L : Plua_State) : LongInt; Cdecl; |
1127 function lc_sethealth(L : Plua_State) : LongInt; Cdecl; |
1122 var gear : PGear; |
1128 var gear : PGear; |
1123 begin |
1129 begin |
1124 if lua_gettop(L) <> 2 then |
1130 if lua_gettop(L) <> 2 then |
1125 begin |
1131 begin |
1126 LuaError('Lua: Wrong number of parameters passed to SetHealth!'); |
1132 LuaParameterCountError('SetHealth', 'gearUid, health', lua_gettop(L)); |
1127 end |
1133 end |
1128 else |
1134 else |
1129 begin |
1135 begin |
1130 gear:= GearByUID(lua_tointeger(L, 1)); |
1136 gear:= GearByUID(lua_tointeger(L, 1)); |
1131 if gear <> nil then |
1137 if gear <> nil then |
1132 begin |
1138 begin |
1133 gear^.Health:= lua_tointeger(L, 2); |
1139 gear^.Health:= lua_tointeger(L, 2); |
1134 |
1140 |
1135 if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1141 if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1136 begin |
1142 begin |
1137 RenderHealth(gear^.Hedgehog^); |
1143 RenderHealth(gear^.Hedgehog^); |
1138 RecountTeamHealth(gear^.Hedgehog^.Team) |
1144 RecountTeamHealth(gear^.Hedgehog^.Team) |
1139 end; |
1145 end; |
1140 |
1146 |
1141 SetAllToActive; |
1147 SetAllToActive; |
1147 function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1153 function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1148 var gear : PGear; |
1154 var gear : PGear; |
1149 begin |
1155 begin |
1150 if lua_gettop(L) <> 2 then |
1156 if lua_gettop(L) <> 2 then |
1151 begin |
1157 begin |
1152 LuaError('Lua: Wrong number of parameters passed to SetTimer!'); |
1158 LuaParameterCountError('SetTimer', 'gearUid, timer', lua_gettop(L)); |
1153 end |
1159 end |
1154 else |
1160 else |
1155 begin |
1161 begin |
1156 gear:= GearByUID(lua_tointeger(L, 1)); |
1162 gear:= GearByUID(lua_tointeger(L, 1)); |
1157 if gear <> nil then gear^.Timer:= lua_tointeger(L, 2) |
1163 if gear <> nil then gear^.Timer:= lua_tointeger(L, 2) |
1161 |
1167 |
1162 function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1168 function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1163 var gear: PGear; |
1169 var gear: PGear; |
1164 begin |
1170 begin |
1165 if lua_gettop(L) <> 3 then |
1171 if lua_gettop(L) <> 3 then |
1166 LuaError('Lua: Wrong number of parameters passed to SetEffect!') |
1172 LuaParameterCountError('SetEffect', 'gearUid, effect, enabled', lua_gettop(L)) |
1167 else begin |
1173 else begin |
1168 gear := GearByUID(lua_tointeger(L, 1)); |
1174 gear := GearByUID(lua_tointeger(L, 1)); |
1169 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1175 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1170 gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3); |
1176 gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3); |
1171 end; |
1177 end; |
1172 lc_seteffect := 0; |
1178 lc_seteffect := 0; |
1173 end; |
1179 end; |
1180 |
|
1174 function lc_geteffect(L : Plua_State) : LongInt; Cdecl; |
1181 function lc_geteffect(L : Plua_State) : LongInt; Cdecl; |
1175 var gear : PGear; |
1182 var gear : PGear; |
1176 begin |
1183 begin |
1177 if lua_gettop(L) <> 2 then |
1184 if lua_gettop(L) <> 2 then |
1178 begin |
1185 begin |
1179 LuaError('Lua: Wrong number of parameters passed to GetEffect!'); |
1186 LuaParameterCountError('GetEffect', 'gearUid, effect', lua_gettop(L)); |
1180 end |
1187 end |
1181 else |
1188 else |
1182 begin |
1189 begin |
1183 gear:= GearByUID(lua_tointeger(L, 1)); |
1190 gear:= GearByUID(lua_tointeger(L, 1)); |
1184 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1191 if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1192 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
1199 function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
1193 var gear : PGear; |
1200 var gear : PGear; |
1194 begin |
1201 begin |
1195 if lua_gettop(L) <> 2 then |
1202 if lua_gettop(L) <> 2 then |
1196 begin |
1203 begin |
1197 LuaError('Lua: Wrong number of parameters passed to SetState!'); |
1204 LuaParameterCountError('SetState', 'gearUid, state', lua_gettop(L)); |
1198 end |
1205 end |
1199 else |
1206 else |
1200 begin |
1207 begin |
1201 gear:= GearByUID(lua_tointeger(L, 1)); |
1208 gear:= GearByUID(lua_tointeger(L, 1)); |
1202 if gear <> nil then |
1209 if gear <> nil then |
1211 function lc_getstate(L : Plua_State) : LongInt; Cdecl; |
1218 function lc_getstate(L : Plua_State) : LongInt; Cdecl; |
1212 var gear : PGear; |
1219 var gear : PGear; |
1213 begin |
1220 begin |
1214 if lua_gettop(L) <> 1 then |
1221 if lua_gettop(L) <> 1 then |
1215 begin |
1222 begin |
1216 LuaError('Lua: Wrong number of parameters passed to GetState!'); |
1223 LuaParameterCountError('GetState', 'gearUid', lua_gettop(L)); |
1217 end |
1224 end |
1218 else |
1225 else |
1219 begin |
1226 begin |
1220 gear:= GearByUID(lua_tointeger(L, 1)); |
1227 gear:= GearByUID(lua_tointeger(L, 1)); |
1221 if gear <> nil then |
1228 if gear <> nil then |
1229 function lc_gettag(L : Plua_State) : LongInt; Cdecl; |
1236 function lc_gettag(L : Plua_State) : LongInt; Cdecl; |
1230 var gear : PGear; |
1237 var gear : PGear; |
1231 begin |
1238 begin |
1232 if lua_gettop(L) <> 1 then |
1239 if lua_gettop(L) <> 1 then |
1233 begin |
1240 begin |
1234 LuaError('Lua: Wrong number of parameters passed to GetX!'); |
1241 LuaParameterCountError('GetTag', 'gearUid', lua_gettop(L)); |
1235 lua_pushnil(L); // return value on stack (nil) |
1242 lua_pushnil(L); // return value on stack (nil) |
1236 end |
1243 end |
1237 else |
1244 else |
1238 begin |
1245 begin |
1239 gear:= GearByUID(lua_tointeger(L, 1)); |
1246 gear:= GearByUID(lua_tointeger(L, 1)); |
1248 function lc_settag(L : Plua_State) : LongInt; Cdecl; |
1255 function lc_settag(L : Plua_State) : LongInt; Cdecl; |
1249 var gear : PGear; |
1256 var gear : PGear; |
1250 begin |
1257 begin |
1251 if lua_gettop(L) <> 2 then |
1258 if lua_gettop(L) <> 2 then |
1252 begin |
1259 begin |
1253 LuaError('Lua: Wrong number of parameters passed to SetTag!'); |
1260 LuaParameterCountError('SetTag', 'gearUid, tag', lua_gettop(L)); |
1254 end |
1261 end |
1255 else |
1262 else |
1256 begin |
1263 begin |
1257 gear:= GearByUID(lua_tointeger(L, 1)); |
1264 gear:= GearByUID(lua_tointeger(L, 1)); |
1258 if gear <> nil then |
1265 if gear <> nil then |
1274 function lc_sendstat(L : Plua_State) : LongInt; Cdecl; |
1281 function lc_sendstat(L : Plua_State) : LongInt; Cdecl; |
1275 var statInfo : TStatInfoType; |
1282 var statInfo : TStatInfoType; |
1276 var i : LongInt; |
1283 var i : LongInt; |
1277 var color : shortstring; |
1284 var color : shortstring; |
1278 begin |
1285 begin |
1279 statInfo := TStatInfoType(lua_tointeger(L, 1)); |
1286 statInfo := TStatInfoType(lua_tointeger(L, 1)); |
1280 if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills) |
1287 if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills) |
1281 and (statInfo <> siClanHealth)) then |
1288 and (statInfo <> siClanHealth)) then |
1282 begin |
1289 begin |
1283 LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 2 parameters.'); |
1290 LuaParameterCountError('SendStat', 'statInfoType, color', lua_gettop(L)); |
1284 end |
1291 end |
1285 else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills) |
1292 else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills) |
1286 or (statInfo = siClanHealth)) then |
1293 or (statInfo = siClanHealth)) then |
1287 begin |
1294 begin |
1288 LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 3 parameters.'); |
1295 LuaParameterCountError('SendStat', 'siClanHealth, color, teamname', lua_gettop(L)); |
1289 end |
1296 end |
1290 else |
1297 else |
1291 begin |
1298 begin |
1292 if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then |
1299 if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then |
1293 begin |
1300 begin |
1294 // 3: team name |
1301 // 3: team name |
1295 for i:= 0 to Pred(TeamsCount) do |
1302 for i:= 0 to Pred(TeamsCount) do |
1296 begin |
1303 begin |
1297 with TeamsArray[i]^ do |
1304 with TeamsArray[i]^ do |
1298 begin |
1305 begin |
1299 if TeamName = lua_tostring(L, 3) then |
1306 if TeamName = lua_tostring(L, 3) then |
1300 begin |
1307 begin |
1301 color := uUtils.IntToStr(Clan^.Color); |
1308 color := uUtils.IntToStr(Clan^.Color); |
1302 Break; |
1309 Break; |
1303 end |
1310 end |
1304 end |
1311 end |
1305 end; |
1312 end; |
1306 if (statInfo = siPlayerKills) then |
1313 if (statInfo = siPlayerKills) then |
1307 begin |
1314 begin |
1308 SendStat(siPlayerKills, color + ' ' + |
1315 SendStat(siPlayerKills, color + ' ' + |
1309 lua_tostring(L, 2) + ' ' + TeamsArray[i]^.TeamName); |
1316 lua_tostring(L, 2) + ' ' + TeamsArray[i]^.TeamName); |
1310 end |
1317 end |
1311 else if (statInfo = siClanHealth) then |
1318 else if (statInfo = siClanHealth) then |
1312 begin |
1319 begin |
1313 SendStat(siClanHealth, color + ' ' + |
1320 SendStat(siClanHealth, color + ' ' + |
1314 lua_tostring(L, 2)); |
1321 lua_tostring(L, 2)); |
1315 end |
1322 end |
1316 end |
1323 end |
1317 else |
1324 else |
1318 begin |
1325 begin |
1319 SendStat(statInfo,lua_tostring(L, 2)); |
1326 SendStat(statInfo,lua_tostring(L, 2)); |
1320 end; |
1327 end; |
1321 end; |
1328 end; |
1322 lc_sendstat:= 0 |
1329 lc_sendstat:= 0 |
1323 end; |
1330 end; |
1324 |
1331 |
1325 function lc_sendhealthstatsoff(L : Plua_State) : LongInt; Cdecl; |
1332 function lc_sendhealthstatsoff(L : Plua_State) : LongInt; Cdecl; |
1326 begin |
1333 begin |
1335 tryhard: boolean; |
1342 tryhard: boolean; |
1336 left, right: LongInt; |
1343 left, right: LongInt; |
1337 begin |
1344 begin |
1338 tryhard:= false; |
1345 tryhard:= false; |
1339 if (lua_gettop(L) <> 4) and (lua_gettop(L) <> 5) then |
1346 if (lua_gettop(L) <> 4) and (lua_gettop(L) <> 5) then |
1340 LuaError('Lua: Wrong number of parameters passed to FindPlace!') |
1347 LuaParameterCountError('FindPlace', 'gearUid, fall, left, right[, tryHarder]', lua_gettop(L)) |
1341 else |
1348 else |
1342 begin |
1349 begin |
1343 gear:= GearByUID(lua_tointeger(L, 1)); |
1350 gear:= GearByUID(lua_tointeger(L, 1)); |
1344 fall:= lua_toboolean(L, 2); |
1351 fall:= lua_toboolean(L, 2); |
1345 left:= lua_tointeger(L, 3); |
1352 left:= lua_tointeger(L, 3); |
1365 begin |
1372 begin |
1366 gear:= GearByUID(lua_tointeger(L, 2)); |
1373 gear:= GearByUID(lua_tointeger(L, 2)); |
1367 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1374 if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1368 AddVoice(TSound(lua_tointeger(L, 1)),gear^.Hedgehog^.Team^.Voicepack) |
1375 AddVoice(TSound(lua_tointeger(L, 1)),gear^.Hedgehog^.Team^.Voicepack) |
1369 end |
1376 end |
1370 else LuaError('Lua: Wrong number of parameters passed to PlaySound!'); |
1377 else LuaParameterCountError('PlaySound', 'soundId', lua_gettop(L)); |
1371 lc_playsound:= 0; |
1378 lc_playsound:= 0; |
1372 end; |
1379 end; |
1373 |
1380 |
1374 function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
1381 function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
1375 var np: LongInt; |
1382 var np: LongInt; |
1376 begin |
1383 begin |
1377 np:= lua_gettop(L); |
1384 np:= lua_gettop(L); |
1378 if (np < 5) or (np > 6) then |
1385 if (np < 5) or (np > 6) then |
1379 begin |
1386 begin |
1380 LuaError('Lua: Wrong number of parameters passed to AddTeam!'); |
1387 LuaParameterCountError('AddTeam', 'teamname, color, grave, fort, voicepack[, flag]', lua_gettop(L)); |
1381 //lua_pushnil(L) |
1388 //lua_pushnil(L) |
1382 end |
1389 end |
1383 else |
1390 else |
1384 begin |
1391 begin |
1385 ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true, true); |
1392 ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true, true); |
1397 function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
1404 function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
1398 var temp: ShortString; |
1405 var temp: ShortString; |
1399 begin |
1406 begin |
1400 if lua_gettop(L) <> 4 then |
1407 if lua_gettop(L) <> 4 then |
1401 begin |
1408 begin |
1402 LuaError('Lua: Wrong number of parameters passed to AddHog!'); |
1409 LuaParameterCountError('AddHog', 'hogname, botlevel, health, hat', lua_gettop(L)); |
1403 lua_pushnil(L) |
1410 lua_pushnil(L) |
1404 end |
1411 end |
1405 else |
1412 else |
1406 begin |
1413 begin |
1407 temp:= lua_tostring(L, 4); |
1414 temp:= lua_tostring(L, 4); |
1415 function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl; |
1422 function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl; |
1416 var gear: PGear; |
1423 var gear: PGear; |
1417 begin |
1424 begin |
1418 if lua_gettop(L) <> 2 then |
1425 if lua_gettop(L) <> 2 then |
1419 begin |
1426 begin |
1420 LuaError('Lua: Wrong number of parameters passed to HogTurnLeft!'); |
1427 LuaParameterCountError('HogTurnLeft', 'gearUid, boolean', lua_gettop(L)); |
1421 end |
1428 end |
1422 else |
1429 else |
1423 begin |
1430 begin |
1424 gear:= GearByUID(lua_tointeger(L, 1)); |
1431 gear:= GearByUID(lua_tointeger(L, 1)); |
1425 if gear <> nil then |
1432 if gear <> nil then |
1431 function lc_getgearposition(L : Plua_State) : LongInt; Cdecl; |
1438 function lc_getgearposition(L : Plua_State) : LongInt; Cdecl; |
1432 var gear: PGear; |
1439 var gear: PGear; |
1433 begin |
1440 begin |
1434 if lua_gettop(L) <> 1 then |
1441 if lua_gettop(L) <> 1 then |
1435 begin |
1442 begin |
1436 LuaError('Lua: Wrong number of parameters passed to GetGearPosition!'); |
1443 LuaParameterCountError('GetGearPosition', 'gearUid', lua_gettop(L)); |
1437 lua_pushnil(L); |
1444 lua_pushnil(L); |
1438 lua_pushnil(L) |
1445 lua_pushnil(L) |
1439 end |
1446 end |
1440 else |
1447 else |
1441 begin |
1448 begin |
1458 var gear: PGear; |
1465 var gear: PGear; |
1459 col: boolean; |
1466 col: boolean; |
1460 x, y: LongInt; |
1467 x, y: LongInt; |
1461 begin |
1468 begin |
1462 if lua_gettop(L) <> 3 then |
1469 if lua_gettop(L) <> 3 then |
1463 LuaError('Lua: Wrong number of parameters passed to SetGearPosition!') |
1470 LuaParameterCountError('SetGearPosition', 'gearUid, x, y', lua_gettop(L)) |
1464 else |
1471 else |
1465 begin |
1472 begin |
1466 gear:= GearByUID(lua_tointeger(L, 1)); |
1473 gear:= GearByUID(lua_tointeger(L, 1)); |
1467 if gear <> nil then |
1474 if gear <> nil then |
1468 begin |
1475 begin |
1484 function lc_getgeartarget(L : Plua_State) : LongInt; Cdecl; |
1491 function lc_getgeartarget(L : Plua_State) : LongInt; Cdecl; |
1485 var gear: PGear; |
1492 var gear: PGear; |
1486 begin |
1493 begin |
1487 if lua_gettop(L) <> 1 then |
1494 if lua_gettop(L) <> 1 then |
1488 begin |
1495 begin |
1489 LuaError('Lua: Wrong number of parameters passed to GetGearTarget!'); |
1496 LuaParameterCountError('GetGearTarget', 'gearUid', lua_gettop(L)); |
1490 lua_pushnil(L); |
1497 lua_pushnil(L); |
1491 lua_pushnil(L) |
1498 lua_pushnil(L) |
1492 end |
1499 end |
1493 else |
1500 else |
1494 begin |
1501 begin |
1509 |
1516 |
1510 function lc_setgeartarget(L : Plua_State) : LongInt; Cdecl; |
1517 function lc_setgeartarget(L : Plua_State) : LongInt; Cdecl; |
1511 var gear: PGear; |
1518 var gear: PGear; |
1512 begin |
1519 begin |
1513 if lua_gettop(L) <> 3 then |
1520 if lua_gettop(L) <> 3 then |
1514 LuaError('Lua: Wrong number of parameters passed to SetGearTarget!') |
1521 LuaParameterCountError('SetGearTarget', 'gearUid, x, y', lua_gettop(L)) |
1515 else |
1522 else |
1516 begin |
1523 begin |
1517 gear:= GearByUID(lua_tointeger(L, 1)); |
1524 gear:= GearByUID(lua_tointeger(L, 1)); |
1518 if gear <> nil then |
1525 if gear <> nil then |
1519 begin |
1526 begin |
1528 var gear: PGear; |
1535 var gear: PGear; |
1529 var t: LongInt; |
1536 var t: LongInt; |
1530 begin |
1537 begin |
1531 if lua_gettop(L) <> 1 then |
1538 if lua_gettop(L) <> 1 then |
1532 begin |
1539 begin |
1533 LuaError('Lua: Wrong number of parameters passed to GetGearVelocity!'); |
1540 LuaParameterCountError('GetGearVelocity', 'gearUid', lua_gettop(L)); |
1534 lua_pushnil(L); |
1541 lua_pushnil(L); |
1535 lua_pushnil(L) |
1542 lua_pushnil(L) |
1536 end |
1543 end |
1537 else |
1544 else |
1538 begin |
1545 begin |
1551 |
1558 |
1552 function lc_setgearvelocity(L : Plua_State) : LongInt; Cdecl; |
1559 function lc_setgearvelocity(L : Plua_State) : LongInt; Cdecl; |
1553 var gear: PGear; |
1560 var gear: PGear; |
1554 begin |
1561 begin |
1555 if lua_gettop(L) <> 3 then |
1562 if lua_gettop(L) <> 3 then |
1556 LuaError('Lua: Wrong number of parameters passed to SetGearVelocity!') |
1563 LuaParameterCountError('SetGearVelocity', 'gearUid, dx, dy', lua_gettop(L)) |
1557 else |
1564 else |
1558 begin |
1565 begin |
1559 gear:= GearByUID(lua_tointeger(L, 1)); |
1566 gear:= GearByUID(lua_tointeger(L, 1)); |
1560 if gear <> nil then |
1567 if gear <> nil then |
1561 begin |
1568 begin |
1568 end; |
1575 end; |
1569 |
1576 |
1570 function lc_setzoom(L : Plua_State) : LongInt; Cdecl; |
1577 function lc_setzoom(L : Plua_State) : LongInt; Cdecl; |
1571 begin |
1578 begin |
1572 if lua_gettop(L) <> 1 then |
1579 if lua_gettop(L) <> 1 then |
1573 LuaError('Lua: Wrong number of parameters passed to SetZoom!') |
1580 LuaParameterCountError('SetZoom', 'zoomLevel', lua_gettop(L)) |
1574 else |
1581 else |
1575 begin |
1582 begin |
1576 ZoomValue:= lua_tonumber(L, 1); |
1583 ZoomValue:= lua_tonumber(L, 1); |
1577 if ZoomValue < cMaxZoomLevel then |
1584 if ZoomValue < cMaxZoomLevel then |
1578 ZoomValue:= cMaxZoomLevel; |
1585 ZoomValue:= cMaxZoomLevel; |
1584 |
1591 |
1585 function lc_getzoom(L : Plua_State) : LongInt; Cdecl; |
1592 function lc_getzoom(L : Plua_State) : LongInt; Cdecl; |
1586 begin |
1593 begin |
1587 if lua_gettop(L) <> 0 then |
1594 if lua_gettop(L) <> 0 then |
1588 begin |
1595 begin |
1589 LuaError('Lua: Wrong number of parameters passed to GetZoom!'); |
1596 LuaParameterCountError('GetZoom', '', lua_gettop(L)); |
1590 lua_pushnil(L) |
1597 lua_pushnil(L) |
1591 end |
1598 end |
1592 else |
1599 else |
1593 lua_pushnumber(L, ZoomValue); |
1600 lua_pushnumber(L, ZoomValue); |
1594 lc_getzoom:= 1 |
1601 lc_getzoom:= 1 |
1597 function lc_setammo(L : Plua_State) : LongInt; Cdecl; |
1604 function lc_setammo(L : Plua_State) : LongInt; Cdecl; |
1598 var np: LongInt; |
1605 var np: LongInt; |
1599 begin |
1606 begin |
1600 np:= lua_gettop(L); |
1607 np:= lua_gettop(L); |
1601 if (np < 4) or (np > 5) then |
1608 if (np < 4) or (np > 5) then |
1602 LuaError('Lua: Wrong number of parameters passed to SetAmmo!') |
1609 LuaParameterCountError('SetAmmo', 'ammoType, count, probability, delay[, numberInCrate]', lua_gettop(L)) |
1603 else if np = 4 then |
1610 else if np = 4 then |
1604 ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), 1) |
1611 ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), 1) |
1605 else |
1612 else |
1606 ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
1613 ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
1607 lc_setammo:= 0 |
1614 lc_setammo:= 0 |
1610 function lc_setammodelay(L : Plua_State) : LongInt; Cdecl; |
1617 function lc_setammodelay(L : Plua_State) : LongInt; Cdecl; |
1611 var np: LongInt; |
1618 var np: LongInt; |
1612 begin |
1619 begin |
1613 np:= lua_gettop(L); |
1620 np:= lua_gettop(L); |
1614 if (np <> 2) then |
1621 if (np <> 2) then |
1615 LuaError('Lua: Wrong number of parameters passed to SetAmmoDelay!') |
1622 LuaParameterCountError('SetAmmoDelay', 'ammoType, delay', lua_gettop(L)) |
1616 else |
1623 else |
1617 ScriptSetAmmoDelay(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2)); |
1624 ScriptSetAmmoDelay(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2)); |
1618 lc_setammodelay:= 0 |
1625 lc_setammodelay:= 0 |
1619 end; |
1626 end; |
1620 |
1627 |
1621 function lc_setammostore(L : Plua_State) : LongInt; Cdecl; |
1628 function lc_setammostore(L : Plua_State) : LongInt; Cdecl; |
1622 var np: LongInt; |
1629 var np: LongInt; |
1623 begin |
1630 begin |
1624 np:= lua_gettop(L); |
1631 np:= lua_gettop(L); |
1625 if (np <> 4) then |
1632 if (np <> 4) then |
1626 LuaError('Lua: Wrong number of parameters passed to SetAmmoStore!') |
1633 LuaParameterCountError('SetAmmoStore', 'loadouts, probabilities, delays, reinforments', lua_gettop(L)) |
1627 else |
1634 else |
1628 begin |
1635 begin |
1629 ScriptAmmoLoadout:= lua_tostring(L, 1); |
1636 ScriptAmmoLoadout:= lua_tostring(L, 1); |
1630 ScriptAmmoProbability:= lua_tostring(L, 2); |
1637 ScriptAmmoProbability:= lua_tostring(L, 2); |
1631 ScriptAmmoDelay:= lua_tostring(L, 3); |
1638 ScriptAmmoDelay:= lua_tostring(L, 3); |
1637 function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
1644 function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
1638 var m : LongInt; |
1645 var m : LongInt; |
1639 begin |
1646 begin |
1640 if lua_gettop(L) <> 1 then |
1647 if lua_gettop(L) <> 1 then |
1641 begin |
1648 begin |
1642 LuaError('Lua: Wrong number of parameters passed to GetRandom!'); |
1649 LuaParameterCountError('GetRandom', 'number', lua_gettop(L)); |
1643 lua_pushnil(L); // return value on stack (nil) |
1650 lua_pushnil(L); // return value on stack (nil) |
1644 end |
1651 end |
1645 else |
1652 else |
1646 begin |
1653 begin |
1647 m:= lua_tointeger(L, 1); |
1654 m:= lua_tointeger(L, 1); |
1657 end; |
1664 end; |
1658 |
1665 |
1659 function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
1666 function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
1660 begin |
1667 begin |
1661 if lua_gettop(L) <> 1 then |
1668 if lua_gettop(L) <> 1 then |
1662 LuaError('Lua: Wrong number of parameters passed to SetWind!') |
1669 LuaParameterCountError('SetWind', 'windSpeed', lua_gettop(L)) |
1663 else |
1670 else |
1664 begin |
1671 begin |
1665 cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed; |
1672 cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed; |
1666 cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
1673 cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
1667 if cWindSpeed.isNegative then |
1674 if cWindSpeed.isNegative then |
1673 |
1680 |
1674 function lc_getdatapath(L : Plua_State) : LongInt; Cdecl; |
1681 function lc_getdatapath(L : Plua_State) : LongInt; Cdecl; |
1675 begin |
1682 begin |
1676 if lua_gettop(L) <> 0 then |
1683 if lua_gettop(L) <> 0 then |
1677 begin |
1684 begin |
1678 LuaError('Lua: Wrong number of parameters passed to GetDataPath!'); |
1685 LuaParameterCountError('GetDataPath', '', lua_gettop(L)); |
1679 lua_pushnil(L); |
1686 lua_pushnil(L); |
1680 end |
1687 end |
1681 else |
1688 else |
1682 lua_pushstring(L, str2pchar(cPathz[ptData])); |
1689 lua_pushstring(L, str2pchar(cPathz[ptData])); |
1683 lc_getdatapath:= 1 |
1690 lc_getdatapath:= 1 |
1685 |
1692 |
1686 function lc_getuserdatapath(L : Plua_State) : LongInt; Cdecl; |
1693 function lc_getuserdatapath(L : Plua_State) : LongInt; Cdecl; |
1687 begin |
1694 begin |
1688 if lua_gettop(L) <> 0 then |
1695 if lua_gettop(L) <> 0 then |
1689 begin |
1696 begin |
1690 LuaError('Lua: Wrong number of parameters passed to GetUserDataPath!'); |
1697 LuaParameterCountError('GetUserDataPath', '', lua_gettop(L)); |
1691 lua_pushnil(L); |
1698 lua_pushnil(L); |
1692 end |
1699 end |
1693 else |
1700 else |
1694 lua_pushstring(L, str2pchar(cPathz[ptData])); |
1701 lua_pushstring(L, str2pchar(cPathz[ptData])); |
1695 lc_getuserdatapath:= 1 |
1702 lc_getuserdatapath:= 1 |
1697 |
1704 |
1698 function lc_maphasborder(L : Plua_State) : LongInt; Cdecl; |
1705 function lc_maphasborder(L : Plua_State) : LongInt; Cdecl; |
1699 begin |
1706 begin |
1700 if lua_gettop(L) <> 0 then |
1707 if lua_gettop(L) <> 0 then |
1701 begin |
1708 begin |
1702 LuaError('Lua: Wrong number of parameters passed to MapHasBorder!'); |
1709 LuaParameterCountError('MapHasBorder', '', lua_gettop(L)); |
1703 lua_pushnil(L); |
1710 lua_pushnil(L); |
1704 end |
1711 end |
1705 else |
1712 else |
1706 lua_pushboolean(L, hasBorder); |
1713 lua_pushboolean(L, hasBorder); |
1707 lc_maphasborder:= 1 |
1714 lc_maphasborder:= 1 |
1710 function lc_getgearradius(L : Plua_State) : LongInt; Cdecl; |
1717 function lc_getgearradius(L : Plua_State) : LongInt; Cdecl; |
1711 var gear : PGear; |
1718 var gear : PGear; |
1712 begin |
1719 begin |
1713 if lua_gettop(L) <> 1 then |
1720 if lua_gettop(L) <> 1 then |
1714 begin |
1721 begin |
1715 LuaError('Lua: Wrong number of parameters passed to GetGearRadius!'); |
1722 LuaParameterCountError('GetGearRadius', 'gearUid', lua_gettop(L)); |
1716 lua_pushnil(L); // return value on stack (nil) |
1723 lua_pushnil(L); // return value on stack (nil) |
1717 end |
1724 end |
1718 else |
1725 else |
1719 begin |
1726 begin |
1720 gear:= GearByUID(lua_tointeger(L, 1)); |
1727 gear:= GearByUID(lua_tointeger(L, 1)); |
1728 |
1735 |
1729 function lc_gethoghat(L : Plua_State): LongInt; Cdecl; |
1736 function lc_gethoghat(L : Plua_State): LongInt; Cdecl; |
1730 var gear : PGear; |
1737 var gear : PGear; |
1731 begin |
1738 begin |
1732 if lua_gettop(L) <> 1 then |
1739 if lua_gettop(L) <> 1 then |
1733 LuaError('Lua: Wrong number of parameters passed to GetHogHat!') |
1740 LuaParameterCountError('GetHogHat', 'gearUid', lua_gettop(L)) |
1734 else begin |
1741 else begin |
1735 gear := GearByUID(lua_tointeger(L, 1)); |
1742 gear := GearByUID(lua_tointeger(L, 1)); |
1736 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1743 if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1737 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
1744 lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
1738 else |
1745 else |
1745 var gear : PGear; |
1752 var gear : PGear; |
1746 hat: ShortString; |
1753 hat: ShortString; |
1747 begin |
1754 begin |
1748 if lua_gettop(L) <> 2 then |
1755 if lua_gettop(L) <> 2 then |
1749 begin |
1756 begin |
1750 LuaError('Lua: Wrong number of parameters passed to SetHogHat!'); |
1757 LuaParameterCountError('SetHogHat', 'gearUid, hat', lua_gettop(L)); |
1751 lua_pushnil(L) |
1758 lua_pushnil(L) |
1752 end |
1759 end |
1753 else |
1760 else |
1754 begin |
1761 begin |
1755 gear:= GearByUID(lua_tointeger(L, 1)); |
1762 gear:= GearByUID(lua_tointeger(L, 1)); |
1768 end; |
1775 end; |
1769 |
1776 |
1770 function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
1777 function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
1771 begin |
1778 begin |
1772 if lua_gettop(L) <> 3 then |
1779 if lua_gettop(L) <> 3 then |
1773 LuaError('Lua: Wrong number of parameters passed to PlaceGirder!') |
1780 LuaParameterCountError('PlaceGirder', 'x, y, state', lua_gettop(L)) |
1774 else |
1781 else |
1775 TryPlaceOnLand( |
1782 TryPlaceOnLand( |
1776 lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2, |
1783 lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2, |
1777 lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2, |
1784 lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2, |
1778 sprAmGirder, lua_tointeger(L, 3), true, false); |
1785 sprAmGirder, lua_tointeger(L, 3), true, false); |
1780 end; |
1787 end; |
1781 |
1788 |
1782 function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
1789 function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
1783 begin |
1790 begin |
1784 if lua_gettop(L) <> 0 then |
1791 if lua_gettop(L) <> 0 then |
1785 LuaError('Lua: Wrong number of parameters passed to GetCurAmmoType!') |
1792 LuaParameterCountError('GetCurAmmoType', '', lua_gettop(L)) |
1786 else |
1793 else |
1787 lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType)); |
1794 lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType)); |
1788 lc_getcurammotype := 1; |
1795 lc_getcurammotype := 1; |
1789 end; |
1796 end; |
1790 |
1797 |
1791 function lc_savecampaignvar(L : Plua_State): LongInt; Cdecl; |
1798 function lc_savecampaignvar(L : Plua_State): LongInt; Cdecl; |
1792 begin |
1799 begin |
1793 if lua_gettop(L) <> 2 then |
1800 if lua_gettop(L) <> 2 then |
1794 LuaError('Lua: Wrong number of parameters passed to SaveCampaignVar!') |
1801 LuaParameterCountError('SaveCampaignVar', 'varname, value', lua_gettop(L)) |
1795 else begin |
1802 else begin |
1796 SendIPC('V!' + lua_tostring(L, 1) + ' ' + lua_tostring(L, 2) + #0); |
1803 SendIPC('V!' + lua_tostring(L, 1) + ' ' + lua_tostring(L, 2) + #0); |
1797 end; |
1804 end; |
1798 lc_savecampaignvar := 0; |
1805 lc_savecampaignvar := 0; |
1799 end; |
1806 end; |
1800 |
1807 |
1801 function lc_getcampaignvar(L : Plua_State): LongInt; Cdecl; |
1808 function lc_getcampaignvar(L : Plua_State): LongInt; Cdecl; |
1802 begin |
1809 begin |
1803 if (lua_gettop(L) <> 1) then |
1810 if (lua_gettop(L) <> 1) then |
1804 LuaError('Lua: Wrong number of parameters passed to GetCampaignVar!') |
1811 LuaParameterCountError('GetCampaignVar', 'varname', lua_gettop(L)) |
1805 else |
1812 else |
1806 SendIPCAndWaitReply('V?' + lua_tostring(L, 1) + #0); |
1813 SendIPCAndWaitReply('V?' + lua_tostring(L, 1) + #0); |
1807 lua_pushstring(L, str2pchar(CampaignVariable)); |
1814 lua_pushstring(L, str2pchar(CampaignVariable)); |
1808 lc_getcampaignvar := 1; |
1815 lc_getcampaignvar := 1; |
1809 end; |
1816 end; |
1810 |
1817 |
1811 function lc_hidehog(L: Plua_State): LongInt; Cdecl; |
1818 function lc_hidehog(L: Plua_State): LongInt; Cdecl; |
1812 var gear: PGear; |
1819 var gear: PGear; |
1813 begin |
1820 begin |
1814 if lua_gettop(L) <> 1 then |
1821 if lua_gettop(L) <> 1 then |
1815 LuaError('Lua: Wrong number of parameters passed to HideHog!') |
1822 LuaParameterCountError('HideHog', 'gearUid', lua_gettop(L)) |
1816 else |
1823 else |
1817 begin |
1824 begin |
1818 gear:= GearByUID(lua_tointeger(L, 1)); |
1825 gear:= GearByUID(lua_tointeger(L, 1)); |
1819 HideHog(gear^.hedgehog) |
1826 HideHog(gear^.hedgehog) |
1820 end; |
1827 end; |
1824 function lc_restorehog(L: Plua_State): LongInt; Cdecl; |
1831 function lc_restorehog(L: Plua_State): LongInt; Cdecl; |
1825 var i, h: LongInt; |
1832 var i, h: LongInt; |
1826 uid: LongWord; |
1833 uid: LongWord; |
1827 begin |
1834 begin |
1828 if lua_gettop(L) <> 1 then |
1835 if lua_gettop(L) <> 1 then |
1829 LuaError('Lua: Wrong number of parameters passed to RestoreHog!') |
1836 LuaParameterCountError('RestoreHog', 'gearUid', lua_gettop(L)) |
1830 else |
1837 else |
1831 begin |
1838 begin |
1832 uid:= LongWord(lua_tointeger(L, 1)); |
1839 uid:= LongWord(lua_tointeger(L, 1)); |
1833 if TeamsCount > 0 then |
1840 if TeamsCount > 0 then |
1834 for i:= 0 to Pred(TeamsCount) do |
1841 for i:= 0 to Pred(TeamsCount) do |
1846 function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; |
1853 function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; |
1847 var rtn: Boolean; |
1854 var rtn: Boolean; |
1848 begin |
1855 begin |
1849 if lua_gettop(L) <> 5 then |
1856 if lua_gettop(L) <> 5 then |
1850 begin |
1857 begin |
1851 LuaError('Lua: Wrong number of parameters passed to TestRectForObstacle!'); |
1858 LuaParameterCountError('TestRectForObstacle', 'x1, y1, x2, y2, landOnly', lua_gettop(L)); |
1852 lua_pushnil(L); // return value on stack (nil) |
1859 lua_pushnil(L); // return value on stack (nil) |
1853 end |
1860 end |
1854 else |
1861 else |
1855 begin |
1862 begin |
1856 rtn:= TestRectancleForObstacle( |
1863 rtn:= TestRectancleForObstacle( |
1868 |
1875 |
1869 function lc_setaihintsongear(L : Plua_State) : LongInt; Cdecl; |
1876 function lc_setaihintsongear(L : Plua_State) : LongInt; Cdecl; |
1870 var gear: PGear; |
1877 var gear: PGear; |
1871 begin |
1878 begin |
1872 if lua_gettop(L) <> 2 then |
1879 if lua_gettop(L) <> 2 then |
1873 LuaError('Lua: Wrong number of parameters passed to SetAIHintOnGear!') |
1880 LuaParameterCountError('SetAIHintOnGear', 'gearUid, aiHints', lua_gettop(L)) |
1874 else |
1881 else |
1875 begin |
1882 begin |
1876 gear:= GearByUID(lua_tointeger(L, 1)); |
1883 gear:= GearByUID(lua_tointeger(L, 1)); |
1877 if gear <> nil then |
1884 if gear <> nil then |
1878 gear^.aihints:= lua_tointeger(L, 2); |
1885 gear^.aihints:= lua_tointeger(L, 2); |
1883 |
1890 |
1884 function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
1891 function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
1885 begin |
1892 begin |
1886 if lua_gettop(L) <> 1 then |
1893 if lua_gettop(L) <> 1 then |
1887 begin |
1894 begin |
1888 LuaError('Lua: Wrong number of parameters passed to HedgewarsScriptLoad!'); |
1895 LuaParameterCountError('HedgewarsScriptLoad', 'scriptPath', lua_gettop(L)); |
1889 lua_pushnil(L) |
1896 lua_pushnil(L) |
1890 end |
1897 end |
1891 else |
1898 else |
1892 ScriptLoad(lua_tostring(L, 1)); |
1899 ScriptLoad(lua_tostring(L, 1)); |
1893 lc_hedgewarsscriptload:= 0; |
1900 lc_hedgewarsscriptload:= 0; |
1895 |
1902 |
1896 |
1903 |
1897 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
1904 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
1898 begin |
1905 begin |
1899 if lua_gettop(L) <> 4 then |
1906 if lua_gettop(L) <> 4 then |
1900 LuaError('Lua: Wrong number of parameters passed to DeclareAchievement!') |
1907 LuaParameterCountError('DeclareAchievement', 'achievementId, teamname, location, value', lua_gettop(L)) |
1901 else |
1908 else |
1902 declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4)); |
1909 declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4)); |
1903 lc_declareachievement:= 0 |
1910 lc_declareachievement:= 0 |
1904 end; |
1911 end; |
1905 /////////////////// |
1912 /////////////////// |
2034 begin |
2041 begin |
2035 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
2042 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
2036 if StoreCnt-1 < k then AddAmmoStore; |
2043 if StoreCnt-1 < k then AddAmmoStore; |
2037 inc(k) |
2044 inc(k) |
2038 end |
2045 end |
2039 else |
2046 else |
2040 for i:= 0 to Pred(TeamsCount) do |
2047 for i:= 0 to Pred(TeamsCount) do |
2041 begin |
2048 begin |
2042 for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
2049 for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
2043 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
2050 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
2044 if StoreCnt-1 < k then AddAmmoStore; |
2051 if StoreCnt-1 < k then AddAmmoStore; |
2090 AddFileLog('[LUA] Script not found: ' + name); |
2097 AddFileLog('[LUA] Script not found: ' + name); |
2091 exit; |
2098 exit; |
2092 end; |
2099 end; |
2093 |
2100 |
2094 f:= pfsOpenRead(s); |
2101 f:= pfsOpenRead(s); |
2095 if f = nil then |
2102 if f = nil then |
2096 exit; |
2103 exit; |
2097 |
2104 |
2098 physfsReaderSetBuffer(@buf); |
2105 physfsReaderSetBuffer(@buf); |
2099 ret:= lua_load(luaState, @physfsReader, f, Str2PChar(s)); |
2106 ret:= lua_load(luaState, @physfsReader, f, Str2PChar(s)); |
2100 pfsClose(f); |
2107 pfsClose(f); |
2301 SetAmmoReinforcement(ScriptAmmoReinforcement) |
2308 SetAmmoReinforcement(ScriptAmmoReinforcement) |
2302 end; |
2309 end; |
2303 AddAmmoStore; |
2310 AddAmmoStore; |
2304 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 |
2311 TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 |
2305 end |
2312 end |
2306 else |
2313 else |
2307 for i:= 0 to Pred(TeamsCount) do |
2314 for i:= 0 to Pred(TeamsCount) do |
2308 begin |
2315 begin |
2309 if ScriptExists('onNewAmmoStore') then |
2316 if ScriptExists('onNewAmmoStore') then |
2310 begin |
2317 begin |
2311 ScriptPrepareAmmoStore; |
2318 ScriptPrepareAmmoStore; |