Trailed Icons

by Konlet
Need to have icons follow one another?
ID:1892007
 
For help with lists, refer to this tutorial.
What happens when a mob teleports from one location to another?
When their parent moves, the child goes to the parent. The z-value of children does NOT automatically update to their parent's.
In response to Konlet
Exactly, seems like something you should fix. Also, it won't update if the player teleports from their house to their friend's house which is 50 tiles away for example. In that case they've got a long way to walk.

Definitely seems like you need to fix that.
In response to Zecronious
When the parent's z-value changes, children now update to parent's the new location entirely.

Zecronious wrote:
Also, it won't update if the player teleports from their house to their friend's house which is 50 tiles away for example. In that case they've got a long way to walk.

Definitely seems like you need to fix that.


This library uses step_towards() rather than step_to() or walk_to(). Having children teleport entirely to the lastpos variable will create unnecessary CPU usage. If you'd like to incorporate that, feel free, though I will not be including that in the vanilla source.
In response to Zecronious
I can see a few ways to handle teleportation:

1. The pieces follow the head into the portal. This might actually work in this demo already, as long as the tail is teleported the same as the head.

2. The whole body is transported, all at once, and every bit is stacked on the same tile. This is relatively easy; just iterate through every follower and teleport it to the same target tile.

3. The whole body is transported, all at once. The body retains its shape. This is slightly more complicated because you'd have to copy over the positions of each part relative to something else that gets transported (e.g. the head). You also have to decide which part ends up on the target tile: the head, the tail (if multiple, which tail?), or something in between?

Konlet could decide to implement one or more of these. However, I wouldn't consider it a bug that "needs fixing". This demo appears to be functionally complete in everything it demonstrates, so the teleporter would just be something that the developer could have to consider on their own.
In response to Konlet
unnecessary CPU usage

You can do that without changing step_towards and without adding extra CPU usage.
Add a teleportChild(newLoc) method that can be called whenever it's needed (hence no extra CPU usage unless you need it) and when it's called it will also call the teleportChild(newLoc) method of the child.

By altering newLoc you could have them all teleport to the same position (shape) or have them all teleport to the location of the main parent where they'll begin following again.
I'm just saying this because I almost know for certain a bunch of people will use this for pets and then get mad when they can't use teleports.
In response to Zecronious
I've added a modifiable variable called TELEPORT_MODE in the demo. If you'd like children to update location by teleportation, simply enable it.
In response to Konlet
Awesome man :)