Skip to content

Commit

Permalink
fix db names in scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tjurczyk committed Jul 8, 2024
1 parent 5a4f41f commit 0d8066b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 44 deletions.
10 changes: 5 additions & 5 deletions mapper/localization.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ amap.localization = amap.localization or {
}

amap.localization.db = db:create("roomdescriptions", {
roomDescriptions = {
roomdescriptions = {
room_id = -1,
short = "",
exitDesc = "",
Expand All @@ -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
end
9 changes: 4 additions & 5 deletions skrypty/misc/counter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -56,4 +56,3 @@ function trigger_func_process_kill_for_teammate()
scripts.ui:info_killed_update()
end
end

68 changes: 34 additions & 34 deletions skrypty/misc/counter/counter2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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 = {}

Expand Down Expand Up @@ -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("<grey>+---------------------------------------------------------+\n")
cecho("<grey>| |\n")
Expand Down Expand Up @@ -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 .. "\" "
Expand All @@ -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)

Expand All @@ -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"]
Expand All @@ -252,7 +251,7 @@ function misc.counter2:show_logs(year, month, day)

local kill_date_str = string.sub(kill_date .. " ", 1, 14)


cecho("<grey>|<orange> " .. kill_date_str .. " <grey>" .. text .. "<grey>|\n")
sum = sum + 1
end
Expand All @@ -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

0 comments on commit 0d8066b

Please sign in to comment.