当前位置: 首页>>代码示例>>Golang>>正文


Golang State.GetTop方法代码示例

本文整理汇总了Golang中github.com/xenith-studios/golua.State.GetTop方法的典型用法代码示例。如果您正苦于以下问题:Golang State.GetTop方法的具体用法?Golang State.GetTop怎么用?Golang State.GetTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/xenith-studios/golua.State的用法示例。


在下文中一共展示了State.GetTop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: LuaNumParamsOk

func LuaNumParamsOk(L *lua.State, num_params int, name string) bool {
	n := L.GetTop()
	if n != num_params {
		err_str := fmt.Sprintf("%s expects exactly %d parameters, got %d.", name, num_params, n)
		LuaDoError(L, err_str)
		return false
	}
	return true
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:9,代码来源:script_utils.go

示例2: registerUtilityFunctions

// Ripped from game/ai/ai.go - should probably sync up with it
func registerUtilityFunctions(L *lua.State) {
	L.Register("print", func(L *lua.State) int {
		var res string
		n := L.GetTop()
		for i := -n; i < 0; i++ {
			res += LuaStringifyParam(L, i) + " "
		}
		base.Log().Printf("GameScript(%p): %s", L, res)
		return 0
	})
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:12,代码来源:script.go

示例3: LuaCheckParamsOk

func LuaCheckParamsOk(L *lua.State, name string, params ...LuaType) bool {
	fmt.Sprintf("%s(")
	n := L.GetTop()
	if n != len(params) {
		LuaDoError(L, fmt.Sprintf("Got %d parameters to %s.", n, luaMakeSigniature(name, params)))
		return false
	}
	for i := -n; i < 0; i++ {
		ok := false
		switch params[i+n] {
		case LuaInteger:
			ok = L.IsNumber(i)
		case LuaFloat:
			ok = L.IsNumber(i)
		case LuaBoolean:
			ok = L.IsBoolean(i)
		case LuaString:
			ok = L.IsString(i)
		case LuaEntity:
			if L.IsTable(i) {
				L.PushNil()
				for L.Next(i-1) != 0 {
					if L.ToString(-2) == "type" && L.ToString(-1) == "Entity" {
						ok = true
					}
					L.Pop(1)
				}
			}
		case LuaPoint:
			if L.IsTable(i) {
				var x, y bool
				L.PushNil()
				for L.Next(i-1) != 0 {
					if L.ToString(-2) == "X" {
						x = true
					}
					if L.ToString(-2) == "Y" {
						y = true
					}
					L.Pop(1)
				}
				ok = x && y
			}
		case LuaRoom:
			if L.IsTable(i) {
				var floor, room, door bool
				L.PushNil()
				for L.Next(i-1) != 0 {
					switch L.ToString(-2) {
					case "floor":
						floor = true
					case "room":
						room = true
					case "door":
						door = true
					}
					L.Pop(1)
				}
				ok = floor && room && !door
			}
		case LuaDoor:
			if L.IsTable(i) {
				var floor, room, door bool
				L.PushNil()
				for L.Next(i-1) != 0 {
					switch L.ToString(-2) {
					case "floor":
						floor = true
					case "room":
						room = true
					case "door":
						door = true
					}
					L.Pop(1)
				}
				ok = floor && room && door
			}
		case LuaSpawnPoint:
			if L.IsTable(i) {
				L.PushNil()
				for L.Next(i-1) != 0 {
					if L.ToString(-2) == "type" && L.ToString(-1) == "SpawnPoint" {
						ok = true
					}
					L.Pop(1)
				}
			}
		case LuaArray:
			// Make sure that all of the indices 1..length are there, and no others.
			check := make(map[int]int)
			if L.IsTable(i) {
				L.PushNil()
				for L.Next(i-1) != 0 {
					if L.IsNumber(-2) {
						check[L.ToInteger(-2)]++
					} else {
						break
					}
					L.Pop(1)
				}
//.........这里部分代码省略.........
开发者ID:FlyingCar,项目名称:haunts,代码行数:101,代码来源:script_utils.go


注:本文中的github.com/xenith-studios/golua.State.GetTop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。