User Tools

Site Tools


cw4:cursor_magnet

This is a quick and lazy cursor magnet, easily switchable from attract to repel.

$radius:4
$mult:1 #1 is full push, -1 is full pull
 
GetPointerTerrainCoords ->z ->x
do(<-z <-radius + 1 + <-z <-radius -)
 do(<-x <-radius + 1 + <-x <-radius -)
  V2(I <-x - J <-z -) ->direction
  Normalize(<-direction) ->direction
  <-direction GetCreeper(i j) mul 1000000 mul <-mult mul ->flowVec
  SetFlow(i j <-flowVec.x <-flowVec.y)
 loop
loop

At the default radius of 4, it affects every tile in a 7×7 area centered on the cursor. It pushes or pulls in a straight line from the center, and is full strength all the way to the edge. It's power is based on the amount of creeper, so a mult of 1 is the maximum amount of push, regardless of creeper quantity.

It is not extremely performant, so a large radius should be avoided to prevent lag.

cw4/cursor_magnet.txt · Last modified: 2021/03/31 12:50 by durikkan