dudeim
Member
- Joined
- Oct 5, 2007
- Messages
- 121
- Reaction score
- 9
Hey,
I have a little problem currently,
I have this very big table that requires alot of data set that needs to be accessed globaly (so I need to set it befor hand and not in some creature/action/globalscript or whatever)
So I wrote this function that sets that data for me so I have to write alot less like this:
Note: I'm trying to create something instance-like I have no idea if that even works (if you know if it works or if I'm doing it wrong or anything would be great to hear how I could fix it), I don't think it's the problem but it might, who knows
Also this is handwritten here in the editor so there might be some small errors
Thanks!
I have a little problem currently,
I have this very big table that requires alot of data set that needs to be accessed globaly (so I need to set it befor hand and not in some creature/action/globalscript or whatever)
So I wrote this function that sets that data for me so I have to write alot less like this:
Lua:
CurrentNumber = 1
Data = {
life={},
mana={},
stuff={},
create = function()
CurrentNumber = CurrentNumber+1
return Data[CurrentNumber]
end,
addData = function(life,mana,stuff) --this function adds alot of data to the table
table.insert(life,{val=life,max=life*2})
table.insert(mana,{val=mana,max=mana*2})
table.insert(stuff,{val=stuff,max=stuff*2})
--alot more here but just for simplification;)
end
}
--now I want to be able to call somewhere in 050-functions or somewhere else this:
Data1 = Data.create()
Data1.addData(150,50,13)
Data1.addData(250,0,5)
Data1.addData(50,200,50)
Data1.addData(125,100,25)
Data2 = Data.create()
Data2.addData(1150,150,113)
Data2.addData(1250,10,15)
Data2.addData(150,1200,150)
Data2.addData(1125,1100,125)
--etc....
Also this is handwritten here in the editor so there might be some small errors
Thanks!