plugin

package
v0.0.0-...-f7fb57a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2019 License: BSD-3-Clause Imports: 25 Imported by: 0

README

plugin GoDoc

Usage

local plugin = require("plugin")
local time = require("time")

local plugin_body = [[
    local time = require("time")
    local i = 1
    while true do
        print(i)
        i = i + 1
        time.sleep(1)
    end
]]

-- plugin.do_string(body)
local print_plugin = plugin.do_string(plugin_body)
print_plugin:run()
time.sleep(2)
print_plugin:stop()
time.sleep(1)

local running = print_plugin:is_running()
if running then error("already running") end

-- also you can use: plugin.do_file(filename)

Documentation

Overview

Package plugin implements run lua-code from lua-code.

Example (Package)

plugin.do_string(), plugin_ud:run(), plugin_ud:stop()

state := lua.NewState()
Preload(state)
time.Preload(state)
source := `
    local plugin = require("plugin")
    local time = require("time")

    local plugin_body = [[
        local time = require("time")
        local i = 1
        while true do
            print(i)
            i = i + 1
            time.sleep(1)
        end
    ]]

    local print_plugin = plugin.do_string(plugin_body)
    print_plugin:run()
    time.sleep(2)
    print_plugin:stop()
    time.sleep(1)

    local running = print_plugin:is_running()
    if running then error("already running") end

`
if err := state.DoString(source); err != nil {
	log.Fatal(err.Error())
}
Output:

1
2

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoFile

func DoFile(L *lua.LState) int

DoFile(): lua plugin.do_file(filename) returns plugin_ud

func DoString

func DoString(L *lua.LState) int

DoString(): lua plugin.do_string(body) returns plugin_ud

func Error

func Error(L *lua.LState) int

Error(): lua plugin_ud:error() returns err

func IsRunning

func IsRunning(L *lua.LState) int

IsRunning(): lua plugin_ud:is_running()

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func NewPluginState

func NewPluginState() *lua.LState

NewPluginState return lua state for plugin

func Preload

func Preload(L *lua.LState)

Preload adds plugin to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:

local plugin = require("plugin")

func Run

func Run(L *lua.LState) int

Run(): lua plugin_ud:run()

func Stop

func Stop(L *lua.LState) int

Stop(): lua plugin_ud:stop()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL