本文整理汇总了Java中org.luaj.vm2.Globals.set方法的典型用法代码示例。如果您正苦于以下问题:Java Globals.set方法的具体用法?Java Globals.set怎么用?Java Globals.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.luaj.vm2.Globals
的用法示例。
在下文中一共展示了Globals.set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAllTo
import org.luaj.vm2.Globals; //导入方法依赖的package包/类
/**
* Set all key-value pairs to lua globals
*/
public void setAllTo(Globals globals) {
for (Map.Entry<String, Object> entry : entrySet()) {
final Object value = entry.getValue();
if (value instanceof Integer) {
globals.set(entry.getKey(), (Integer) entry.getValue());
} else if (value instanceof Long) {
globals.set(entry.getKey(), (Long) entry.getValue());
} else if (value instanceof Float) {
globals.set(entry.getKey(), (Float) entry.getValue());
} else if (value instanceof Double) {
globals.set(entry.getKey(), (Double) entry.getValue());
} else if (value instanceof String) {
globals.set(entry.getKey(), (String) entry.getValue());
} else if (value instanceof Byte) {
globals.set(entry.getKey(), (Byte) entry.getValue());
} else if (value instanceof Boolean) {
globals.set(entry.getKey(), (Boolean) entry.getValue() ? LuaValue.TRUE : LuaValue.FALSE);
}
}
}
示例2: main
import org.luaj.vm2.Globals; //导入方法依赖的package包/类
public static void main(String[] args) {
Globals globals = JsePlatform.debugGlobals();
globals.set("Core", new LuaTable());
globals.get("Core").set("createEntityTemplate", new CreateEntityTemplate());
globals.get("Core").set("invoke", new Invoke());
globals.get("Core").set("destroy", new CreateEntityTemplate());
ScriptableComponent cmp = new ScriptableComponent();
File scripts = new File("scripts/");
List<File> files = getFilesRec(scripts);
for (File f : files) {
if (f.getName().equals("autorun.lua")) globals.loadfile(f.getAbsolutePath()).call();
}
// cmp.initMethods();
// cmp.awake();
// cmp.setEnabled(true);
// cmp.executeMethod(Events.CollisionEnter);
}
示例3: luaMain
import org.luaj.vm2.Globals; //导入方法依赖的package包/类
/** Simple wrapper for invoking a lua function with command line arguments.
* The supplied function is first given a new Globals object,
* then the program is run with arguments.
*/
public static void luaMain(LuaValue mainChunk, String[] args) {
Globals g = standardGlobals();
int n = args.length;
LuaValue[] vargs = new LuaValue[args.length];
for (int i = 0; i < n; ++i)
vargs[i] = LuaValue.valueOf(args[i]);
LuaValue arg = LuaValue.listOf(vargs);
arg.set("n", n);
g.set("arg", arg);
mainChunk.initupvalue1(g);
mainChunk.invoke(LuaValue.varargsOf(vargs));
}
示例4: getLocalCompiler
import org.luaj.vm2.Globals; //导入方法依赖的package包/类
private Globals getLocalCompiler() {
Globals user_globals = new Globals();
user_globals.load(new JseBaseLib());
user_globals.load(new PackageLib());
user_globals.load(new Bit32Lib());
user_globals.load(new TableLib());
user_globals.load(new StringLib());
user_globals.load(new JseMathLib());
user_globals.load(new DebugLib());
sethook = user_globals.get("debug").get("sethook");
user_globals.set("debug", LuaValue.NIL);
return user_globals;
}
示例5: luaMain
import org.luaj.vm2.Globals; //导入方法依赖的package包/类
/**
* Simple wrapper for invoking a lua function with command line arguments.
* The supplied function is first given a new Globals object,
* then the program is run with arguments.
*/
public static void luaMain(LuaValue mainChunk, String[] args) {
Globals g = standardGlobals();
int n = args.length;
LuaValue[] vargs = new LuaValue[args.length];
for (int i = 0; i < n; ++i)
vargs[i] = LuaValue.valueOf(args[i]);
LuaValue arg = LuaValue.listOf(vargs);
arg.set("n", n);
g.set("arg", arg);
mainChunk.initupvalue1(g);
mainChunk.invoke(LuaValue.varargsOf(vargs));
}
示例6: setAllTo
import org.luaj.vm2.Globals; //导入方法依赖的package包/类
/**
* Set all key-value pairs to lua globals
*/
public void setAllTo(Globals globals) {
globals.set("ID", id);
globals.set("NAME", name);
globals.set("TYPE", type);
globals.set("VERSION", version);
globals.set("ENTRY", entry);
globals.set("DEBUG", debug ? LuaValue.TRUE : LuaValue.FALSE);
userConfig.setAllTo(globals);
}
示例7: luaMain
import org.luaj.vm2.Globals; //导入方法依赖的package包/类
/** Simple wrapper for invoking a lua function with command line arguments.
* The supplied function is first given a new Globals object,
* then the program is run with arguments.
*/
public static void luaMain(LuaValue mainChunk, String[] args) {
Globals g = standardGlobals();
int n = args.length;
LuaValue[] vargs = new LuaValue[args.length];
for (int i = 0; i < n; ++i)
vargs[i] = LuaValue.valueOf(args[i]);
LuaValue arg = LuaValue.listOf(vargs);
arg.set("n", n);
g.set("arg", arg);
mainChunk.initupvalue1(g);
mainChunk.invoke(LuaValue.varargsOf(vargs));
}