Forum

> > CS2D > Scripts > "Table" example
Forums overviewCS2D overview Scripts overviewLog in to reply

English "Table" example

22 replies
Page
To the start Previous 1 2 Next To the start

old Re: "Table" example

EP
User Off Offline

Quote
Oh sorry @user EndDead: , I made a typo in a function name

1
2
3
4
5
6
7
8
9
10
11
12
EXAMPLE = {
     {43, 23, 24}, -- TileX, TileY, Item ID
     {13, 43, 45} -- TileX, TileY, Item ID
}
addhook("use","_use")
function _use(id,x,y)
     for k,v in pairs(EXAMPLE) do
          if x == v[1] and y == v[2] then
               parse("equip "..id.." "..v[3])
          end
     end
end

old Re: "Table" example

EndDead
User Off Offline

Quote
@user EP: I already noticed the mistake and it still didnt work. (And gave you that console error wrongly [It was still true, cause of your typo] , i messed up when i re-wrote the script)
I guess the script gets the postion X and Y not the Tile X and Tile Y.
I'm fixing that with something like...
1
local x,y=player(id,"tilex"),player(id,"tiley")
Then im giving my results again.

Edit:
Finally, got it to work. Now goin to learn more things. Thanks all!

Final Example >


PS: again, I may not use this method in any script, just an example to learn new things.
edited 2×, last 28.12.12 08:19:49 pm
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview