LUA GetRand
Posted: Fri Nov 13, 2009 3:35 am
Hi,
I wanted to have a chance that a monster would jump out and needed random
Can i get this added?
int EQ2Emu_lua_GetRand(lua_State* state) {
if(!lua_interface)
return 0;
srand(time(0));
int max = lua_interface->GetInt32Value(state, 1);
int randomNumber = rand();
int value = (randomNumber % max) + 1;
//LogFile->write(EQEMuLog::Debug, "Random Value was: %i", value);
lua_interface->SetInt32Value(state, value);
return 1;
}
Cheers
I wanted to have a chance that a monster would jump out and needed random
Can i get this added?
int EQ2Emu_lua_GetRand(lua_State* state) {
if(!lua_interface)
return 0;
srand(time(0));
int max = lua_interface->GetInt32Value(state, 1);
int randomNumber = rand();
int value = (randomNumber % max) + 1;
//LogFile->write(EQEMuLog::Debug, "Random Value was: %i", value);
lua_interface->SetInt32Value(state, value);
return 1;
}
Cheers