From 0d8066bede14faf9eddf9c56a28f3bba61dbc643 Mon Sep 17 00:00:00 2001 From: Tomasz Jurczyk Date: Mon, 8 Jul 2024 09:09:26 -0700 Subject: [PATCH] fix db names in scripts --- mapper/localization.lua | 10 ++--- skrypty/misc/counter.lua | 9 ++-- skrypty/misc/counter/counter2.lua | 68 +++++++++++++++---------------- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/mapper/localization.lua b/mapper/localization.lua index b175657f..efa7fab1 100644 --- a/mapper/localization.lua +++ b/mapper/localization.lua @@ -4,7 +4,7 @@ amap.localization = amap.localization or { } amap.localization.db = db:create("roomdescriptions", { - roomDescriptions = { + roomdescriptions = { room_id = -1, short = "", exitDesc = "", @@ -15,12 +15,12 @@ amap.localization.db = db:create("roomdescriptions", { }) function amap.localization:try_to_locate() - local results = db:fetch(self.db.roomDescriptions, db:AND( - db:eq(self.db.roomDescriptions.short, self.current_short), - db:eq(self.db.roomDescriptions.exitDesc, self.current_exit) + local results = db:fetch(self.db.roomdescriptions, db:AND( + db:eq(self.db.roomdescriptions.short, self.current_short), + db:eq(self.db.roomdescriptions.exitDesc, self.current_exit) )) if #results == 1 then amap:set_position(results[1].room_id, true) return true end -end \ No newline at end of file +end diff --git a/skrypty/misc/counter.lua b/skrypty/misc/counter.lua index 9f26cc78..7894684c 100644 --- a/skrypty/misc/counter.lua +++ b/skrypty/misc/counter.lua @@ -6,8 +6,8 @@ misc.counter["all_kills"] = misc.counter["all_kills"] or 0 misc.counter.killed_amount["JA"] = misc.counter.killed_amount["JA"] or 0 -- counter2 -misc.counter2["db_log"] = db:create("counter2log", { - counter2_log = { +misc.counter2["db_log"] = db:create("countertwolog", { + countertwolog = { year = 0, month = 0, day = 0, @@ -19,8 +19,8 @@ misc.counter2["db_log"] = db:create("counter2log", { } }) -misc.counter2["db_daysum"] = db:create("counter2daysum", { - counter2_daysum = { +misc.counter2["db_daysum"] = db:create("countertwo_daysum", { + countertwo_daysum = { year = 0, month = 0, day = 0, @@ -56,4 +56,3 @@ function trigger_func_process_kill_for_teammate() scripts.ui:info_killed_update() end end - diff --git a/skrypty/misc/counter/counter2.lua b/skrypty/misc/counter/counter2.lua index 9115a211..f887d7b3 100644 --- a/skrypty/misc/counter/counter2.lua +++ b/skrypty/misc/counter/counter2.lua @@ -11,7 +11,7 @@ function misc.counter2:add_item(original_text, item) end function misc.counter2:add_log(original_text, year, month, day, hour) - local ret = db:add(misc.counter2.db_log.counter2_log, { + local ret = db:add(misc.counter2.db_log.countertwolog, { year = year, month = month, day = day, @@ -28,18 +28,18 @@ end function misc.counter2:add_sum(item, year, month, day, type) -- first, update for this type this date - local retrieved = db:fetch(misc.counter2.db_daysum.counter2_daysum, + local retrieved = db:fetch(misc.counter2.db_daysum.countertwo_daysum, { - db:eq(misc.counter2.db_daysum.counter2_daysum.year, year), - db:eq(misc.counter2.db_daysum.counter2_daysum.month, month), - db:eq(misc.counter2.db_daysum.counter2_daysum.day, day), - db:eq(misc.counter2.db_daysum.counter2_daysum.character, scripts.character_name), - db:eq(misc.counter2.db_daysum.counter2_daysum.type, type) + db:eq(misc.counter2.db_daysum.countertwo_daysum.year, year), + db:eq(misc.counter2.db_daysum.countertwo_daysum.month, month), + db:eq(misc.counter2.db_daysum.countertwo_daysum.day, day), + db:eq(misc.counter2.db_daysum.countertwo_daysum.character, scripts.character_name), + db:eq(misc.counter2.db_daysum.countertwo_daysum.type, type) }) if not retrieved or table.size(retrieved) == 0 then - local ret = db:add(misc.counter2.db_daysum.counter2_daysum, { + local ret = db:add(misc.counter2.db_daysum.countertwo_daysum, { year = year, month = month, day = day, @@ -51,29 +51,27 @@ function misc.counter2:add_sum(item, year, month, day, type) if not ret then scripts:print_log("Cos poszlo nie tak z zapisem do globalnych zabitych", true) end - elseif table.size(retrieved) == 1 then local update_item = retrieved[1] local count = tonumber(update_item["amount"]) update_item["amount"] = count + 1 - db:update(misc.counter2.db_daysum.counter2_daysum, update_item) - + db:update(misc.counter2.db_daysum.countertwo_daysum, update_item) else scripts:print_log("Cos poszlo nie tak z zapisem do globalnych zabitych", true) return end -- now do 'all' (count for day) - local retrieved = db:fetch(misc.counter2.db_daysum.counter2_daysum, + local retrieved = db:fetch(misc.counter2.db_daysum.countertwo_daysum, { - db:eq(misc.counter2.db_daysum.counter2_daysum.year, year), - db:eq(misc.counter2.db_daysum.counter2_daysum.month, month), - db:eq(misc.counter2.db_daysum.counter2_daysum.day, day), - db:eq(misc.counter2.db_daysum.counter2_daysum.type, "all") + db:eq(misc.counter2.db_daysum.countertwo_daysum.year, year), + db:eq(misc.counter2.db_daysum.countertwo_daysum.month, month), + db:eq(misc.counter2.db_daysum.countertwo_daysum.day, day), + db:eq(misc.counter2.db_daysum.countertwo_daysum.type, "all") }) if not retrieved or table.size(retrieved) == 0 then - local ret = db:add(misc.counter2.db_daysum.counter2_daysum, { + local ret = db:add(misc.counter2.db_daysum.countertwo_daysum, { year = year, month = month, day = day, @@ -89,22 +87,22 @@ function misc.counter2:add_sum(item, year, month, day, type) local update_item = retrieved[1] local count = tonumber(update_item["amount"]) update_item["amount"] = count + 1 - db:update(misc.counter2.db_daysum.counter2_daysum, update_item) + db:update(misc.counter2.db_daysum.countertwo_daysum, update_item) else scripts:print_log("Cos poszlo nie tak z zapisem do globalnych zabitych", true) return end end - function misc.counter2:show_short() if not scripts.character_name then scripts:print_log("Korzystanie z bazy zabitych po ustawieniu 'scripts.character_name' w configu") return end - local sql_query = "SELECT * FROM counter2_daysum WHERE character=\"" .. scripts.character_name .. "\" AND type!=\"all\" ORDER BY _row_id ASC" - local retrieved = db:fetch_sql(misc.counter2.db_daysum.counter2_daysum, sql_query) + local sql_query = "SELECT * FROM countertwo_daysum WHERE character=\"" .. + scripts.character_name .. "\" AND type!=\"all\" ORDER BY _row_id ASC" + local retrieved = db:fetch_sql(misc.counter2.db_daysum.countertwo_daysum, sql_query) local count_dict = {} @@ -148,8 +146,9 @@ function misc.counter2:show_long() return end - local sql_query = "SELECT * FROM counter2_daysum WHERE character=\"" .. scripts.character_name .. "\" AND type!=\"all\" ORDER BY _row_id ASC" - local retrieved = db:fetch_sql(misc.counter2.db_daysum.counter2_daysum, sql_query) + local sql_query = "SELECT * FROM countertwo_daysum WHERE character=\"" .. + scripts.character_name .. "\" AND type!=\"all\" ORDER BY _row_id ASC" + local retrieved = db:fetch_sql(misc.counter2.db_daysum.countertwo_daysum, sql_query) cecho("+---------------------------------------------------------+\n") cecho("| |\n") @@ -206,15 +205,15 @@ function misc.counter2:show_logs(year, month, day) return end - if( (year == '' or year == nil) and (month == '' or month == nil) and (day == '' or day == nil)) then + if ((year == '' or year == nil) and (month == '' or month == nil) and (day == '' or day == nil)) then misc.counter2:show_short() return end - local date = ""..year - local sql_query = "SELECT * FROM counter2_log WHERE character=\"" .. scripts.character_name .. - "\" AND year=\"" .. year .. "\" " - + local date = "" .. year + local sql_query = "SELECT * FROM countertwolog WHERE character=\"" .. scripts.character_name .. + "\" AND year=\"" .. year .. "\" " + if month ~= nil then date = date .. "/" .. month; sql_query = sql_query .. " AND month=\"" .. month .. "\" " @@ -225,7 +224,7 @@ function misc.counter2:show_logs(year, month, day) end sql_query = sql_query .. " ORDER BY _row_id ASC" - local retrieved = db:fetch_sql(misc.counter2.db_log.counter2_log, sql_query) + local retrieved = db:fetch_sql(misc.counter2.db_log.countertwolog, sql_query) local date = string.sub(date .. " ", 1, 11) @@ -242,7 +241,7 @@ function misc.counter2:show_logs(year, month, day) for k, v in pairs(retrieved) do local text = string.sub(v["text"] .. " ", 1, 46) - + local kill_date = ""; if month == nil or day == nil then kill_date = v["month"] .. "/" .. v["day"] .. " " .. v["hour"] @@ -252,7 +251,7 @@ function misc.counter2:show_logs(year, month, day) local kill_date_str = string.sub(kill_date .. " ", 1, 14) - + cecho("| " .. kill_date_str .. " " .. text .. "|\n") sum = sum + 1 end @@ -274,11 +273,12 @@ function misc.counter2:reset() scripts:print_log("Probujesz wykasowac cala baze zabitych, od tego nie ma odwrotu. Aby wykonac, powtorz komende") misc.counter2.retried = true else - db:delete(misc.counter2.db_log.counter2_log, db:eq(misc.counter2.db_log.counter2_log.character, scripts.character_name)) - db:delete(misc.counter2.db_daysum.counter2_daysum, db:eq(misc.counter2.db_daysum.counter2_daysum.character, scripts.character_name)) + db:delete(misc.counter2.db_log.countertwolog, + db:eq(misc.counter2.db_log.countertwolog.character, scripts.character_name)) + db:delete(misc.counter2.db_daysum.countertwo_daysum, + db:eq(misc.counter2.db_daysum.countertwo_daysum.character, scripts.character_name)) scripts:print_log("Ok") end tempTimer(5, function() misc.counter2.retried = nil end) end -