equal
deleted
inserted
replaced
32 interface |
32 interface |
33 |
33 |
34 procedure ScriptPrintStack; |
34 procedure ScriptPrintStack; |
35 procedure ScriptClearStack; |
35 procedure ScriptClearStack; |
36 |
36 |
37 function ScriptLoad(name : shortstring; mustExist : boolean) : boolean; |
37 procedure ScriptLoad(name : shortstring; mustExist : boolean); |
38 procedure ScriptOnPreviewInit; |
38 procedure ScriptOnPreviewInit; |
39 procedure ScriptOnGameInit; |
39 procedure ScriptOnGameInit; |
40 procedure ScriptOnScreenResize; |
40 procedure ScriptOnScreenResize; |
41 procedure ScriptSetInteger(name : shortstring; value : LongInt); |
41 procedure ScriptSetInteger(name : shortstring; value : LongInt); |
42 procedure ScriptSetString(name : shortstring; value : shortstring); |
42 procedure ScriptSetString(name : shortstring; value : shortstring); |
3064 lc_setgearaihints:= 0 |
3064 lc_setgearaihints:= 0 |
3065 end; |
3065 end; |
3066 |
3066 |
3067 |
3067 |
3068 function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
3068 function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
3069 var success : boolean; |
|
3070 begin |
3069 begin |
3071 if CheckLuaParamCount(L, 1, 'HedgewarsScriptLoad', 'scriptPath') then |
3070 if CheckLuaParamCount(L, 1, 'HedgewarsScriptLoad', 'scriptPath') then |
3072 begin |
3071 ScriptLoad(lua_tostring(L, 1), true) |
3073 success:= ScriptLoad(lua_tostring(L, 1), false); |
3072 else |
3074 lua_pushboolean(L, success); |
3073 lua_pushnil(L); |
3075 end |
3074 lc_hedgewarsscriptload:= 0; |
3076 else |
|
3077 lua_pushboolean(L, false); |
|
3078 lc_hedgewarsscriptload:= 1; |
|
3079 end; |
3075 end; |
3080 |
3076 |
3081 |
3077 |
3082 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
3078 function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
3083 begin |
3079 begin |
3562 end; |
3558 end; |
3563 ScriptLocaleReader:= mybuf |
3559 ScriptLocaleReader:= mybuf |
3564 end; |
3560 end; |
3565 // ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |
3561 // ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |
3566 |
3562 |
3567 function ScriptLoad(name : shortstring; mustExist : boolean) : boolean; |
3563 procedure ScriptLoad(name : shortstring; mustExist : boolean); |
3568 var ret : LongInt; |
3564 var ret : LongInt; |
3569 s : shortstring; |
3565 s : shortstring; |
3570 f : PFSFile; |
3566 f : PFSFile; |
3571 buf : array[0..Pred(BUFSIZE)] of byte; |
3567 buf : array[0..Pred(BUFSIZE)] of byte; |
3572 begin |
3568 begin |
3581 begin |
3577 begin |
3582 if mustExist then |
3578 if mustExist then |
3583 OutError('Script not found: ' + name, true) |
3579 OutError('Script not found: ' + name, true) |
3584 else |
3580 else |
3585 AddFileLog('[LUA] Script not found: ' + name); |
3581 AddFileLog('[LUA] Script not found: ' + name); |
3586 ScriptLoad:= false; |
|
3587 exit; |
3582 exit; |
3588 end; |
3583 end; |
3589 |
3584 |
3590 f:= pfsOpenRead(s); |
3585 f:= pfsOpenRead(s); |
3591 if f = nil then |
3586 if f = nil then |
3605 |
3600 |
3606 if ret <> 0 then |
3601 if ret <> 0 then |
3607 begin |
3602 begin |
3608 LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |
3603 LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |
3609 LuaError(lua_tostring(luaState, -1)); |
3604 LuaError(lua_tostring(luaState, -1)); |
3610 ScriptLoad:= false; |
|
3611 end |
3605 end |
3612 else |
3606 else |
3613 begin |
3607 begin |
3614 WriteLnToConsole('Lua: ' + name + ' loaded'); |
3608 WriteLnToConsole('Lua: ' + name + ' loaded'); |
3615 // call the script file |
3609 // call the script file |
3616 lua_pcall(luaState, 0, 0, 0); |
3610 lua_pcall(luaState, 0, 0, 0); |
3617 ScriptLoaded:= true; |
3611 ScriptLoaded:= true |
3618 ScriptLoad:= true; |
|
3619 end; |
3612 end; |
3620 end; |
3613 end; |
3621 |
3614 |
3622 procedure SetGlobals; |
3615 procedure SetGlobals; |
3623 var x, y: LongInt; |
3616 var x, y: LongInt; |