Package org.luaj.vm2

Examples of org.luaj.vm2.Prototype


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

                    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

    }

    private void fakeWikiBase() {
        // fake http://www.mediawiki.org/wiki/Extension:Wikibase
        final LuaValue mw = globals.get("mw");
        final LuaTable wikibase = new LuaTable();
        wikibase.set("getEntity", new ZeroArgFunction() {
            @Override public LuaValue call() {
                return NIL;
            }
        });
        mw.set("wikibase", wikibase);
View Full Code Here

        }
    }

    @Override
    public LuaTable getInterface() {
        final LuaTable table = new LuaTable();
        table.set("loadPackage", loadPackage());
        table.set("frameExists", frameExists());
        table.set("newChildFrame", newChildFrame());
        table.set("getExpandedArgument", getExpandedArgument());
        table.set("getAllExpandedArguments", getAllExpandedArguments());
        table.set("getFrameTitle", getFrameTitle());
        table.set("expandTemplate", expandTemplate());
        table.set("callParserFunction", callParserFunction());
        table.set("preprocess", preprocess());
        table.set("incrementExpensiveFunctionCount", incrementExpensiveFunctionCount());
        table.set("isSubsting", isSubsting());
        return table;
    }
View Full Code Here

        throw new FileNotFoundException("could not find module " + moduleName);
    }

    @Override
    public LuaValue getSetupOptions() {
        return new LuaTable();
    }
View Full Code Here

TOP

Related Classes of org.luaj.vm2.Prototype

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.