Guide:Arbitrary Entity Manipulation
What is Arbitrary Entity Manipulation?
Some examples of what Arbitrary Entity Manipulation can do are changing entity states, changing their colors, or disabling their collision checks. This guide will focus on changing sprites.
Select the entity
First, you have to select the entity and there's two methods to achieve it. The first method is by targeting an entity by their index. The second method is targeting the next entity which gets spawned. Both of these methods have their own benefits and flaws, so it's good to know both so you can pick what's best for you.
Targeting an entity by index
Every entity in a room has an index. It starts at 0, and increases with every entity which gets created. For example, Viridian is always 0, because they always exist. If you place a checkpoint down in an empty room, that will have the index of 1. If you place another one, that'll be 2. If you spawn an enemy through a script after, that'll be 3. Think of entities as if they're in a huge list, where newer entities get added to the end. The index is how far from the start the entity is. Since Viridian is at the start, they're 0 entities away.
Using fakecommands, you can target an entity by ID with the
:target(x) command, which can only be used inside internal scripts. However, you can NOT target entity 0 or 1 this way.
If you don't want to use a Ved plugin, what you can do instead is type it out manually. What the
:target(x) fake command does is create an instantly-closing textbox with a line count of
x. So to target entity 2, you can do the following:
text(cyan,0,0,2) # The 2 is what matters here! # # backgroundtext speak endtextfast
The reason why an
x value lower than 2 does not work is a bit complex to explain. The variable which gets used as the Arbitrary Entity Manipulation target is only set if the textbox has more than 1 line, because the target variable is used to do a loop.
To get around this restriction, place a terminal underneath the roomname as your first entity in the room. The terminal itself will be off screen.
Targeting the next entity
This method is using
everybodysad(), but this only works for entities created after a script runs, as long as you don't reload the room. This targets the next entity to be created.
everybodysad createentity(40,40,1,4,0) # Create your entity AFTER everybodysad gets called! changemood(player,0) # Make Viridian happy again, since we made everybody sad!
The reason this targets the NEXT entity to be created is because it sets the target to the current entity count, which is one index after the last spawned entity. Creating a new entity will then fill the slot which the target variable currently points to.
The reason this works is because
everybodysad loops through all entities in the room using the target variable.
Manipulating the entity
Now that you've targeted the entity, you will need to use a command which normally targets a crewmate. Meaning, a command which can take a crewmate color as an argument. For this guide, we'll continue focusing on changing the entity's sprite, but experiment with different commands as much as you want.
changetile(target,value) changes the sprite that the crewmate uses. Instead of inputting a crewmate color, or
player, we'll put something that VVVVVV doesn't expect -- anything else.
Most people use
changetile(#,value), but you can feel free to input what you'd like.
Calling the command will change the sprite of the entity you targeted. For example, the following script will create an enemy, then change it to look like the unused hourglass/bowtie enemy.
# First, target the next entity that spawns. everybodysad # Create the entity. createentity(40,40,1,4,0) # Change their sprite, changetile(#,92) # and reset Viridian's mood. changemood(player,0)