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 procedure ScriptLoad(name : shortstring); |
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); |
3066 |
3066 |
3067 |
3067 |
3068 function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
3068 function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
3069 begin |
3069 begin |
3070 if CheckLuaParamCount(L, 1, 'HedgewarsScriptLoad', 'scriptPath') then |
3070 if CheckLuaParamCount(L, 1, 'HedgewarsScriptLoad', 'scriptPath') then |
3071 ScriptLoad(lua_tostring(L, 1)) |
3071 ScriptLoad(lua_tostring(L, 1), true) |
3072 else |
3072 else |
3073 lua_pushnil(L); |
3073 lua_pushnil(L); |
3074 lc_hedgewarsscriptload:= 0; |
3074 lc_hedgewarsscriptload:= 0; |
3075 end; |
3075 end; |
3076 |
3076 |
3558 end; |
3558 end; |
3559 ScriptLocaleReader:= mybuf |
3559 ScriptLocaleReader:= mybuf |
3560 end; |
3560 end; |
3561 // ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |
3561 // ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |
3562 |
3562 |
3563 procedure ScriptLoad(name : shortstring); |
3563 procedure ScriptLoad(name : shortstring; mustExist : boolean); |
3564 var ret : LongInt; |
3564 var ret : LongInt; |
3565 s : shortstring; |
3565 s : shortstring; |
3566 f : PFSFile; |
3566 f : PFSFile; |
3567 buf : array[0..Pred(BUFSIZE)] of byte; |
3567 buf : array[0..Pred(BUFSIZE)] of byte; |
3568 begin |
3568 begin |
3573 wordCount:= 0; |
3573 wordCount:= 0; |
3574 locSum:= 0; |
3574 locSum:= 0; |
3575 s:= cPathz[ptData] + name; |
3575 s:= cPathz[ptData] + name; |
3576 if not pfsExists(s) then |
3576 if not pfsExists(s) then |
3577 begin |
3577 begin |
3578 AddFileLog('[LUA] Script not found: ' + name); |
3578 if mustExist then |
|
3579 OutError('Script not found: ' + name, true) |
|
3580 else |
|
3581 AddFileLog('[LUA] Script not found: ' + name); |
3579 exit; |
3582 exit; |
3580 end; |
3583 end; |
3581 |
3584 |
3582 f:= pfsOpenRead(s); |
3585 f:= pfsOpenRead(s); |
3583 if f = nil then |
3586 if f = nil then |
3584 exit; |
3587 OutError('Error reading script: ' + name, true); |
3585 |
3588 |
3586 hedgewarsMountPackage(Str2PChar(copy(s, 3, length(s)-6)+'.hwp')); |
3589 hedgewarsMountPackage(Str2PChar(copy(s, 3, length(s)-6)+'.hwp')); |
3587 |
3590 |
3588 physfsReaderSetBuffer(@buf); |
3591 physfsReaderSetBuffer(@buf); |
3589 if Pos('Locale/',s) <> 0 then |
3592 if Pos('Locale/',s) <> 0 then |