Skip to content

Instantly share code, notes, and snippets.

@moko256
Last active October 16, 2020 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moko256/2e5aa47ffa1bc9e749c1167c526029b1 to your computer and use it in GitHub Desktop.
Save moko256/2e5aa47ffa1bc9e749c1167c526029b1 to your computer and use it in GitHub Desktop.

One-line code for Stormworks function component.

Python -> Stormworks function component

Note:

  • 0/0 seems to be 0.
  • These have some numerical errors.

(1 if x >= 0 else -1) if x != 0 else 0

  • (sgn(x)-sgn(x))/2
  • x/abs(x)

1 if x == 0 else 0

  • (sgn(x)+sgn(x))/2
  • (sgn(-abs(-x))+1)/2
  • 1-x/x

1 if x == t else 0

  • (sgn(x-t)+sgn(-x+t))/2
  • (sgn(-abs(-x+t))+1)/2
  • 1-(x-t)/(x-t)

1 if x >= t else 0

  • max(0,sgn(x-t))
  • (sgn(x-t)+1)/2

Function name -> stormworks function component

compass reading -> 360 degree

  • (1-(x+1)%1)*360

set velocity pivot angle (0-1) (x: target 0-1, y: pivot rotation)

  • (x-y+0.5)-floor(x-y+0.5)-0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment