A sort of GUI, do you think the code is clear enough?
function create_monster(options) local monster=extend_table({},monster_base_methods) -- create a basic monster extend_table(monster,options) -- set specific values / override methods ... do other initialization... return monsterend...my_monster = create_monster{ name="Bob", health=100, weapon=create_weapon{name="Bludgeon of Bobbing", damage=10}, function attack(self,target) -- override standard attack method self:yell("Bob is angry!") return monster_base_methods.attack(self,target) -- do standard attack end,}
monster = {}monster.__index = monsterfunction monster.create(name,hp,str,wp) local mob={} setmetatable(mob,monster) mob.name=name mob.hp=hp mob.str=str mob.wp=wp mob.dmg="0" return mobendfunction monster:attacking(target) self.dmg=self.str*self.wp message=self.name.." attacked and dealt "..self.dmg.." damages to "..target return messageendaggro=monster.create("Bob",100,20,3)print(aggro:attacking("peter"))
"SHAPES.LUA:382: attempt to concatenate global 'choiche'"
ty for your reply! i appreciate a lot your comments and advices, the memory fact is something i didn't think about, in fact i should have tought that a camera has not a lot of ram
honestly i didn't understand very well the extend_table, i mean, your example is clear but the function itself is not clear to me
attempt to concatenate global 'choiche'"
Started by mrShrimp LUA Scripting
Started by Andre-K Script Writing
Started by TheFattie Script Writing
Started by Asdew General Discussion and Assistance
Started by hancockks Hello, I'm a NEWBIE - HELP!! (Newbies assistance, User Guides and thank you notes)