hedgewars/uScript.pas
changeset 3774 af0e68ca273e
parent 3761 f96b99f944e6
child 3777 5276f2150d65
equal deleted inserted replaced
3773:f552c7b439fa 3774:af0e68ca273e
   778 ScriptSetInteger('TurnTime', cHedgehogTurnTime);
   778 ScriptSetInteger('TurnTime', cHedgehogTurnTime);
   779 ScriptSetInteger('CaseFreq', cCaseFactor);
   779 ScriptSetInteger('CaseFreq', cCaseFactor);
   780 ScriptSetInteger('LandAdds', cLandAdditions);
   780 ScriptSetInteger('LandAdds', cLandAdditions);
   781 ScriptSetInteger('Explosives', cExplosives);
   781 ScriptSetInteger('Explosives', cExplosives);
   782 ScriptSetInteger('Delay', cInactDelay);
   782 ScriptSetInteger('Delay', cInactDelay);
       
   783 ScriptSetInteger('Ready', cReadyDelay);
   783 ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns);
   784 ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns);
   784 ScriptSetString('Map', '');
   785 ScriptSetString('Map', '');
   785 ScriptSetString('Theme', '');
   786 ScriptSetString('Theme', '');
   786 
   787 
   787 // import locale
   788 // import locale
   803 ParseCommand('$sd_turns ' + ScriptGetString('SuddenDeathTurns'), true);
   804 ParseCommand('$sd_turns ' + ScriptGetString('SuddenDeathTurns'), true);
   804 if ScriptGetString('Map') <> '' then
   805 if ScriptGetString('Map') <> '' then
   805     ParseCommand('map ' + ScriptGetString('Map'), true);
   806     ParseCommand('map ' + ScriptGetString('Map'), true);
   806 if ScriptGetString('Theme') <> '' then
   807 if ScriptGetString('Theme') <> '' then
   807     ParseCommand('theme ' + ScriptGetString('Theme'), true);
   808     ParseCommand('theme ' + ScriptGetString('Theme'), true);
       
   809 cReadyDelay:= ScriptGetInteger('Ready');
   808 
   810 
   809 if ScriptExists('onAmmoStoreInit') then
   811 if ScriptExists('onAmmoStoreInit') then
   810     begin
   812     begin
   811     ScriptPrepareAmmoStore;
   813     ScriptPrepareAmmoStore;
   812     ScriptCall('onAmmoStoreInit');
   814     ScriptCall('onAmmoStoreInit');
   819 procedure ScriptLoad(name : shortstring);
   821 procedure ScriptLoad(name : shortstring);
   820 var ret : LongInt;
   822 var ret : LongInt;
   821 begin
   823 begin
   822 ret:= luaL_loadfile(luaState, Str2PChar(name));
   824 ret:= luaL_loadfile(luaState, Str2PChar(name));
   823 if ret <> 0 then
   825 if ret <> 0 then
   824     LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')')
   826     begin
       
   827     LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
       
   828     LuaError('Lua: ' + lua_tostring(luaState, -1));
       
   829     end
   825 else
   830 else
   826     begin
   831     begin
   827     WriteLnToConsole('Lua: ' + name + ' loaded');
   832     WriteLnToConsole('Lua: ' + name + ' loaded');
   828     // call the script file
   833     // call the script file
   829     lua_pcall(luaState, 0, 0, 0);
   834     lua_pcall(luaState, 0, 0, 0);