for i = 1, config.amount do
Game.createMonster(config.monster, Position(math.random(topL.x, botR.x), math.random(topL.y, botR.y), topL.z))
end
local config = {
monster = "Rat",
amount = 5,
topL = {x = 100, y = 100, z = 7},
botR = {x = 200, y = 200, z = 7}
}
for var = 1, config.amount do
local pos = {x = math.random(config.topL.x, config.botR.x), y = math.random(config.topL.y, config.botR.y), z = math.random(config.topL.z, config.botR.z)}
doCreateMonster(config.monster:lower(), pos)
end
Isn't Position just a matter of,There is no Position() in 0.4, you have to do {x=math.random(topL.x, botR.x), y=math.random(topL.y, botR.y), z=topL.z}
function Position(a, b, c, d)
return {x = (a > -1 and a < 65536) and a or 0, y = (b > -1 and b < 65536) and b or 0, z = (c > -1 and c < 16) and c or 7, stackpos = (d > -1 and d < 256) and d or 255}
end
What else is there to position aside from using it as a function, i never actually seen it used for anything else aside from using it as a shortcut to setting the x,y,z and stackpos.You have to set the metatable as well
// Position
registerClass("Position", "", LuaScriptInterface::luaPositionCreate);
registerMetaMethod("Position", "__add", LuaScriptInterface::luaPositionAdd);
registerMetaMethod("Position", "__sub", LuaScriptInterface::luaPositionSub);
registerMetaMethod("Position", "__eq", LuaScriptInterface::luaPositionCompare);
registerMethod("Position", "getDistance", LuaScriptInterface::luaPositionGetDistance);
registerMethod("Position", "isSightClear", LuaScriptInterface::luaPositionIsSightClear);
registerMethod("Position", "sendMagicEffect", LuaScriptInterface::luaPositionSendMagicEffect);
registerMethod("Position", "sendDistanceEffect", LuaScriptInterface::luaPositionSendDistanceEffect);
https://github.com/otland/forgottenserver/wiki/MetatableositionWhat else is there to position aside from using it as a function, i never actually seen it used for anything else aside from using it as a shortcut to setting the x,y,z and stackpos.
Is getPosition a metamethod of Position?
function Position(x, y, z, stackpos)
local t = {x=x, y=y, z=z, stackpos=stackpos or 0}
return setmetatable(t, debug.getmetatable(Position))
end