本文整理匯總了Golang中github.com/aarzilli/golua/lua.State.ToInteger方法的典型用法代碼示例。如果您正苦於以下問題:Golang State.ToInteger方法的具體用法?Golang State.ToInteger怎麽用?Golang State.ToInteger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aarzilli/golua/lua.State
的用法示例。
在下文中一共展示了State.ToInteger方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: apiAudioSetBitrate
func (p *Plugin) apiAudioSetBitrate(l *lua.State) int {
bitrate := l.ToInteger(1)
if enc, ok := p.instance.Client.AudioEncoder.(*opus.Encoder); ok {
enc.SetBitrate(bitrate)
}
return 0
}
示例2: sliceSub
func sliceSub(L *lua.State) int {
slice, _ := valueOfProxy(L, 1)
i1, i2 := L.ToInteger(2), L.ToInteger(3)
newslice := slice.Slice(i1-1, i2)
makeValueProxy(L, newslice, cSLICE_META)
return 1
}
示例3: LuaIntUTCTime
func LuaIntUTCTime(L *lua.State) int {
luaAssertArgnum(L, 1, "utctime()")
timestamp := L.ToInteger(1)
PushTime(L, time.Unix(int64(timestamp), 0))
return 1
}
示例4: apiTimerNew
func (p *Plugin) apiTimerNew(l *lua.State) int {
callback := luar.NewLuaObject(l, 1)
timeout := l.ToInteger(2)
t := &Timer{
cancel: make(chan bool),
}
go func() {
defer func() {
close(t.cancel)
t.cancel = nil
}()
select {
case <-time.After(time.Millisecond * time.Duration(timeout)):
p.callValue(callback)
callback.Close()
case <-t.cancel:
}
}()
obj := luar.NewLuaObjectFromValue(l, t)
obj.Push()
obj.Close()
return 1
}
示例5: slice__newindex
func slice__newindex(L *lua.State) int {
slice, t := valueOfProxy(L, 1)
idx := L.ToInteger(2)
val := LuaToGo(L, t.Elem(), 3)
slice.Index(idx - 1).Set(valueOf(val))
return 0
}
示例6: GetTableInt
func GetTableInt(L *lua.State, name string) int {
// Remember to check stack for 1 extra location
L.PushString(name)
L.GetTable(-2)
r := L.ToInteger(-1)
L.Pop(1)
return r
}
示例7: slice__newindex
func slice__newindex(L *lua.State) int {
slice, t := valueOfProxy(L, 1)
idx := L.ToInteger(2)
val := luaToGoValue(L, t.Elem(), 3)
if idx < 1 || idx > slice.Len() {
RaiseError(L, "slice set: index out of range")
}
slice.Index(idx - 1).Set(val)
return 0
}
示例8: apiAudioNewTarget
func (p *Plugin) apiAudioNewTarget(l *lua.State) int {
id := l.ToInteger(1)
target := &gumble.VoiceTarget{}
target.ID = uint32(id)
obj := luar.NewLuaObjectFromValue(l, target)
obj.Push()
obj.Close()
return 1
}
示例9: LuaIntLocalTime
func LuaIntLocalTime(L *lua.State) int {
luaAssertArgnum(L, 1, "localtime()")
tl := GetTasklistFromLua(L)
timezone := tl.GetTimezone()
timestamp := L.ToInteger(1)
t := time.Unix(int64(timestamp)+(int64(timezone)*60*60), 0)
PushTime(L, t)
return 1
}
示例10: slice__index
func slice__index(L *lua.State) int {
slice, _ := valueOfProxy(L, 1)
if L.IsNumber(2) {
idx := L.ToInteger(2)
if idx < 1 || idx > slice.Len() {
RaiseError(L, "slice get: index out of range")
}
ret := slice.Index(idx - 1)
GoToLua(L, ret.Type(), ret, false)
} else {
RaiseError(L, "slice requires integer index")
}
return 1
}
示例11: slice__index
func slice__index(L *lua.State) int {
slice, _ := valueOfProxy(L, 1)
if L.IsNumber(2) {
idx := L.ToInteger(2)
ret := slice.Index(idx - 1)
GoToLua(L, ret.Type(), ret)
} else {
name := L.ToString(2)
switch name {
case "Slice":
L.PushGoFunction(slice_slice)
default:
fmt.Println("unknown slice method")
}
}
return 1
}
示例12: LuaIntGetterSetterFunctionInt
func LuaIntGetterSetterFunctionInt(fname string, L *lua.State, getter func(tl *Tasklist, entry *Entry) int64, setter func(tl *Tasklist, entry *Entry, value int)) int {
argNum := L.GetTop()
if argNum == 0 {
entry := GetEntryFromLua(L, CURSOR, fname)
tl := GetTasklistFromLua(L)
L.PushInteger(getter(tl, entry))
return 1
} else if argNum == 1 {
value := L.ToInteger(1)
entry := GetEntryFromLua(L, CURSOR, fname)
tl := GetTasklistFromLua(L)
setter(tl, entry, value)
if !tl.luaFlags.cursorCloned {
tl.luaFlags.cursorEdited = true
}
return 0
}
panic(errors.New(fmt.Sprintf("Incorrect number of argoments to %s (only 0 or 1 accepted)", fname)))
return 0
}
示例13: LuaIntSplit
func LuaIntSplit(L *lua.State) int {
if L.GetTop() < 2 {
panic(errors.New("Wrong number of arguments to split()"))
return 0
}
instr := L.ToString(1)
sepstr := L.ToString(2)
n := -1
if L.GetTop() == 3 {
n = L.ToInteger(3)
}
if L.GetTop() > 3 {
panic(errors.New("Wrong number of arguments to split()"))
return 0
}
PushStringVec(L, strings.SplitN(instr, sepstr, n))
return 1
}