Documentation ¶
Index ¶
- Constants
- Variables
- func LogDebugf(L *lua.LState) int
- type Config
- type GameController
- type Interpreter
- func (ip *Interpreter) AddCustomLoader(ld filesystem.Loader)
- func (ip *Interpreter) DoFile(file string) error
- func (ip Interpreter) DoString(src string) error
- func (ip Interpreter) EraCall(vname string) error
- func (ip Interpreter) EraCallBool(vname string) (bool, error)
- func (ip Interpreter) EraCallBoolArgInt(func_name string, arg int64) (bool, error)
- func (ip Interpreter) HasEraValue(vname string) bool
- func (ip *Interpreter) LoadDataOnSandbox(file, dataKey string) (map[string]string, error)
- func (ip Interpreter) LoadSystem() error
- func (ip Interpreter) PathOf(file string) string
- func (ip *Interpreter) Quit()
- func (ip *Interpreter) RemoveCustomLoader(ld filesystem.Loader)
- func (ip Interpreter) SetContext(ctx context.Context)
Constants ¶
const ( // non-error but requires quiting the application. ScriptQuitMessage = "# EXIT NORMALY #" // non-error but interrupts script execution. ScriptLongReturnMessage = "# LONG RETURN #" // non-error but requires quiting current scene flow and starts next scene. ScriptGoToNextSceneMessage = "# GOTO NEXT SCENE #" )
const ( // Maximum integer number to maintain accuracy in Interpreter. // Since log10(MaxInteger) = 15.95..., // a number upto 10^15 is completely supported, and // upto 10^16 is partialy supported. MaxInteger = (1 << 53) - 1 // Maximum number in Interpreter. MaxNumber = math.MaxFloat64 )
const (
// era functions are included in this module.
EraModuleName = "era"
)
Variables ¶
var ( // default paramters for script VM. LoadPattern = "init.lua" CallStackSize = lua.CallStackSize RegistrySize = lua.RegistrySize )
Functions ¶
func LogDebugf ¶
func LogDebugf(L *lua.LState) int
+gendoc * log.debugf(fmt_string, [any...])
Debugレベルで、fmt_stringをログファイルに出力します。 fmt_string中の特殊文字(例えば、%v)は、anyで置き換えられます。 特殊文字の詳細は、Golangのfmtパッケージを参照 (https://godoc.org/fmt)。 この関数はデバッグモード時のみ動作します。
Types ¶
type Config ¶
type Config struct { LoadDir string LoadPattern string CallStackSize int RegistrySize int IncludeGoStackTrace bool }
ScriptConfig holds Script parameters.
type GameController ¶
type GameController interface { scene.IOController // scene controll // // do multiple trains defined by commands. DoTrainsScene(commands []int64) error // starting scene of loading game data. DoLoadGameScene() error // starting scene of saving game data. DoSaveGameScene() error // set next scene specified by its name. SetNextSceneByName(name string) error // register new scene flow using its name and the function desclibeing its flow. // next_func must return next scene name to move to next flow. RegisterSceneFunc(name string, next_func func() (string, error)) // remove registered scene specified name. UnRegisterScene(name string) }
game controller controlls game flow, input, output, ... etc.
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
Interpreter parse script files. it runs user script in the strict environment.
typical usage:
ip := NewInterpreter(...) defer ip.Quit()
func NewInterpreter ¶
func NewInterpreter(s *state.GameState, g GameController, config Config) *Interpreter
construct interpreter. must be call Interpreter.Quit after use this.
func (*Interpreter) AddCustomLoader ¶ added in v0.5.0
func (ip *Interpreter) AddCustomLoader(ld filesystem.Loader)
func (*Interpreter) DoFile ¶
func (ip *Interpreter) DoFile(file string) error
do given script on internal VM.
func (Interpreter) DoString ¶
func (ip Interpreter) DoString(src string) error
DoString runs given src text as script.
func (Interpreter) EraCall ¶
func (ip Interpreter) EraCall(vname string) error
call funtion vname in era module.
func (Interpreter) EraCallBool ¶
func (ip Interpreter) EraCallBool(vname string) (bool, error)
call funtion vname in era module and return a bool value.
func (Interpreter) EraCallBoolArgInt ¶
func (ip Interpreter) EraCallBoolArgInt(func_name string, arg int64) (bool, error)
call funtion vname in era module with argument int64, and return a bool value. To cover all range of int, argument requires int64
func (Interpreter) HasEraValue ¶
func (ip Interpreter) HasEraValue(vname string) bool
VM has given value name in era module?
func (*Interpreter) LoadDataOnSandbox ¶ added in v0.3.0
func (ip *Interpreter) LoadDataOnSandbox(file, dataKey string) (map[string]string, error)
do given script file on internal VM with sandbox environment. Return data table queried by the dataKey.
func (Interpreter) LoadSystem ¶
func (ip Interpreter) LoadSystem() error
load all files matched to config pattern. it is used for loading user scirpts under specified directory.
func (Interpreter) PathOf ¶
func (ip Interpreter) PathOf(file string) string
return Path of Under Script Dir
func (*Interpreter) Quit ¶
func (ip *Interpreter) Quit()
Quit quits virtual machine in Interpreter. use it for releasing resources.
func (*Interpreter) RemoveCustomLoader ¶ added in v0.5.0
func (ip *Interpreter) RemoveCustomLoader(ld filesystem.Loader)
func (Interpreter) SetContext ¶
func (ip Interpreter) SetContext(ctx context.Context)
set context to internal virtual machine. context must not be nil.