Theo's map after #1898: The Timer. By: theo

Started by theo, March 28, 2015, 09:57:56 AM

Previous topic - Next topic

theo

If you want it to appear faster then help me with my crpl, the fire freeze script is ready so I attached it here. It is named messages because it will also show messages, but everything inside the if(fireFreeze) is the fire freeze script, also it will contain corrupted units and a unit that can corrupt normal units.
Also, I made some scripts that should shot bullets, but I made the script so big that I can't find what does not work in it, I'm not goig to tell you it's name but I think you can figure out what it's suppoposed to represent. The map will also involve my Subspace Slip Artificial Anti Emitters. If you fix my script please tell me what didn't work. The Aether Transmitter does not shot bullets and those bullets do almost no damage to the creeper.

warren

fix: DamageCreeper(CurrentCoords 20 20 <-creeperAmount 1000000 mul 0)

theo

The bullet works but I don't understand what's the problem with the Aether Transmitter, it does not shot bullets, it requests ammo and rotates it's image but it doesn't shoot anything. Can you help me?

warren

You are testing for a lot of stuff. If the code were indented, maybe I could figure out what you are trying to test for. As it is, you have an eq that needs a second argument. Try using ShowTraceLog. and TraceStack to inspect the stack. and "hello" Trace to see if the fire function is arrived at.

theo

The Aether Transmitter works now. Thanks you for the help. Now all I have to do is make the Bad Aether Transmitter. That one will do something once you go near it. I didn't start working on it yet but I'll start now. Thanks you.   

teknotiss

Quote from: theo on March 29, 2015, 05:07:26 AM
The Aether Transmitter works now. Thanks you for the help. Now all I have to do is make the Bad Aether Transmitter. That one will do something once you go near it. I didn't start working on it yet but I'll start now. Thanks you.

theo and warren, can you take all of these codes and copy them to a thread in the coders corner please?
we try to keep all the scripts centralised so people don't have to search these threads
cheers dudes!  8)
"Is God willing to prevent evil, but not able? Then he is not omnipotent.... Is he able, but not willing? Then he is malevolent.... Is he both able and willing? Then whence cometh evil?.... Is he neither able nor willing? Then why call him God?" --- Epicurus

theo

#6
Sure, how will the thread be named?
EDIT: Someone moved this thread in the coder's corner.

theo

I need help with a script. It does nothing. It is supposed to destroy all totems and start corrupting shields, relays and beams once units get in it's range. On the tracelog it says that it exceeds that maximum number of loops per frame or something like that.

warren

Yep, infinite loop. The first one I have ever seen in CRPL. (while TRUE repeat) Is a perfectly legal structure, if you have a break or return in the body somewhere. The reason why all the examples have loops that look like (<yada yada> GetAllunitsInRange 0 do) is because doing the same thing differently is a complicated proposition. Thar's yor problem. Try adding (if break endif) to the end of your loop, (and neq0 => eq0).

theo

Now it destroys the totems but it doesn't shoot bullets that corrupt units.

thegamemaster1234

#10
I hope all this stuff isn't an April Fools joke (that'd be dumb). Anyhow, to be blunt, your code looks absolutely terrible.
Here's some tips:

  • Always indent once when starting a code block (if statement, loop, etc).
  • Use comments to document your code, so you always know what stuff is when you look at it later. (and so other coders don't have to figure it out themselves)
  • Put empty lines between different sections of code.
  • Never, never, NEVER use an infinite loop.
Also, the reason why your code isn't working is because you forgot to have enabled and the timer checked for their appropriate boolean values. So this:
<-enabled GetTimer0 if
should be this:
<-enabled 1 eq GetTimer0 eq0 and if
This checks if "enabled" is equal to 1, and if timer 0 is 0, then starts doing things if both are true. Never forget your logic operators.

As for the infinite loop, here's an alternative that looks way better:

CurrentCoords 9999999 1 GetAllUnitsInRange do
     ->unit
     GetUnitType(<-unit) ->unitType

     if(<-unitType "TOTEM" eq)
          <-unit 2 Destroy
     endif
loop


Information on the problems with the bullet script in the spoiler below. Note that I did not actually test the script, I was just looking at it.
Spoiler


  • You're trying to access "target" in the bullet script, but you sent it "unit" instead. As it is, "target" will be 0, and your bullet will try to aim at 0,0 - every time. Because there normally is no unit 0. And if there is a unit 0 for any reason, it'll always target that. All of the other problems here are supposing that this problem is fixed.
  • If the beam or shield were moved from its position at the time the bullet was fired, it'll still be destroyed, and a corrupted unit will appear where the unit used to be, even though it obviously missed.
  • The bullet will play the explosion sound twice on impact. That is, if it actually destroys itself. (see below)
  • You're telling the bullet to not take map space twice. Redundant.
  • The bullet is required for victory. Whether you want it that way or not is your choice.
  • The bullet will still try to destroy the unit even if it no longer exists. If a newer unit has taken that UID (I don't know if this happens or not) then it will be destroyed, regardless of location or type.
  • When the bullet's self-destruct is activated, it will error because there is no given UID to destroy (call Self to get the bullet's own UID)
  • If the bullet is supposed to create a Corrupt Shield, it will error because it was not given a unit type to create. (forgot a CurrentCoords "CRPLCORE" in your CreateUnit call)
  • Another infinite loop (in the firing script).
[close]

theo

Quote from: thegamemaster1234 on April 05, 2015, 11:54:24 PM
I hope all this stuff isn't an April Fools joke (that'd be dumb). Anyhow, to be blunt, your code looks absolutely terrible.
Here's some tips:

  • Always indent once when starting a code block (if statement, loop, etc).
  • Use comments to document your code, so you always know what stuff is when you look at it later. (and so other coders don't have to figure it out themselves)
  • Put empty lines between different sections of code.
  • Never, never, NEVER use an infinite loop.
Also, the reason why your code isn't working is because you forgot to have enabled and the timer checked for their appropriate boolean values. So this:
<-enabled GetTimer0 if
should be this:
<-enabled 1 eq GetTimer0 eq0 and if
This checks if "enabled" is equal to 1, and if timer 0 is 0, then starts doing things if both are true. Never forget your logic operators.

As for the infinite loop, here's an alternative that looks way better:

CurrentCoords 9999999 1 GetAllUnitsInRange do
     ->unit
     GetUnitType(<-unit) ->unitType

     if(<-unitType "TOTEM" eq)
          <-unit 2 Destroy
     endif
loop


Information on the problems with the bullet script in the spoiler below. Note that I did not actually test the script, I was just looking at it.
Spoiler


  • You're trying to access "target" in the bullet script, but you sent it "unit" instead. As it is, "target" will be 0, and your bullet will try to aim at 0,0 - every time. Because there normally is no unit 0. And if there is a unit 0 for any reason, it'll always target that. All of the other problems here are supposing that this problem is fixed.
  • If the beam or shield were moved from its position at the time the bullet was fired, it'll still be destroyed, and a corrupted unit will appear where the unit used to be, even though it obviously missed.
  • The bullet will play the explosion sound twice on impact. That is, if it actually destroys itself. (see below)
  • You're telling the bullet to not take map space twice. Redundant.
  • The bullet is required for victory. Whether you want it that way or not is your choice.
  • The bullet will still try to destroy the unit even if it no longer exists. If a newer unit has taken that UID (I don't know if this happens or not) then it will be destroyed, regardless of location or type.
  • When the bullet's self-destruct is activated, it will error because there is no given UID to destroy (call Self to get the bullet's own UID)
  • If the bullet is supposed to create a Corrupt Shield, it will error because it was not given a unit type to create. (forgot a CurrentCoords "CRPLCORE" in your CreateUnit call)
  • Another infinite loop (in the firing script).
[close]
I already fixed that, but I didn't notice the bug with moving units. I'll add a location check to the shield... YOU CAN'T MOVE A RELAY!
Also, I removed targeting beams, they're required to destroy the bullet.