ID:272542
Sep 6 2008, 3:46 am
|
|
OK, Mob has walk_towards, what does object have to set a course?
|
Sep 6 2008, 3:49 am
|
|
walk_towards()
|
In response to Glarfugus
|
|
Doesn't comply
<code> /obj/wind_up_toy proc Walkme() var/x = rand(1,100) var/y = rand(1,100) var/z = rand(1,2) src.walk_towards(x,y,z) </code> |
In response to World Build
|
|
You're passing three arguments to walk_towards() for a location. Passing three arguments to locate() for a location is just fine, though.
|
In response to World Build
|
|
obj/wind_up_toy How did you expect the obj to walk from Z level to Z level ? <.< Also, you should look up on walk_towards(), like Glarfugus said, it doesn't take 3 location arguments like you did, it takes 1. |
In response to World Build
|
|
It doesn't compile because such a proc doesn't exist, and it wouldn't compile if you attempt to use it on a mob, either. The walk() and step() series procs are global procs, not object procs, therefore you don't run them on any object with the . operator, as shown by others in the example. You're also using wrong arguments, though that wouldn't cause a compile-time error. Look up procs before you use them, check out what arguments are needed for walk_towards() in the DM Reference. If you want to find a turf at specific coordinates, also look up the locate() proc.
|
In response to Andre-g1
|
|
You really shouldn't use such loops that keep calling and starting up new procs over and over (there's extra overhead involved in every call, as well as expanding the call stack), they're just bad and you should use while() or for() instead. Heck, even goto is better (not that you should use it), and also actually somewhat similar if you decide to call the proc by repeating its defined name instead of calling .(), it resembles jumping to a label (only it's less efficient >_>). Also, just an oversight, but locate() with coordinates will always return a turf, why did you define that var as an obj? =P You don't need to define it as a turf either though, or anything for that matter since you're not using any vars/procs.
Note I realize that code is simply an example, but people may learn to follow the bad practices in it. I also saw people using such a loop when they're infinite, which is even worse and will also potentially crash if not pulled off correctly. Hm, but for this topic, such a thing doesn't even warrant an example if you think about it, since just a single call is involved in the basic sense. =P |
In response to Kaioken
|
|
I read in the reference that walk_towards's second argument which is the one we want them to walk to, has to be an object :/
Maybe I misread though. |
In response to Andre-g1
|
|
But, the defined type doesn't mean the var will necessarily contain a reference to that type only, it just affects error checking (mainly) when accessing an object's vars and procs, so it wouldn't make a difference there. Though that was the first argument you probably read about - it has to be either an obj (mind the difference between 'obj' and 'object', BTW) or mob, as only those types can move. The destination can, of course, also be a turf (maybe even an area, but that wouldn't be very useful).
|
In response to Kaioken
|
|
Ah, then I indeed, did misread. Thanks :)
|