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 }