ID:151538
 
Ok, I've come back to one of my old projects I was trying to pull off "Final Fantasy 3". Anyways Ive been working at it for a while, trying to pull off a sort of menu system using a cursor and arrows. I found a library on the In game menus for talking, and I implamented into my game, of course first trying to understand the code. Anyways, back to the main idea. I decided that because the cursor needed to be visible only to the player, I would use a client.image set up. I then used verbs for my movement of the cursor. I set everything for this as such:
//This is cut short, I used verbs that were specified to turfs
//only. And I would change the location based on the verb being used.
//Set up as macros of course.
obj/curser
icon='curser.dmi'
layer=10
New(client/C)
C.screen+=src
Update(C)
proc/Update(client/C)
var/mob/M
for (M in world)
if (!isnull(C) && !isnull(M))
if (M.key == C.key)
if(M.curser==0)
src.icon_state=""
if(M.curser==1)
src.icon_state="1"
if(M.location==0)
src.screen_loc="4,17"
if(M.location==1)
src.screen_loc="4,13"
if(M.location==2)
src.screen_loc="4,9"
if(M.location==3)
src.screen_loc="4,5"
if(M.location==4)
src.screen_loc="4,14"
if(M.location==5)
src.screen_loc="4,12"
if(M.location==6)
src.screen_loc="4,10"
if(M.location==7)
src.screen_loc="4,8"
if(M.location==8)
src.screen_loc="2,10"
...()//That means there is more, in case you don't know.
spawn(1) Update(C)

I want to know is this the best way of moving my cursor, or is there a better way, because it ends up being alot of space.
There's a certain formula involved with some of them, so use that to your advantage. switch() is your friend when comparing many values of the same variable and there's a much easier way to get the mob reference for the client (which is client.mob):
  proc/Update(client/C)
var/mob/M = C.mob
src.icon_state = M.curser==0?"":"1" // Mini-if statement. If curser == 0, then the state is "", otherwise it is "1"
switch(M.location)
if(0 to 3) // If M.location is 0, 1, 2, 3
src.screen_loc="4,[17-(4*M.location)]"
if(4 to 7)
src.screen_loc="4,[14-(2*(M.location-4))]"
if(8)
src.screen_loc="2,10"
else
CRASH("Something is wrong here :(")
In response to GhostAnime
Thanks, That is a neat concept, I cant believe I didn't see think of doing that. lol
In response to Gamekrazzy
A lot of people don't see that. BTW, one thing I forgot to do in that snippet, is that you should call Update() when it actually is needed, not every 1/10th of a second... or at the very least that you should use while() instead of respawning it...
Update(client/C)
if(!istype(C)) return
var/mob/M = C.mob
while(C && M.curser_on)
...
sleep(60)