ID:141916
 
Code:
obj
snow
mid12
name = "Cockpit"
density = 1
layer = MOB_LAYER-1
icon = 'snow.dmi'
icon_state = "mid1"
Click()
if(usr.flying == 1)
usr << "<b>You are already flying a plane!"
return
else
usr.flying = 1
usr.loc = locate(src.x,src.y,src.z)
usr.icon_state = "above"
usr.overlays += /obj/snow/lwing2
usr.overlays += /obj/snow/rwing2
usr.overlays += /obj/snow/top2
usr.overlays += /obj/snow/bottom2
usr.overlays += /obj/snow/mid22
usr.overlays += /obj/snow/mid32
usr.density = 0
usr.rundelay = 0
usr.health = 300
usr.mhealth = 300
usr.verbs += new/mob/verb/shoot
usr.verbs += new/mob/verb/shootm
usr << "You currently have 5 missles left."
usr.flying()
mob
proc
flying()
set background = 1
serp
if(src.flying == 1)
walk(src,dir)
if(src.flying == 0)
return
goto serp
mob
Move()
if(src.frozen||src.moving)
return
src.moving = 1
..()
sleep(src.rundelay)
src.moving = 0


Problem description: I'm trying to make it so i can get in the plane and fly around in it... well i can get that much done but when your in the plane and its using the flying proc it doesn't let me turn the plane.. at all! and then if i shoot a bullet it gets behind me somehow... which either means i made the plane too fast for the bullets or somehow i messed that up but can you help with making the plane turn please? i tried everything i can think of o.o

SadoSoldier wrote:
Code:
> mob
> proc
> flying()
> set background = 1
> serp
> if(src.flying == 1)
> walk(src,dir)
> if(src.flying == 0)
> return
> goto serp
>



I'm guessing that the problem is in there. First, not having to do with your problem but something to fix anyways is the use of goto. You don't need to use goto there. A while loop could go there instead. You can either do while(1), and have the rest of the code remain unchanged, or better yet, while(flying). Then both of those if() statements become unnecessary and the code looks much cleaner and should be easier to maintain.

Concerning the problem you're having, the loop you've set up never sleeps. It's constantly calling walk(src,dir) and never leaves time for any other kind of movement to happen. After replacing goto with while(), try adding a call to sleep(). sleep(1) would have the plane wait 1 tick (0.1 seconds) between moves: increase the sleep time if it moves too fast or you find the plane still unresponsive.
In response to Jon88
If he's going to loop the call every few ticks, he should use step() instead of walk(), and only that way the rate of movement is actually decided by the sleep() (probably just slipped past you). Then he should also ditch the 'set background', so it doesn't sleep more, unexpectedly.
In response to Kaioken
mob
proc
flying()
if(src.flying == 1)
step(src,dir)
sleep(1)
while(flying)
else
return


Is that what you mean? because i don't ever use while and thus im not good at it.. I'm guessing thats not what you mean because it keeps saying invalid expression for the else clause o.o
In response to Mr Death126
something has to be underneath of 'while'. Everything tabbed out beneath 'while' is effected by it.
In response to Speedro
Thanks very much to all of you, for the while(flying) idea, the step idea, and the instructions to put while above the code i needed to be in while o.o but thanks to you all i got it to work thx ^.^