User Tools

Site Tools


crpl:docs:iscreeperinrange

<- CRPL reference <- Creeper Commands

IsCreeperInRange

ArgumentsResultNotation
int x, int y, int range, int threshold, bool lessThan, bool square, bool AC ansber x y r t lt s ac – b4

Description

Checks if there is creeper in range of the x,y coordinates, threshold parameter defines the minimal amount of creeper to be found, while square command switches between a square and a circle area of searching. AC parameter defines if anti-creeper is searched for.

GetCreeper returns a float value, but threshold is an integer. So, to test for a creeper level of 1.0, you'd use a threshold of 1,000,000.

Examples

$powerLineUnitX:84
$powerLineUnitY:81

$beamUnitX:84
$beamUnitY:63

$initialDelay:0

once
	GetUnitAt(<-powerLineUnitX <-powerLineUnitY) ->powerLineUID
	GetUnitAt(<-beamUnitX <-beamUnitY) ->beamUID
endonce


if (not(<-alreadyDelayed) and (<-initialDelay gt(0)))
	Delay(<-initialDelay)
	TRUE ->alreadyDelayed
endif

@ActivatePowerPlant(not(IsCreeperInRange(CurrentX CurrentY 5 1 FALSE TRUE FALSE)))


:ActivatePowerPlant
	->activate
	if (<-activate and (not(<-active)))
		TRUE ->active
		SetImageColor(Self "Main" 255 255 255 255)
		SetImageColor(<-powerLineUID "Main" 0 255 0 255)
		SetScriptVar(<-beamUID "BeamWeapon.crpl" "enabled" TRUE)
		PlaySound("Misc15")
	else if (not(<-activate) and (<-active))	
		FALSE ->active
		SetImageColor(Self "Main" 255 128 200 255)
		SetImageColor(<-powerLineUID "Main" 255 0 0 255)
		SetScriptVar(<-beamUID "BeamWeapon.crpl" "enabled" FALSE)
		PlaySound("Misc27")
	endif endif
crpl/docs/iscreeperinrange.txt · Last modified: 2015/03/19 07:55 by warren