本文整理汇总了Golang中github.com/aarzilli/golua/lua.State.ArgError方法的典型用法代码示例。如果您正苦于以下问题:Golang State.ArgError方法的具体用法?Golang State.ArgError怎么用?Golang State.ArgError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aarzilli/golua/lua.State
的用法示例。
在下文中一共展示了State.ArgError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MessThingTellallMethod
func MessThingTellallMethod(state *lua.State, thing *Thing) int {
state.PushGoFunction(func(state *lua.State) int {
place := checkThing(state, 1)
text := state.CheckString(2)
// If arg 3 is present, it should be a table of Things to exclude.
excludes := make(map[ThingId]bool)
if 2 < state.GetTop() {
if !state.IsTable(3) {
state.ArgError(3, "expected `table` for exclude argument if present")
}
numExcludes := int(state.ObjLen(3))
for i := 0; i < numExcludes; i++ {
state.RawGeti(3, i+1)
exclude := checkThing(state, -1)
excludes[exclude.Id] = true
}
}
for _, content := range place.GetContents() {
if excludes[content.Id] {
continue
}
if content.Client != nil {
content.Client.Send(text)
}
}
return 0
})
return 1
}
示例2: checkThing
func checkThing(state *lua.State, argNum int) *Thing {
userdata := state.CheckUdata(argNum, ThingMetaTableName)
if userdata == nil {
state.ArgError(argNum, "`Thing` expected")
}
var thingPtr *int64
thingPtr = (*int64)(userdata)
thingId := ThingId(*thingPtr)
thing := World.ThingForId(thingId)
if thing == nil {
state.ArgError(argNum, "`Thing` argument is no longer valid")
}
return thing
}
示例3: MessThingFindinsideMethod
func MessThingFindinsideMethod(state *lua.State, thing *Thing) int {
state.PushGoFunction(func(state *lua.State) int {
thing := checkThing(state, 1)
text := state.CheckString(2)
if text == "" {
state.ArgError(2, "cannot find empty string")
}
otherThing := thing.FindInside(text)
if otherThing == nil {
return 0
}
pushValue(state, otherThing.Id)
return 1
})
return 1
}