:awake
Self CONST_BEAMTARGET 1 SetUnitAttribute
10 20 RandInt 0 do
RandCoords 3 5 RandInt QueueMove
CurrentCoords 20 AddCreeper
loop
self 2 destroy
:destroyed
CurrentCoords SetVoid
CurrentCoords SetCreeper 100
When I try to run it, nothing happens. The core isn't even targeted by beams.
Possibly unrelated, but when I try to load or reload any map containing the script, it freezes on the "calibrating sensors" screen.
:awake only runs when the core is created, that is when another core spawns it or the game is loaded. You should put this in a once block instead of the awake function, or if this is going to be spawned by something and you want it to take effect IMMEDIATLEYUU!!!! you can do this:
once
@awake
endonce
:awake
once
...
endonce
Also, QueueMove does just that -- puts the move in a queue. It doesn't pause the script until the end of the move (only Delay pauses a script), the core simply moves based on the first entry of the queue each frame. So the destroy and addcreeper will occur immediately after it is created rather than after all the moves have completed unless you make it check each frame:
GetQueuedMoveCount eq0 if
self 2 destroy
endif
Of course, having it drop creeper at the end of each move is a bit trickier.
The final script would look like this:
once
@awake
endonce
GetQueuedMoveCount <-segments neq if
GetQueuedMoveCount if
GetQueuedMoveCount ->segments
CurrentCoords 20 AddCreeper
else
Self 2 Destroy
endif
endif
:awake
once
Self CONST_BEAMTARGET 1 SetUnitAttribute
10 20 RandInt ->segments
<-segments 0 do
RandCoords 3 5 RandInt QueueMove
loop
endonce
:destroyed
CurrentCoords SetVoid
CurrentCoords SetCreeper 100
I'm assuming that you're using a radially symmetrical sprite for this so heading has no effect on appearance. Making it appear to turn at each corner is slightly more complex, but not hard.
Wow, thanks! The new script works perfectly.
Okay, now when it gets destroyed the creeper is released on the left edge of the map instead of its current coordinates. I suspect it has something to do with it pulling CurrentCoords after destruction, but the SetVoid works like normal.
Quote from: Asbestos on January 10, 2015, 01:28:18 PM
Okay, now when it gets destroyed the creeper is released on the left edge of the map instead of its current coordinates. I suspect it has something to do with it pulling CurrentCoords after destruction, but the SetVoid works like normal.
CurrentCoords SetCreeper 100
should probably be
CurrentCoords 100 SetCreeper
Self "Custom0" GetImageRotation ->currentRotation
<-currentRotation 0.1 add ->currentRotation
Self "Custom0" <-currentRotation SetImageRotation
10 Delay
This is mostly the code example from the SetImageRotation wiki page, which doesn't work, even though it looks like it should...
First you need to set the image with SetImage. The default image for a core is "main". So...
Self "main" "Custom0" SetImage #This sets the "main" image to Custom0
Then, you'd need to change your example commands to use "main" instead of "Custom0" -- those commands operate on the "image slot" which is a named slot. All cores have a main, and you can add additional images with any name you like.
Technically you could say:
Self "Custom0" "Custom0" SetImage
But that would get confusing and I don't recommend it, as one refers to a particular core's image slot,and the other refers to a custom image slot.
If you aren't using multiple images with your core, stick with "main".
$XCoord:1
$YCoord:1
once
<-XCoord <-YCoord SetCurrentCoords
Self "main" "NONE" SetImage
1800 Delay
Self "NONE" "Custom3" SetImage
DropFromOrbit
90 Delay
11 CurrentCoords 0.01 1 1 1 CreateEffect
Self "Custom3" "Custom4" SetImage
CurrentCoords -100 AddCreeper
endonce
This script doesn't seem to be working either. The core disappears but it doesn't reappear or drop from orbit.
DropFromOrbit requires coordinates.