This isn't working

Started by ShadowDragon7015, May 28, 2013, 09:57:53 PM

Previous topic - Next topic

ShadowDragon7015

CurrentCoords -10 AddCreeper
Delay 10
CurrentCoords 10 AddCreeper
Delay 10
SetTerrain
91 185 2
CurrentCoords -10 AddCreeper
Delay 10
CurrentCoords 10 AddCreeper
Delay 10
SetTerrain
88 188 2
CurrentCoords -10 AddCreeper
Delay 10
CurrentCoords 10 AddCreeper
Delay 10
SetTerrain
94 188 2
CurrentCoords -10 AddCreeper
Delay 10
CurrentCoords 10 AddCreeper
Delay 10
SetTerrain
91 191 2
CurrentCoords -10 AddCreeper
Delay 10
CurrentCoords 10 AddCreeper
Delay 10
SetVoid
91 185
CurrentCoords -10 AddCreeper
Delay 10
CurrentCoords 10 AddCreeper
Delay 10
SetVoid
88 188
CurrentCoords -10 AddCreeper
Delay 10
CurrentCoords 10 AddCreeper
Delay 10
SetVoid
94 188
CurrentCoords -10 AddCreeper
Delay 10
CurrentCoords 10 AddCreeper
Delay 10
SetVoid
91 191

I'm having trouble with this making the terrain move up and down all it does now is raise the terrain to level 10 in 3 of the 4 spots
Hiding the golden creeper for years to come.

J

You have to put up the arguments first.
So instead of:
Delay 10
SetTerrain
91 185 2

You'll have to write:
10 Delay
91 185 2 SetTerrain

Hope that helps

Molay

So, I modified it a bit.
First, I added a function for the repetitive part (the setcreeper part) to make the code a bit clearer.
Second, I used the warp operator. By the structure of your code, it looks like you're more familiar with the non-reverse notations, and the warp operator works very well for that :)

Overall, the code should be much smaller now and much easier to look at.

# ShadowDragon1.crpl
# Created on: 5/29/2013 2:06:17 PM
# Created by: ShadowDragon7015
# ---------------------------------

@spawnCreeper
SetTerrain(91 185 2)
@spawnCreeper
SetTerrain(88 188 2)
@spawnCreeper
SetTerrain(94 188 2)
@spawnCreeper
SetTerrain(91 191 2)
@spawnCreeper
SetVoid(91 185)
@spawnCreeper
SetVoid(88 188)
@spawnCreeper
SetVoid(94 188)
@spawnCreeper
SetVoid(91 191)

:spawnCreeper
CurrentCoords -10 AddCreeper
Delay(10)
CurrentCoords 10 AddCreeper
Delay(10)


It looks pretty cool when you put the creeplecore in the middle of the terraforming, kinda like a little factory of sorts. Neat stuff :)

ShadowDragon7015

Thanks Molay it worked perfectly!
Hiding the golden creeper for years to come.

ShadowDragon7015

i need to make this smaller and make it possible to change the variables multiple times in one CRPL core please help
$X:154
$Y:253
$RANGE:3
$UNITTYPE:"RELAY"
$DESTROYTYPE:2

@KillUnitsInRange(<-X <-Y <-RANGE <-UNITTYPE <-DESTROYTYPE)

# Usage @KillUnitsInRange(x y range "UNITTYPE" destroyType)
:KillUnitsInRange
   ->destroyType
   ->unitType
   ->range
   ->y
   ->x
   do (GetUnitsInRange(<-x <-y <-range) 0)
      ->unitUID
      if (GetUnitType(<-unitUID) eq(<-unitType))
         Destroy(<-unitUID <-destroyType)
      endif
   loop
Hiding the golden creeper for years to come.

knucracker

You can add the same script to a single core more than once.  So if you just need to target two ranges on the map, or two unit types in the same location, you can just add the Killer.crpl script to a core twice then configure it differently for each one (without changing any of the code).

Now if you are wanting to kill different unit types (say 4 different things) in the same range, then it would be more efficient to modify the code to take a list of unit types to destroy.  This could be done by adding  $UNITTYPE2, $UNITTYPE3, $UNITTYPE4, etc. variables and checking for any of them in the 'if' that's inside GetUnitsInRange.  Or you could ask me to add a string 'split' function to CRPL so you could put all of the items in one variable and separate them with spaces.  Or you could ask me to add array support to CRPL and the editor, so you could add them as an array of data.

Or, if you just want to get it done, copy and paste the 'if' clause inside GetUnitsInRange and type in each unit type that you want to kill.


ShadowDragon7015

Can you add an array so it takes multiple units and multiple coordinates?
Hiding the golden creeper for years to come.

knucracker

So you want to nuke some number of units (by type) in more than one range?

If that is the case it would better to loop through all units on the map and do the range calculations and type checking in that one loop.  GetUnitsInRange is going to be the expensive call, so you only want to do that once.  Just do it at coords 0,0 with a range of like 9999.  That will get all units on the map.  Then you can check the type of each unit and the range of each unit and destroy as appropriate.

Unfortunately, I'm not going to take the 15 minutes it would take to write that for you since I've got a full plate already.  But you already have examples of all of the requires API's necessary to do this.

ShadowDragon7015

i want to kill units that get put on certain spots throughout the map
Hiding the golden creeper for years to come.

knucracker

How many spots and are the spots just single coordinates (no range necessary)?  Are you wanting to kill any player unit, or only units of certain types.  If certain types, how many?

ShadowDragon7015

set single spots and i want to kill relays and collectors on those spots
Hiding the golden creeper for years to come.

knucracker

If somebody builds a relay one cell to the right of one of your spots, what should happen?  Note that units take up 3x3 areas.

ShadowDragon7015

i want to prevent them from putting them on powerzones.  8)
Hiding the golden creeper for years to come.

knucracker

Ok, so your actual requirement for your map is:
- Prevent the player from building collectors and relays on power zones.

That means you would like to 'destroy' the unit before it is even built, correct?  Else the player would waste time building a relay only to have it blow up.

In the next build I have added a 'GetUnitAt' call that will return a unit at any coordinates you specify.  It will return any unit, even if it is building.  Unfortunately, it only returns one unit.  So stacked units (like a unit on a power zone) means you would get unpredictable results.

The GetUnitsInRange calls only return units that are built.

You need a more fundamental API that returns all units regardless of state, then you need to check to see if any collectors or relays overlap any power zones.  That would work but what a pain.

An IsOverPowerZone call would be nice in this case.  So you'd want something like this to work:

do (GetAllUnitsInRange(0 0 999) 0)
      ->unitUID
      GetUnitType(<-unitUID) ->unitType
      if (<-unitType eq("COLLECTOR) or (<-unitType eq("RELAY")))
         if (IsOverPowerZone(<-unitUID))
            Destroy(<-unitUID 0)
         endif
      endif
loop


ShadowDragon7015

If the IsOverPowerZone function existed that would work perfectly, yes.
Hiding the golden creeper for years to come.