Forum

> > CS2D > Scripts > Lua question - Table
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua question - Table

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Lua question - Table

Infinite Rain
Reviewer Off Offline

Zitieren
look at my code:
1
2
3
weaponshop[1]={x1=11,y1=5,x2=11,y2=6,npcpath="gfx/skilllife/npc3.png",npcposx=18,npcposy=3,npcrot=-90}
weaponshop[1]={item_id[1]=32,item_name[1]="M4a1",item_cost[1]=300}
weaponshop[1]={item_id[2]=45,item_name[2]="Laser",item_cost[2]=4500}

Error:

1
LUA ERROR at line 2 '}' expected near '='
WTF everything must work well pllz help me

alt Re: Lua question - Table

DannyDeth
User Off Offline

Zitieren
It's probably code elsewhere, these seem fine to me
or you might be missing a comma somewhere which happens to cause this error.

alt Re: Lua question - Table

Roni
User Off Offline

Zitieren
at which point did you create the tables "iteam_id", "item_name", "item_cost" ?
also im not sure if you can difine them like that in a table
try this
weaponshop={}
weaponshop[1]={}
weaponshop[1].item_id={*id1*,...}
weaponshop[1].item_cost={*cost1*,...}
weaponshop[1].item_name={*name1*,...}

alt Re: Lua question - Table

Lee
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
weaponshop = {}
weaponshop[1] = {item_id=32,item_name="M4A1",item_cost=300}
...

-- To use again

local m4a1 = weaponshop[1]
print("You bought a "..m4a1.item_name)

PS: You can access all of these weapon information from within CS2D, so you can just rehash the item_cost based on wpn id rather than complicating the matter further.

Also, never post in all caps
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht