80 |
80 |
81 // functions called from Lua: |
81 // functions called from Lua: |
82 // function(L : Plua_State) : LongInt; Cdecl; |
82 // function(L : Plua_State) : LongInt; Cdecl; |
83 // where L contains the state, returns the number of return values on the stack |
83 // where L contains the state, returns the number of return values on the stack |
84 // call lua_gettop(L) to receive number of parameters passed |
84 // call lua_gettop(L) to receive number of parameters passed |
|
85 |
|
86 function lc_band(L: PLua_State): LongInt; Cdecl; |
|
87 begin |
|
88 if lua_gettop(L) <> 2 then |
|
89 begin |
|
90 LuaError('Lua: Wrong number of parameters passed to band!'); |
|
91 lua_pushnil(L); |
|
92 end |
|
93 else lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)); |
|
94 lc_band := 1; |
|
95 end; |
|
96 |
|
97 function lc_bor(L: PLua_State): LongInt; Cdecl; |
|
98 begin |
|
99 if lua_gettop(L) <> 2 then |
|
100 begin |
|
101 LuaError('Lua: Wrong number of parameters passed to bor!'); |
|
102 lua_pushnil(L); |
|
103 end |
|
104 else lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)); |
|
105 lc_bor := 1; |
|
106 end; |
|
107 |
|
108 function lc_bnot(L: PLua_State): LongInt; Cdecl; |
|
109 begin |
|
110 if lua_gettop(L) <> 1 then |
|
111 begin |
|
112 LuaError('Lua: Wrong number of parameters passed to bnot!'); |
|
113 lua_pushnil(L); |
|
114 end |
|
115 else lua_pushinteger(L, not lua_tointeger(L, 1)); |
|
116 lc_bnot := 1; |
|
117 end; |
85 |
118 |
86 function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
119 function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
87 begin |
120 begin |
88 if lua_gettop(L) = 1 then |
121 if lua_gettop(L) = 1 then |
89 begin |
122 begin |
1316 |
1349 |
1317 for he:= Low(THogEffect) to High(THogEffect) do |
1350 for he:= Low(THogEffect) to High(THogEffect) do |
1318 ScriptSetInteger(EnumToStr(he), ord(he)); |
1351 ScriptSetInteger(EnumToStr(he), ord(he)); |
1319 |
1352 |
1320 // register functions |
1353 // register functions |
|
1354 lua_register(luaState, 'band', @lc_band); |
|
1355 lua_register(luaState, 'bor', @lc_bor); |
|
1356 lua_register(luaState, 'bnot', @lc_bnot); |
1321 lua_register(luaState, 'AddGear', @lc_addgear); |
1357 lua_register(luaState, 'AddGear', @lc_addgear); |
1322 lua_register(luaState, 'DeleteGear', @lc_deletegear); |
1358 lua_register(luaState, 'DeleteGear', @lc_deletegear); |
1323 lua_register(luaState, 'AddVisualGear', @lc_addvisualgear); |
1359 lua_register(luaState, 'AddVisualGear', @lc_addvisualgear); |
1324 lua_register(luaState, 'DeleteVisualGear', @lc_deletevisualgear); |
1360 lua_register(luaState, 'DeleteVisualGear', @lc_deletevisualgear); |
1325 lua_register(luaState, 'GetVisualGearValues', @lc_getvisualgearvalues); |
1361 lua_register(luaState, 'GetVisualGearValues', @lc_getvisualgearvalues); |