ID:148701
 
Ok, i am working on creating a menu right, now when ever the usr presses his down button, i want it to make the cursor go down on. Why doesnt mine work?
By the way, it uses Client.screen

mob
proc
menucheck(direction,menu)
if(menu == "playermenu")
if(direction == SOUTH)
for(var/obj/menu/Curser/c in usr.client.screen)
src << "i found [c]!"
src << "[c.screen_loc]"
step(c,SOUTH)
The problem here is that step() can't be used for screen objects. You're going to have change the value of screen_loc to get it to move the way you want it to. If you give the cursor an xcoord and ycoord, you can use those values to adjust the screen position of the cursor. Also, I'm going to assume you only have one cursor on screen at a time(though, I'm not sure why it would be otherwise), so you can ditch that for() loop and just use locate(). You'll need to reset the value of xcoord and ycoord after someone closes one of the menus as well.

mob
proc
menucheck(direction,menu)
var/obj/menu/Curser/c = locate() in src.client.screen
if(menu == "playermenu")
if(direction == SOUTH)
//You'll want to check to be sure that they can actually move the cursor, too
src << "i found [c]!"
src << "[c.screen_loc]"
//Make sure you define xcoord and ycoord for your cursor!
c.screen_loc = "[c.xcoord],[c.ycoord--]"
In response to tenkuu
tenkuu wrote:
The problem here is that step() can't be used for screen objects. You're going to have change the value of screen_loc to get it to move the way you want it to. If you give the cursor an xcoord and ycoord, you can use those values to adjust the screen position of the cursor. Also, I'm going to assume you only have one cursor on screen at a time(though, I'm not sure why it would be otherwise), so you can ditch that for() loop and just use locate(). You'll need to reset the value of xcoord and ycoord after someone closes one of the menus as well.

mob
> proc
> menucheck(direction,menu)
> var/obj/menu/Curser/c = locate() in src.client.screen
> if(menu == "playermenu")
> if(direction == SOUTH)
> //You'll want to check to be sure that they can actually move the cursor, too
> src << "i found [c]!"
> src << "[c.screen_loc]"
> //Make sure you define xcoord and ycoord for your cursor!
> c.screen_loc = "[c.xcoord],[c.ycoord--]"


Sick dog!