English Where is my Mistake? Tile & Menu

5 replies
Goto Page
To the start Previous 1 Next To the start
Up
limonata
User
Offline Off
Hi, this script doesnt work, please tell me my mistake thanks.

Script:

Code:
1
2
3
4
5
6
7
8
9
addhook("move","mypos")
function mypos(id)
     local px = player(id,"tilex")     
     local py = player(id,"tiley")
     --parse('hudtxt2 ..id.. 10 "©000255000X='..x..' Y='..y..'" 13 430 0')
     if px == 1425 and py == 500 then
          menu(id,"Glow Menu,Red,Blue,Green,Yellow,Cyan,White,Aqua,Black,Next Page >>")
     end
end
01.05.14 09:40:33 am
Up
Marcell
Super User
Offline Off
Whats the error in console?
01.05.14 09:44:45 am
Up
Yates
Reviewer
Offline Off
None. This script works fine, your if statement must ask for the wrong x y because nothing produces an error.

I also recommend you use movetile instead. Otherwise the menu will open every pixel you move on the tile you are asking for.
01.05.14 10:09:56 am
Up
limonata
User
Offline Off
Thanks, there is no error but menu doesnt open. I will change it with 'movetile'

Edit:// Thanks yates it worked with movetile hook.

Problem solved.
edited 1×, last 01.05.14 10:26:26 am
01.05.14 02:11:07 pm
Up
VADemon
User
Offline Off
1) You will never (almost) match the exact position in pixels
2) You must round the position to get an integer (14|20 instead 14.234325043 | 20.2143249032590)
>> math.ceil / math.floor
01.05.14 02:32:04 pm
Up
Ortimh
User
Offline Off
@user VADemon:
Code:
function math.round (x)
     return math.floor (x + 0.5)
end

@user limonata: px and py returns player's x and y in tiles because:
Code:
local px = player(id,"tilex")
local py = player(id,"tiley")
edited 1×, last 01.05.14 04:52:05 pm
I'm awesome ... and I really like cookies.
To the start Previous 1 Next To the start