@Gesior.pl Wow perfect example to make me undestand a few more, so in you point number 2 you say i can make something in c++ and convert it to lua? or am i wrong xD
I mean that these 2 languages can communicate with each other, not convert C++ to LUA or LUA to C++ (every programing language at end convert to 'machine code', but it's not easy to write one program in more then 1 language, but it's possible to write program in C++ and LUA, that's why we use it).
You use in LUA function:
and it starts C++ function:
https://github.com/otland/forgottenserver/blob/master/src/luascript.cpp#L4392
PHP:
int LuaScriptInterface::luaGameStartRaid(lua_State* L)
{
// Game.startRaid(raidName)
const std::string& raidName = getString(L, 1);
Raid* raid = g_game.raids.getRaidByName(raidName);
if (raid) {
raid->startRaid();
pushBoolean(L, true);
} else {
lua_pushnil(L);
}
return 1;
}
It executes some advanced calculations [that we want to work fast, so we wrote them in C++, not LUA] like:
raid->startRaid(); - start raid, spawn monsters etc.
and then return to LUA some 'answer':
If raid with name you send exists and started, it return
boolean true:
If raid with name you send does not exist, it return
nil ('nil' is special LUA value which means 'nothing', if you use it in 'if' that will works like 'false'):
So your LUA script send to some C++ function parameter 'demons' and received answer, if raid started.
You can use LUA code like that:
PHP:
local raidNameToSend = 'demons'
local returnedValue = Game.startRaid(raidNameToSend)
if(returnedValue) then
print('RAID STARTED!')
else
print('WRONG RAID NAME :( ')
end