Ride1234 Posted March 6, 2010 Share Posted March 6, 2010 I have a variable, its value gets from gui menu, and assigns to all players on the server, but I want that each player have his own value of this variable. Tell me please how to create a simple array in Lua, how to assign a varible to it, and how to use it in 'if...then' constructions. p.s. sorry for bad english. Link to comment
karlis Posted March 6, 2010 Share Posted March 6, 2010 arrayname={} arrayname[keyname]=value for key,value in ipairs(arrayname) do --do what u want, key is key, and value is value of array end http://www.lua.org/pil/2.5.html Link to comment
Ride1234 Posted March 6, 2010 Author Share Posted March 6, 2010 karlis, thank you. I have a code: local sVar1 = { } local sVar2 = { } local sVar3 = { } ... sVar1[source] = 1 sVar2[source] = 2 sVar3[source] = 3 ... function MyFunc( source, sVar1[source], sVar2[source] , sVar3[source] ) ... end But, when I try to compile it, i get: mymode.lua:62: ')' expected near '[' 62 line in mode, and 9 line here(function MyFunc) What is wrong? How to create a function with array in argument? Link to comment
karlis Posted March 6, 2010 Share Posted March 6, 2010 i think soruce is not registered there, use this, but anyway i didnt test it did u make source before making svar[source]=... ? function MyFunc( source, var1, var2 , var3 ) sVar1[source],sVar2[source],sVar3[source]=var1,var2,var3 ... Link to comment
Ride1234 Posted March 6, 2010 Author Share Posted March 6, 2010 i think soruce is not registered there, use this, but anyway i didnt test itdid u make source before making svar[source]=... ? function MyFunc( source, var1, var2 , var3 ) sVar1[source],sVar2[source],sVar3[source]=var1,var2,var3 ... Thank you, I solve it by the same way... Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now