func (a *Module) loadWhere(L *lua.LState) int { account := &models.Account{} a.Connection.Bind("accounts", account) whereQuery := L.ToString(1) err := a.Connection.LoadWhere(whereQuery) if err != nil { L.Push(lua.LBool(false)) return 1 } accountTable := general.ParseStruct(account) L.Push(accountTable) return 1 }
func (a *Module) update(L *lua.LState) int { accountLuaTable := L.ToTable(1) account := parseTable(accountLuaTable) a.Connection.Bind("accounts", account) err := a.Connection.Update() if err != nil { L.Push(lua.LBool(false)) return 1 } accountTable := general.ParseStruct(account) L.Push(accountTable) return 1 }
func (c *Module) load(L *lua.LState) int { characterLuaTable := L.ToTable(1) character := parseTable(characterLuaTable) c.Connection.Bind("players", character) err := c.Connection.Load() if err != nil { L.Push(lua.LBool(false)) return 1 } characterTable := general.ParseStruct(character) L.Push(characterTable) return 1 }
func (c *Module) characterDeaths(L *lua.LState) int { name := L.ToString(1) deaths, err := models.GetCharacterDeaths(name) if err != nil { L.Push(lua.LString(err.Error())) L.Push(lua.LNil) return 2 } deathList := &lua.LTable{} for _, val := range deaths { t := general.ParseStruct(val) deathList.Append(t) } L.Push(lua.LBool(true)) L.Push(deathList) return 2 }
func (a *Module) isLogged(L *lua.LState) int { logged := a.Session.GetValue("logged") if logged != "true" { L.Push(lua.LBool(false)) return 1 } tkn := a.Session.GetValue("token") if tkn == nil { L.Push(lua.LBool(false)) return 1 } account := models.GetAccountByToken(tkn.(string)) if account.Name == "" { L.Push(lua.LBool(false)) return 1 } accountTable := general.ParseStruct(account) L.Push(accountTable) return 1 }