• Making Tables
    7 replies, posted
I am attempting to create a table that will output something of the following: [code] "superadmin" "prop_physics" = 500 "ragdolls" = 10 "admin" "prop_physics" = 300 "ragdolls" = 5 "user" "prop_physics" = 50 "ragdolls" = 0 [/code] This would obviously be a table consisting of keys corresponding to group names and values which are equivelent to an assosciative arrays of class names and values. This is my attempt at this: [code] Limits = { "superadmin" = { "prop_physics" = 1000, "ragdolls" = 10 }, "admin" = { "prop_physics" = 500, "ragdolls" = 10 } "user" = { "prop_physics" = 50, "ragdolls" = 0 } } [/code] Unfortunately, it does not work. Any guidance on how I would do this is most appreciated.
You posted this AFTER i helped you over steam? :Dawkins102:
[QUOTE=CombineGuru;19975885]You posted this AFTER i helped you over steam? :Dawkins102:[/QUOTE] That would be a dumb thing to do. L2Compare times. ;3 But there are different ways of doing this, and I'd like to learn them.
[lua] Limits = { "SuperAdmin" = { "prop_physics" = 1000; "ragdolls" = 10; } "Admin" = { "prop_physics" = 500; "ragdolls = 10; } "User" = { "prop_physics" = 50; -- 50 props? What the fuck, can't build anything with that. "ragdolls" = 0; } } function PlayerWhat(p) for k,v in pairs(Limits) do if( tostring(v) == "SuperAdmin" ) then if( p:IsSuperAdmin() ) then p.MaxProps = v.prop_physics or 9001; end end end end [/lua]
Read [url=http://www.lua.org/pil/3.6.html]this[/url].
[QUOTE=Nevec;19976414]Read [url=http://www.lua.org/pil/3.6.html]this[/url].[/QUOTE] Thanks, this was actually rather useful. Silly I didn't go there myself.
You need a comma to separate the inside tables (semicolon also works). "string" = value doesn't parse. It's either ["string"] = value or string = value. [lua]Limits = { SuperAdmin = { prop_physics = 1000, ragdolls = 10 }, Admin = { prop_physics = 500, ragdolls = 10 }, User = { prop_physics = 50, ragdolls = 0 } }[/lua]
[QUOTE=fishface60;19982975]You need a comma to separate the inside tables (semicolon also works). "string" = value doesn't parse. It's either ["string"] = value or string = value. [lua]Limits = { SuperAdmin = { prop_physics = 1000, ragdolls = 10 }, Admin = { prop_physics = 500, ragdolls = 10 }, User = { prop_physics = 50, ragdolls = 0 } }[/lua][/QUOTE] Yeah, I gathered that from that lua article, thanks anyway.
Sorry, you need to Log In to post a reply to this thread.