本文整理匯總了Java中org.luaj.vm2.LuaValue.isstring方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.isstring方法的具體用法?Java LuaValue.isstring怎麽用?Java LuaValue.isstring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.luaj.vm2.LuaValue
的用法示例。
在下文中一共展示了LuaValue.isstring方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invoke
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
LuaString name = args.checkstring(1);
InputStream is = null;
// get package path
LuaValue path = package_.get(_PATH);
if (!path.isstring())
return valueOf("package.path is not a string");
// get the searchpath function.
Varargs v = package_.get(_SEARCHPATH).invoke(varargsOf(name, path));
// Did we get a result?
if (!v.isstring(1))
return v.arg(2).tostring();
LuaString filename = v.arg1().strvalue();
// Try to load the file.
v = globals.loadfile(filename.tojstring());
if (v.arg1().isfunction())
return LuaValue.varargsOf(v.arg1(), filename);
// report error
return varargsOf(NIL, valueOf("'" + filename + "': " + v.arg(2).tojstring()));
}
示例2: invoke
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
LuaString name = args.checkstring(1);
InputStream is = null;
// get package path
LuaValue path = package_.get(_PATH);
if ( ! path.isstring() )
return valueOf("package.path is not a string");
// get the searchpath function.
Varargs v = package_.get(_SEARCHPATH).invoke(varargsOf(name, path));
// Did we get a result?
if (!v.isstring(1))
return v.arg(2).tostring();
LuaString filename = v.arg1().strvalue();
// Try to load the file.
v = globals.loadfile(filename.tojstring());
if ( v.arg1().isfunction() )
return LuaValue.varargsOf(v.arg1(), filename);
// report error
return varargsOf(NIL, valueOf("'"+filename+"': "+v.arg(2).tojstring()));
}
示例3: luaTableToMap
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
static Map<String, String> luaTableToMap(LuaTable value) {
Map<String, String> params = new HashMap<>();
LuaValue[] keys = value.keys();
for (LuaValue k : keys) {
if (k.isstring()) {
LuaValue v = value.get(k);
if (v.isstring()) {
params.put(k.tojstring(), v.tojstring());
}
}
}
return params;
}
示例4: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public final LuaValue call(LuaValue message) {
if (message.isstring() && mc.player != null) {
mc.player.sendChatMessage(message.tojstring());
return TRUE;
}
return FALSE;
}
示例5: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public LuaValue call(LuaValue event, LuaValue identifier, LuaValue function) {
if (!event.isstring() || !identifier.isstring() || !function.isfunction()) {
return FALSE;
}
LuaHandler.getHandler().getHookManager().add(event.tojstring(), identifier.tojstring(), (LuaFunction) function);
return TRUE;
}
示例6: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public final LuaValue call(LuaValue text, LuaValue x, LuaValue y, LuaValue color) {
if (!text.isstring() || !x.isnumber() || !y.isnumber() || !color.isnumber())
return NIL;
return LuaInteger.valueOf(mc.fontRenderer.drawString(text.tojstring(), x.tofloat(), y.tofloat(), color.toint(), true));
}
示例7: 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());
}
示例8: fromType
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public static Object fromType(LuaValue luaValue) {
if (luaValue.isboolean()) {
return coerce(luaValue, Boolean.class);
}
if (luaValue.isint()) {
return coerce(luaValue, Integer.class);
}
if (luaValue.isnumber()) {
return coerce(luaValue, Double.class);
}
if (luaValue.isstring()) {
return LuaLogger.colorString(luaValue.tojstring());
}
return null;
}
示例9: 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() );
}
示例10: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg1, LuaValue arg2) {
throw arg1.isnil()? new LuaError(null, arg2.optint(1)):
arg1.isstring()? new LuaError(arg1.tojstring(), arg2.optint(1)):
new LuaError(arg1);
}
示例11: _io_input
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs _io_input(LuaValue file) {
infile = file.isnil()? input():
file.isstring()? ioopenfile(FTYPE_NAMED, file.checkjstring(),"r"):
checkfile(file);
return infile;
}
示例12: _io_output
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs _io_output(LuaValue filename) {
outfile = filename.isnil()? output():
filename.isstring()? ioopenfile(FTYPE_NAMED, filename.checkjstring(),"w"):
checkfile(filename);
return outfile;
}
示例13: 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);
}
}
}
}
示例14: call
import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue arg1, LuaValue arg2) {
throw arg1.isnil() ? new LuaError(null, arg2.optint(1)) : arg1.isstring() ? new
LuaError(arg1.tojstring(), arg2.optint(1)) : new LuaError(arg1);
}