ID:151160
 
I'm looking for how to make it so an object moves in a pre-assigned area, example:
mob_walk
left, left, right,down

this won't work of course, but do you get the basic idea?
Thanks,
Gilser
This is untested, but it should be close, anyway...

In this example, the chicken would walk straight two spaces, then turn 45 degrees to the left and take another step, then repeat the cycle, to move in an octagonal pattern.

mob
chicken
var/list/movePattern

New()
movePattern = list(0, 0, 45)
spawn PatternWalk()

proc/PatternWalk()
while(src)
for(var/turnAngle in movePattern)
dir = turn(dir, turnAngle)
step(src, dir)
sleep(4)
In response to Guy T.
I'm trying to make a bus that people can board and get off of, will this code allow me to make it so the bus goes from one place to another, freezes (sleeps?) for a certain amount of time, then goes again. Will this work on turfs too? Another thing I'm worried about is the space turfs that have a density of 1, would that stop it from moving or anything? The bus(well, space shuttle I guess) will be moving over them so will it override them as it goes over them?
Thanks,
Gilser
In response to Gilser
I'm trying to make a bus that people can board and get off of, will this code allow me to make it so the bus goes from one place to another, freezes (sleeps?) for a certain amount of time, then goes again.

This probably isn't the best code snippet to use, then. If the bus ran into any obstructions, it would end up going off the path.


Will this work on turfs too?

Turfs can't move around like mobs and objs can.


Another thing I'm worried about is the space turfs that have a density of 1, would that stop it from moving or anything? The bus(well, space shuttle I guess) will be moving over them so will it override them as it goes over them?

It takes some work to overcome the awful density of space. You may be too young to remember the tragic Challenger explosion that resulted from inadequate "space grease" to cut through the primordial carbon Jell-O outside our atmosphere--but I digress.

One way to kill two birds with one stone would be to create a subclass of the space turf, called bus_path or something like that. This would allow you to do two things:

1) You can override "Enter" to permit buses to enter.
2) You can draw a path of these turfs and force the bus to follow it (you might even be able to get away with using walk_rand or step_rand to make it follow the path, assuming the path has "walls" of space surrounding it).