Pilchard is pretty much right.
Something is a (kind of) class with some stats(x, y, hp, hunger), with their respective retrieving methods(since we're talking about OOP), and CreateSomething(n) creates n instances(objects) of the Something class with mostly random numbers...
Wrapping it up - Someone trying to hack OOP into Lua, and as far as I can see...succeeding.
"Creature1.X"
Creature1 = {X = 50, Y = 30}You can now call Creature1.X and Creature1.Y
Want to create a single instance of creature without that much work:
function CreateSingleCreature(x, y) do
return {X = x, Y = y}
end
Want to create several?
function CreateSeveralCreature(num) do
CreaturesArray = {}
for i = 1, num do
CreaturesArray[i] = CreateSingleCreature( math.random(0, 50) , math.random(0, 50) )
end
end
Now you have a array with num creatures.