My code is as follows:
Code: Select all
crits = db:create("oxide_crits",
{
count = {
type = "",
count = 0,
_unique = { "type" },
_violations = "IGNORE",
}
}
)
function RegisterHit(type)
echo("Counting hit: "..type)
db:set(crits.count.count, db:exp("count + 1"), db:eq(crits.count.type, type))
end
function LoadDefaults()
db:add(crits.count,
{ type = "normal", count = 0 },
{ type = "CRITICAL", count = 0 },
{ type = "CRUSHING CRITICAL", count = 0 },
{ type = "OBLITERATING CRITICAL", count = 0 },
{ type = "ANNIHILATINGLY POWERFUL CRITICAL", count = 0 },
{ type = "WORLD-SHATTERING CRITICAL", count = 0 }
)
end
-- We are ignoring unique key violations, so lets setup the default state here
oxide.crits:LoadDefaults()
Code: Select all
[ERROR:] object:<Hit trigger> function:<Trigger34>
<...Documents and Settings/***/.config/mudlet/db.lua:750: attempt to index global 'sheet' (a nil value)>
Code: Select all
function db:set(field, value, query)
local db_name = sheet._db_name -- HERE
local s_name = sheet._sht_name
local conn = db.__conn[db_name]