Package org.luaj.vm2

Examples of org.luaj.vm2.LocVars


import java.io.IOException;

public class ModuleExecutor {
    public String run(IWikiModel model, String module, String method, Frame frame) throws IOException {
        final Globals globals = getGlobals();
        MwCommon common = new MwCommon(model, globals);
        return common.execute(module, method, frame);
    }
View Full Code Here


        MwCommon common = new MwCommon(model, globals);
        return common.execute(module, method, frame);
    }

    private Globals getGlobals() {
        final Globals globals = JsePlatform.standardGlobals();
//        LuaJC.install(globals);
        return globals;
    }
View Full Code Here

    for (i = 0; i < n; i++)
      dumpInt(f.lineinfo[i]);
    n = (strip) ? 0 : f.locvars.length;
    dumpInt(n);
    for (i = 0; i < n; i++) {
      LocVars lvi = f.locvars[i];
      dumpString(lvi.varname);
      dumpInt(lvi.startpc);
      dumpInt(lvi.endpc);
    }
    n = (strip) ? 0 : f.upvalues.length;
View Full Code Here

  int registerlocalvar(LuaString varname) {
    FuncState fs = this.fs;
    Prototype f = fs.f;
    if (f.locvars == null || fs.nlocvars + 1 > f.locvars.length)
      f.locvars = LuaC.realloc( f.locvars, fs.nlocvars*2+1 );
    f.locvars[fs.nlocvars] = new LocVars(varname,0,0);
    return fs.nlocvars++;
  }
View Full Code Here

    if (packageLib.loaded.get(packageName).toboolean()) {
      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    packageLib.loaded.set(packageName, globals);
  }
View Full Code Here

                    defaultAnimationName = animationName; // set first animation as the default one
                }
            }
            catch (SpriteException ex) {
                // Error in the input file.
                throw new LuaError(ex);
            }
            catch (Exception ex) {
                // Error in the editor.
                ex.printStackTrace();
                throw new LuaError(ex);
            }

            return LuaValue.NIL;
        }
View Full Code Here

            LuaC.install();
            LuaTable environment = LuaValue.tableOf();

            environment.set("animation", new AnimationFunction());

            LuaFunction code = LoadState.load(new FileInputStream(spriteFile),
                spriteFile.getName(), environment);
            code.call();
        }
        catch (IOException ex) {
            throw new SpriteException(ex.getMessage());
        }
        catch (LuaError ex) {
View Full Code Here

                    if (!param.get("raw").isnil()) {
                        actualParam = param.get("raw").checkjstring();
                    } else if (!param.get("num").isnil()) {
                        if (param.get("num").isnumber()) {
                            LuaNumber number = param.get("num").checknumber();
                            NumberFormat nf = NumberFormat.getInstance(Locale.forLanguageTag(lang));
                            actualParam = nf.format(number.todouble());
                        } else {
                            actualParam = param.get("num").tojstring();
                        }
                    } else {
                        actualParam = "unknown";
View Full Code Here

        try {
            this.animations = new TreeMap<String, SpriteAnimation>();
            File spriteFile = Project.getSpriteFile(animationSetId);
            LuaC.install();
            LuaTable environment = LuaValue.tableOf();

            environment.set("animation", new AnimationFunction());

            LuaFunction code = LoadState.load(new FileInputStream(spriteFile),
                spriteFile.getName(), environment);
            code.call();
        }
View Full Code Here

        @Override
        public LuaValue call(LuaValue arg) {

            try {
                LuaTable table = arg.checktable();

                String animationName = table.get("name").checkjstring();
                String srcImageName = table.get("src_image").checkjstring();
                int frameDelay = table.get("frame_delay").optint(0);
                int frameToLoopOn = table.get("frame_to_loop_on").optint(-1);
                LuaTable directionsTable = table.get("directions").checktable();

                BufferedImage srcImage = null;

                try {
                    if (!srcImageName.equals("tileset")) {
                        srcImage = Project.getProjectImage("sprites/" + srcImageName);
                    }
                    else if (!tilesetId.isEmpty()) {
                        srcImage = Project.getProjectImage(
                                "tilesets/" + Project.getTilesetEntitiesImageFile(tilesetId).getName());
                    }
                } catch (IOException ex) {
                    // image cannot be loaded
                }

                Vector<SpriteAnimationDirection> directions = new Vector<SpriteAnimationDirection>();

                // Traverse the directions table.
                LuaValue key = LuaValue.NIL;
                while (true) {

                    Varargs keyValue = directionsTable.next(key);
                    key = keyValue.arg1();
                    if (key.isnil()) {
                        break;
                    }
                    LuaValue directionTable = keyValue.arg(2);
View Full Code Here

TOP

Related Classes of org.luaj.vm2.LocVars

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.