Score
0
Watch 4 Star 9 Fork 1

qingfeng346 / Scorpio-JavaJava

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

Scorpio-Java

此脚本为java平台一个轻量级脚本,纯java实现 兼容所有Java平台以及Java语言的引擎 语法类似 javascript

具体脚本示例请前往c#版查看 https://github.com/qingfeng346/Scorpio-CSharp

Scorpio-CSharp的功能会同步更新到java版本

可使用平台:

  • JavaSE
  • JSP
  • Android
  • libGDX
  • 所有使用java语言的平台

注意事项与Scorpio-CSharp版本的差异##

  • 没有generic_method和generic_type函数,因为java下模板是假模版

源码目录说明:

  • Scorpio 脚本引擎项目,平常使用只需导入或引用此目录即可
  • ScorpioExec 跟lua.exe一样,命令行调用Scorpio脚本
  • 源码项目使用ant编译,如需编译jar文件请自行编译build.xml

Scorpio脚本Hello World函数:

package Scorpio;
public class HelloWorld {
	public static class Test { 
		private int a = 100;
		public Test(int a) {
			this.a = a;
		}
		public void Func() {
			System.out.println("Func " + a);
		}
		public static void StaticFunc() {
			System.out.println("StaticFunc");
		}
	}
	public static void main(String[] args) {
		Script script = new Script();		//new一个Script对象
		script.LoadLibrary();								//加载所有Scorpio的库,源码在Library目录下
		script.SetObject("CTest", script.CreateObject(new Test(300)));	//SetObject可以设置一个c#对象到脚本里
		//LoadString 解析一段字符串,LoadString传入的参数就是热更新的文本文件内容
		try {
			script.LoadString("test", "print(\"hello world\")");
			String str = "MyTest = import_type(\"Scorpio.HelloWorld$Test\")		//import_type 要写入类的全路径 要加上命名空间 否则找不到此类,然后赋值给 MyTest 对象\n" +
					"MyTest.StaticFunc()			//调用类的静态函数\n" + 
					"var t = MyTest(200)			//new 一个Test对象, 括号里面是构造函数的参数\n" + 
					"t.Func()					//调用类的内部函数\n" +
					"CTest.Func()				//调用类的内部函数 CTest是通过 script.SetObject 函数设置\n";
			//Scorpio脚本调用c#函数
			script.LoadString("test", str);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Comments ( 1 )

Sign in for post a comment

About

纯Java 实现的一个脚本语言 语法类似javascript spread retract
Cancel

Releases

No release

Gitee Metrics

Contributors

All

Activities

load more
can not load any more