Forum

> > CS2D > Scripts > Function in table
Forums overviewCS2D overview Scripts overviewLog in to reply

English Function in table

2 replies
To the start Previous 1 Next To the start

old Function in table

xSkyLordx
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
gg={}
gg[1]={x=1,y=3,msg="menu open!",
func(id) menu(id,"Admin menu,commands,items,ban,kick") end
}

addhook("movetile","ggwalk")
function ggwalk(id,x,y)
for _,v in ipairs(gg) do
if (x==v.x) and (y==v.y) then

--Function of gg[1] ???

end
end
end

how can i use table func(id) function ??

old Re: Function in table

EP
User Off Offline

Quote
This is the way you shall use:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
gg={}
gg[1]={x=1,
	y=3,
	msg="menu open!",
	func = function(id) menu(id,"Admin menu,commands,items,ban,kick") end}

addhook("movetile","ggwalk")
function ggwalk(id,x,y)
	for _,v in ipairs(gg) do
		if (x==v.x) and (y==v.y) then
			v.func(id)
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview