Need help with "Taking item from empty stack"

Started by Creator, March 28, 2017, 07:21:29 PM

Previous topic - Next topic

Creator


READ NO FURTHER
Taking item from empty stack is caused by wrong notation!



I am trying to make The Vortex Device, a super weapon that makes a black hole that destroys creeper, anticreeper, and enemy structures.

I have 4 problems:
1.(For Device, script#1) WARNING: Taking item from an empty stack:IF at line 36,35,37
2.(For vortex, script#2) The vortex does not destroy anticreeper
3.(For vortex, script#2) The vortex does not die, it does not stop damaging and pulling creeper
4.(For vortex, script#2) It instantly destroys enemy structures rather than gradually.
Even though I am very good at CRPL, I am not perfect. But here is the code:

# vortex.crpl Why is this here?
# Created on: 3/28/2017 9:22:29 AM
# ------------------------------------------
# Device.crpl
# Created on: 3/28/2017 9:22:21 AM
# ------------------------------------------
once
#Trace spams me with a warning about an empty stack.
ShowTraceLog
   SetUnitAttribute(self CONST_ISBUILDING TRUE)
   SetUnitAttribute(self CONST_CANREQUESTAMMO TRUE)
   SetUnitAttribute(self CONST_MAXAMMO 1000)
   SetUnitAttribute(self CONST_BUILDCOST 5)
   SetUnitAttribute(self CONST_CONNECTABLE TRUE)
   SetUnitAttribute(self CONST_REQUESTPACKETS TRUE)
   SetUnitAttribute(self CONST_PACKETREQUESTDELAY 5)
   SetUnitAttribute(self CONST_MAXHEALTH 1)
   SetUnitAttribute(self CONST_HEALTH 100)
   SetUnitAttribute(self CONST_CREATEPZ FALSE)
   SetUnitAttribute(self CONST_NULLIFIERDAMAGES FALSE)
   SetUnitAttribute(self CONST_COUNTSFORVICTORY FALSE)
   SetUnitAttribute(self CONST_DESTROYONDAMAGE FALSE)
   SetUnitAttribute(self CONST_NULLIFIERDAMAGES FALSE)
   SetUnitAttribute(self CONST_SNIPERTARGET FALSE)
   SetUnitAttribute(self CONST_SUPPORTSDIGITALIS FALSE)
   FALSE ->IsBuilt
endonce
not(GetUnitAttribute(self CONST_ISBUILDING))
not(<-IsBuilt)
if (and)
once
1 ->Built
endonce
ceil(GetUnitAttribute(self CONST_AMMO)) ->stuff
if GetUnitAttribute(self CONST_MAXAMMO) <-stuff gte
#Below is the troublemaker. It takes an item from an empty stack.
if (GetMouseButtonDown(0))
GetMousePosition PixelToCell ->y ->x
if (GetMouseButtonDown(0))
"CRPLCORE" <-x <-y CreateUnit ->Child
<-Child "vortex" AddScriptToUnit
<-Child "main" "Custom0_256" SetImage
endif
endif
endif
endif


# vortex.crpl
# Created on: 3/28/2017 9:22:29 AM
# ------------------------------------------
once
ShowTraceLog
   SetUnitAttribute(self CONST_ISBUILDING FALSE)
   SetUnitAttribute(self CONST_CANREQUESTAMMO FALSE)
   SetUnitAttribute(self CONST_CONNECTABLE FALSE)
   SetUnitAttribute(self CONST_REQUESTPACKETS FALSE)
   SetUnitAttribute(self CONST_PACKETREQUESTDELAY 5)
   SetUnitAttribute(self CONST_MAXHEALTH 100)
   SetUnitAttribute(self CONST_HEALTH 100)
   SetUnitAttribute(self CONST_CREATEPZ FALSE)
   SetUnitAttribute(self CONST_NULLIFIERDAMAGES FALSE)
   SetUnitAttribute(self CONST_COUNTSFORVICTORY FALSE)
   SetUnitAttribute(self CONST_DESTROYONDAMAGE FALSE)
   SetUnitAttribute(self CONST_NULLIFIERDAMAGES FALSE)
   SetUnitAttribute(self CONST_SNIPERTARGET FALSE)
   SetUnitAttribute(self CONST_SUPPORTSDIGITALIS FALSE)
endonce
EnableTowerField(300 -100000000 -10000000 0 TRUE)
   Damage(Self 0.1)
do (GetEnemyUnitsInRange(CurrentCoords 10) 0)
   ->unitUID
   Damage(<-unitUID 0.00002)
loop
DamageCreeper(CurrentCoords 9999 1 1000000 FALSE)
:destroyed
DisableTowerField Trace
-Creator

GoodMorning

A few flaws...

ceil(GetUnitAttribute(self CONST_AMMO)) ->stuff
if GetUnitAttribute(self CONST_MAXAMMO) <-stuff gte


This "if" is missing warp notation after it, causing the empty stack error.

The vortex.crpl script sets CONST_DESTROYONDAMAGE to false. Then you damage it, but never explicitly destroy it. So it is not destroyed.

DamageCreeper I have not used, but understood that it leaves AC alone. You might like to substitute "CurrentCoords 0 SetCreeper" for this function.

If anything is OperateWhilePaused-enabled, then destroyed, there is a bug which may be causing the vortex to operate while paused.

I hope this helps.
A narrative is a lightly-marked path to another reality.

Creator

-Creator