ID:172316
 
Hello all. I want my Boats to move at a speed, determined on "Sail", and I want them to move constantly. I put together :

mob/Boats
Move(New, Dir = 0)
if(Sailing)
..()
var/lags = 10-src.Sail
walk(src,src.dir,lags)
else
return ..(New, Dir)


When they log on, Sailing is set to 1. This works okay, though it has one problem. If they hold down a direction, it completely ignores the lag! Thank you for your time!

~Ease~
Just have a proc to constantly move them forward, and have Move() change the direction.
Untested, but this should work:

<code>var/sail_delay = 10 mob/boat var/sailing = 1 var/speed = 0 // plus 10 delay proc/Sail(dir) if(sailing) sailing = 0 return sailing = 1 while(sailing) step(src, src.dir) sleep(speed - sail_delay)</code>

This way, if you set the arrow keys to change direction, and you have the center key run the Sail() proc, then if the ship is moving, it'll stop moving, but if it isn't moving, it will start moving. It will also stop moving whenever its sailing var is set to 0, so if you want it to stop whenever it bumps something, for example, just set sailing to 0.
In response to Foomer
Thank you very much, but I had just finished doing it myself before I came on the forums =P Thank you though!

~Ease~