ID:718574
 
Code:
proc
Spawn(var/obj/Balloons/T,var/Count)
while(Count)

if(T.name=="Red")
var/obj/Balloons/Red/R=new/obj/Balloons/Red
R.loc=locate(/turf/Start)
if(R.Target==null)
for(var/obj/End/A in world)
R.Target=A
walk_towards(R,R.Target,R.Speed,R.Speed)

Count-=1
world<<Count
sleep(10)


Problem description: Whenever I call in walk_towards, it goes threw the density objects. But if I use something else beside that, the balloon won't move at all. Help?

Do your Balloons have a density of 1?
I just made the density=1, and then instead of it running across the map. It didn't move at all.
Is obj/Ballons/Red dense? Also, use walk_to(). This procedure will make the reference walk to the target and it'll take dense obstacles into account. walk_towards makes the reference walk in the direction of the object.
Just as another note, all atoms take a loc argument in their New proc. Therefore, you can shorten your code a bit:
var/obj/Balloons/Red/R =  new /obj/Balloons/Red(locate(/turf/Start))
In response to .screw
.screw wrote:
Is obj/Ballons/Red dense? Also, use walk_to(). This procedure will make the reference walk to the target. walk_towards makes the reference walk in the direction of the object.

The object is dense, and I've tried using walk_to. But, it doens't move :/
In response to Albro1
Albro1 wrote:
Just as another note, all atoms take a loc argument in their New proc. Therefore, you can shorten your code a bit:
> var/obj/Balloons/Red/R =  new /obj/Balloons/Red(locate(/turf/Start))
>


Not to be picky, but you can also do:
var/obj/Ballons/Red/R = new(locate(/turf/Start))

In response to Flysbad
Flysbad wrote:
.screw wrote:
Is obj/Ballons/Red dense? Also, use walk_to(). This procedure will make the reference walk to the target. walk_towards makes the reference walk in the direction of the object.

The object is dense, and I've tried using walk_to. But, it doens't move :/

Did you override Move()?

What do you mean override Move()?
In response to .screw
.screw wrote:
Not to be picky, but you can also do:
var/obj/Ballons/Red/R = new(locate(/turf/Start))



Touche.


Flysbad wrote:
What do you mean override Move()?

He means, did you override the Balloons' default Move() procedure? If you overrode it and did not use ..(), it will cancel it's ability to move.
In response to Flysbad
Flysbad wrote:
What do you mean override Move()?

Silly me.

If you want to use walk_to, you need to find the atom you're looking for and set that as the target. You cannot use a path type.
obj/Move()
return ..()

obj/Balloons
var
Money
Speed=10
Health
Target
icon='Balloons.dmi'
density=1
Red
name="Red"
icon_state="Red"
Money=10


That's my code.... I'm getting confused lol, I don't know how to override Move() nor I don't know what .screw is talking about whenever he says ' you cannot use a path type. You need to find the atom you're looking for, and set that as the target.'
obj/Ballons
var/atom/Target
proc
Spawn(var/obj/Ballons/T, var/Count)
for(Count, Count >1, Count--)
if(T.name == "Red")

var/obj/Ballons/Red/R = new(locate(/turf/Start))
if(!R.Target) // same as R.Target == null
// I am not even sure why you're doing this, but once you get the target, break from the loop
// R.Target will always be null and this statement will always be used
for(var/obj/End/A in world)
R.Target = A
break

walk_to(R, R.Target)
sleep(10)


This is a quick rewrite of your snippet.

Things to know:
1) R.Target will always be null based on your snippet until the if(!R.Target) statement is reached.
I replaced my code, with your code hoping it'd be fixed. It still didn't fix it, for some reason. No matter what, the Balloons will not move for nothing !
In response to Flysbad
Flysbad wrote:
I replaced my code, with your code hoping it'd be fixed. It still didn't fix it, for some reason. No matter what, the Balloons will not move for nothing !

Don't copy and paste code .. its not good practice ...
In response to A.T.H.K
A.T.H.K wrote:
Flysbad wrote:
I replaced my code, with your code hoping it'd be fixed. It still didn't fix it, for some reason. No matter what, the Balloons will not move for nothing !

Don't copy and paste code .. its not good practice ...

Lol, I already know the stuff he typed above. The only reason why my coding is noobish above is because this is a game I'm making due to bordism. I don't feel like making it look good haha.
In response to Flysbad
Hardly an excuse you still copy and pasted if you knew it would you be able to fix it...
In response to A.T.H.K
A.T.H.K wrote:
Hardly an excuse you still copy and pasted if you knew it would you be able to fix it...

I meant, I knew what he was coding. That code he typed above didn't fix the problem either. I copied and pasted because I didn't feel like typing all of that, even thought it would of only took like less then 2minutes.
In response to Flysbad
Flysbad wrote:
Even thought it would of only took like less then 2minutes.

You were right it did take less than two minutes.

Mind displaying your updated procedure?

If you are using walk_to similar to how you used walk_towards: walk_to(R,R.Target,R.Speed,R.Speed), that could explain the problem. By setting the third parameter to R.Speed, you are telling the game to stop the reference's movement within 10 tiles of the target.
Page: 1 2