Last active
August 29, 2015 14:25
-
-
Save M4GNV5/383c8187f8caa48cc502 to your computer and use it in GitHub Desktop.
sine rendering in vanilla minecraft using CPL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import("util.command"); | |
import("math"); | |
import("chat.tellraw"); | |
fixed start = math.pi(); | |
start *= -1; //start at -pi | |
fixed stop = math.pi(); //stop at pi | |
for(fixed i = start; i <= stop; i += 0.2) | |
{ | |
fixed result = math.sin(i); | |
tellraw("Sine of ", i, " is ", result); | |
fixed x = i; | |
renderValue(x, result); | |
} | |
function renderValue(fixed x, fixed y) | |
{ | |
command("summon ArmorStand 0 10 0 {CustomName:curr,NoGravity:true,Invisible:true,Equipment:[{},{},{},{},{id:wool,Count:1b}]}"); | |
if(x >= 0) | |
{ | |
while(x >= 1) | |
{ | |
command("tp @e[name=curr] ~1 ~ ~"); | |
x -= 1; | |
} | |
while(x >= 0.1) | |
{ | |
command("tp @e[name=curr] ~0.1 ~ ~"); | |
x -= 0.1; | |
} | |
} | |
else | |
{ | |
while(x <= -1) | |
{ | |
command("tp @e[name=curr] ~-1 ~ ~"); | |
x += 1; | |
} | |
while(x <= -0.1) | |
{ | |
command("tp @e[name=curr] ~-0.1 ~ ~"); | |
x += 0.1; | |
} | |
} | |
if(y >= 0) | |
{ | |
while(y >= 0.1) | |
{ | |
command("tp @e[name=curr] ~ ~0.1 ~"); | |
y -= 0.1; | |
} | |
} | |
else | |
{ | |
while(y <= -0.1) | |
{ | |
command("tp @e[name=curr] ~ ~-0.1 ~"); | |
y += 0.1; | |
} | |
} | |
command("entitydata @e[name=curr] {CustomName:done}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment