本文整理匯總了Java中org.luaj.vm2.LuaValue.get方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.get方法的具體用法?Java LuaValue.get怎麽用?Java LuaValue.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.luaj.vm2.LuaValue
的用法示例。
在下文中一共展示了LuaValue.get方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCellClicked
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* 調用 Callback 方法
*
* @param cell
* @param position
* @return
*/
public LuaValue onCellClicked(LuaValue cell, int position) {
final int section = getSectionByPosition(position);
final int row = getRowInSectionByPosition(position);
final String id = getId(position, section, row);
final LuaValue cellData = getCell(id);
if (cellData != null) {
final LuaValue callback = cellData.get("Callback");
if (callback.isfunction()) {
return LuaUtil.callFunction(callback, cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row));
} else if (callback.istable()) {
return LuaUtil.callFunction(LuaUtil.getFunction(callback, "Click", "click"), cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row));
}
}
return NIL;
}
示例2: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/** Perform one-time initialization on the library by creating a table
* containing the library functions, adding that table to the supplied environment,
* adding the table to package.loaded, and returning table as the return value.
* <P>Specifically, adds all library functions that can be implemented directly
* in JSE but not JME: acos, asin, atan, atan2, cosh, exp, log, pow, sinh, and tanh.
* @param modname the module name supplied if this is loaded via 'require'.
* @param env the environment to load into, which must be a Globals instance.
*/
public LuaValue call(LuaValue modname, LuaValue env) {
super.call(modname, env);
LuaValue math = env.get("math");
math.set("acos", new acos());
math.set("asin", new asin());
math.set("atan", new atan());
math.set("atan2", new atan2());
math.set("cosh", new cosh());
math.set("exp", new exp());
math.set("log", new log());
math.set("pow", new pow());
math.set("sinh", new sinh());
math.set("tanh", new tanh());
return math;
}
示例3: getGenericListFromTable
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* Transforming a table of LUA values to a array list of generic data types.
* @param table The table.
* @param mapper The mapper.
* @param <T> The generic type.
* @return The mapped arraylist.
*/
private static <T> ArrayList<T> getGenericListFromTable(LuaValue table, LuaValueMapper<T> mapper) {
ArrayList<T> generics = new ArrayList<T>();
if (!table.isnil() && table.istable()) {
int i = 1;
while (true) {
LuaValue v = table.get(i);
if (v.isnil()) {
break;
}
generics.add(mapper.map(v));
i++;
}
}
return generics;
}
示例4: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue modname, LuaValue env) {
super.call(modname, env);
LuaValue math = env.get("math");
math.set("acos", new acos());
math.set("asin", new asin());
math.set("atan", new atan());
math.set("atan2", new atan2());
math.set("cosh", new cosh());
math.set("exp", new exp());
math.set("log", new log());
math.set("pow", new pow());
math.set("sinh", new sinh());
math.set("tanh", new tanh());
return math;
}
示例5: add_value
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public void add_value(Buffer lbuf, int soffset, int end, LuaValue repl) {
switch (repl.type()) {
case LuaValue.TSTRING:
case LuaValue.TNUMBER:
add_s(lbuf, repl.strvalue(), soffset, end);
return;
case LuaValue.TFUNCTION:
repl = repl.invoke(push_captures(true, soffset, end)).arg1();
break;
case LuaValue.TTABLE:
// Need to call push_onecapture here for the error checking
repl = repl.get(push_onecapture(0, soffset, end));
break;
default:
error("bad argument: string/function/table expected");
return;
}
if (!repl.toboolean()) {
repl = s.substring(soffset, end);
} else if (!repl.isstring()) {
error("invalid replacement value (a " + repl.typename() + ")");
}
lbuf.append(repl.strvalue());
}
示例6: onCellLongClicked
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* 調用 Callback 方法
*
* @param cell
* @param position
* @return
*/
public boolean onCellLongClicked(LuaValue cell, int position) {
final int section = getSectionByPosition(position);
final int row = getRowInSectionByPosition(position);
final String id = getId(position, section, row);
final LuaValue cellData = getCell(id);
if (cellData != null) {
final LuaValue callback = cellData.get("Callback");
if (callback != null && callback.istable()) {
return LuaUtil.callFunction(LuaUtil.getFunction(callback, "LongClick", "longClick"), cell, LuaUtil.toLuaInt(section), LuaUtil.toLuaInt(row)).optboolean(false);
}
}
return false;
}
示例7: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call( LuaValue arg ) {
LuaString name = arg.checkstring();
LuaValue loaded = package_.get(_LOADED);
LuaValue result = loaded.get(name);
if ( result.toboolean() ) {
if ( result == _SENTINEL )
error("loop or previous error loading module '"+name+"'");
return result;
}
/* else must load it; iterate over available loaders */
LuaTable tbl = package_.get(_SEARCHERS).checktable();
StringBuffer sb = new StringBuffer();
Varargs loader = null;
for ( int i=1; true; i++ ) {
LuaValue searcher = tbl.get(i);
if ( searcher.isnil() ) {
error( "module '"+name+"' not found: "+name+sb );
}
/* call loader with module name as argument */
loader = searcher.invoke(name);
if ( loader.isfunction(1) )
break;
if ( loader.isstring(1) )
sb.append( loader.tojstring(1) );
}
// load the module using the loader
loaded.set(name, _SENTINEL);
result = loader.arg1().call(name, loader.arg(2));
if ( ! result.isnil() )
loaded.set( name, result );
else if ( (result = loaded.get(name)) == _SENTINEL )
loaded.set( name, result = LuaValue.TRUE );
return result;
}
示例8: add_value
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public void add_value( Buffer lbuf, int soffset, int end, LuaValue repl ) {
switch ( repl.type() ) {
case LuaValue.TSTRING:
case LuaValue.TNUMBER:
add_s( lbuf, repl.strvalue(), soffset, end );
return;
case LuaValue.TFUNCTION:
repl = repl.invoke( push_captures( true, soffset, end ) ).arg1();
break;
case LuaValue.TTABLE:
// Need to call push_onecapture here for the error checking
repl = repl.get( push_onecapture( 0, soffset, end ) );
break;
default:
error( "bad argument: string/function/table expected" );
return;
}
if ( !repl.toboolean() ) {
repl = s.substring( soffset, end );
} else if ( ! repl.isstring() ) {
error( "invalid replacement value (a "+repl.typename()+")" );
}
lbuf.append( repl.strvalue() );
}
示例9: tableSize
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* Getting the size of a LUA Value table.
* @param table a LUA table.
* @return Size of the table.
*/
public static int tableSize(LuaValue table) {
int i = 1;
if (!table.isnil() && table.istable()) {
while (true) {
LuaValue v = table.get(i);
if (v.isnil()) {
break;
}
i++;
}
}
return i - 1;
}
示例10: initMethods
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public void initMethods() {
for (LuaValue script : mScripts.values()) {
// script.set("ENT", CoerceJavaToLua.coerce(mEntity));
for (Events e : Events.values()) {
try {
System.out.println(e.getEventFunction());
LuaValue fnc = script.get(e.getEventFunction());
if (fnc == LuaValue.NIL) continue;
setEventFunction(e.ordinal(), (LuaFunction) fnc);
} catch (LuaError ex) {
ex.printStackTrace();
}
}
}
}
示例11: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg) {
LuaString name = arg.checkstring();
LuaValue loaded = package_.get(_LOADED);
LuaValue result = loaded.get(name);
if (result.toboolean()) {
if (result == _SENTINEL)
error("loop or previous error loading module '" + name + "'");
return result;
}/* else if (globals != null && (result = globals.lazyLoad(name.checkjstring())) != null){//TODO add by song, 如果是加載自定義的內容則使用globals加載
loaded.set(name, _SENTINEL);
return result;
}*/
/* else must load it; iterate over available loaders */
LuaTable tbl = package_.get(_SEARCHERS).checktable();
StringBuffer sb = new StringBuffer();
Varargs loader = null;
for (int i = 1; true; i++) {
LuaValue searcher = tbl.get(i);
if (searcher.isnil()) {
error("module '" + name + "' not found: " + name + sb);
}
/* call loader with module name as argument */
loader = searcher.invoke(name);
if (loader.isfunction(1))
break;
if (loader.isstring(1))
sb.append(loader.tojstring(1));
}
// load the module using the loader
loaded.set(name, _SENTINEL);
try {
result = loader.arg1().call(name, loader.arg(2));
if (!result.isnil())
loaded.set(name, result);
else if ((result = loaded.get(name)) == _SENTINEL)
loaded.set(name, result = LuaValue.TRUE);
return result;
} catch (Exception e){
LogUtil.e("[PackageLib]", name, "load failed!", e);
return NIL;
}
}
示例12: initSpannableStringBuilder
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
private void initSpannableStringBuilder(LuaValue text, LuaValue config) {
SpannableStringBuilder spannableStringBuilder = getSpannableStringBuilder();
if (text != null && text.isstring()) {
spannableStringBuilder = spannableStringBuilder.append(text.tojstring());
}
if (spannableStringBuilder.length() > 0) {
if (config != null && config.istable()) {
final int end = spannableStringBuilder.length();
final int fontSize = DimenUtil.spToPx(config.get("fontSize").optint(-1));
final Integer fontColor = ColorUtil.parse(LuaUtil.getValue(config, "fontColor"));
final String fontName = config.get("fontName").optjstring(null);
final LuaValue weightValue = config.get("fontWeight");
final int fontWeight = LuaUtil.isNumber(weightValue) ? weightValue.optint(UDFontWeight.WEIGHT_NORMAL_INT) : UDFontWeight.getValue(weightValue.optjstring(UDFontWeight.WEIGHT_NORMAL));
final LuaValue styleValue = config.get("fontStyle");
final int fontStyle = LuaUtil.isNumber(styleValue) ? styleValue.optint(Typeface.NORMAL) : UDFontStyle.getValue(styleValue.optjstring(UDFontStyle.STYLE_NORMAL));
final Integer backgroundColor = ColorUtil.parse(LuaUtil.getValue(config, "backgroundColor"));
final boolean strikethrough = config.get("strikethrough").optboolean(false);
final boolean underline = config.get("underline").optboolean(false);
if (fontSize != -1) {//字體大小
spannableStringBuilder.setSpan(new AbsoluteSizeSpan(fontSize), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (fontColor != null) {//字體顏色
spannableStringBuilder.setSpan(new ForegroundColorSpan(fontColor), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (fontName != null && getLuaResourceFinder() != null) {//字體
spannableStringBuilder.setSpan(new CustomTypefaceSpan(fontName, getLuaResourceFinder().findTypeface(fontName)), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (fontWeight != -1 && fontWeight > UDFontWeight.WEIGHT_NORMAL_INT) {//文字Weight
spannableStringBuilder.setSpan(new WeightStyleSpan(fontWeight), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (fontStyle != -1 && (fontStyle >= Typeface.NORMAL && fontStyle <= Typeface.BOLD_ITALIC)) {//文字樣式
spannableStringBuilder.setSpan(new StyleSpan(fontStyle), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (backgroundColor != null) {//背景色
spannableStringBuilder.setSpan(new BackgroundColorSpan(backgroundColor), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (strikethrough) {//刪除線
spannableStringBuilder.setSpan(new StrikethroughSpan(), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (underline) {//下劃線
spannableStringBuilder.setSpan(new UnderlineSpan(), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
}
}
示例13: hasCellFunction
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
* 是否有某個函數
*
* @param cellId
* @param method
* @return
*/
public boolean hasCellFunction(String cellId, String method) {
final LuaValue methodData = getCell(cellId);
return !methodData.isnil() && methodData.get(method) != null && methodData.get(method).isfunction();
}