(edit):
WARNING: After testing FeatureScript I have discovered it causes a massive amount of lag. Do not use it for anything other than object initialization.
I wish this weren't the case, but unfortunately I took too many shortcuts in developing this, so it didn't turn out the way I wanted it to turn out
If anyone figures out a way to fix this lag issue feel free to post your own version of FeatureScript, just make sure you credit this as the original source.
What is FeatureScript?
FeatureScript is an interpreted programming language built off of Javascript with the intended purpose of giving Minecraft mod developers the power to allow other people to add content to their mods using code that is run outside of the jar file.
As an added bonus, FeatureScript can also be used with any java application, not just Minecraft, which means that you're able to create games in Java that can be modified by others using FeatureScript code.
To make a java program modifiable, simply create "hooks" into certain FeatureScript methods.
For example: you could have a FeatureScript file called "CustomZombie" with a method called "onTick", and then have java code that calls the "onTick" method!
In the GitHub for FeatureScript, there is a "readme" file that documents how the FeatureScript library works, and how you can use it in your mods/games.
The only limitations of FeatureScript are that it does not completely support for loops, and does not support multi-line code (you can't separate one statement into multiple lines and expect it to work)
Example of Multiline code:
String s =
"hello";
FeatureScript DOES NOT support this
Example of a program written in FeatureScript (this program creates a blue square that moves around on the screen):
script:test {
import javax.swing.JFrame
import java.awt.Graphics
import java.awt.Color
import java.util.Random
import java.awt.Image
setvar frame:new JFrame()
setvar random:new Random()
setvar ball_x:250
setvar ball_y:250
setvar width:500
setvar height:500
setvar dirX:random.nextInt(2) * 2 - 1
setvar dirY:random.nextInt(2) * 2 - 1
function init {
frame = new JFrame();
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
setvar image:frame.createVolatileImage(500, 500);
while (true) {
run tick
setvar g:image.getGraphics();
run render :g
g = frame.getGraphics();
g.drawImage(image, 0, 0, 500, 500, null);
g.dispose();
}
}
function tick {
ball_x += dirX * 5;
ball_y += dirY * 5;
if (ball_x > 500) { dirX = -1 }
if (ball_x < 0) { dirX = 1 }
if (ball_y > 500) { dirY = -1 }
if (ball_y < 0) { dirY = 1 }
}
function render g {
if (g != null) {
g.setColor(Color.WHITE);
g.fillRect(0, 0, 500, 500);
g.setColor(Color.BLUE);
g.fillRect(ball_x, ball_y, 50, 50);
}
}
}