• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X SOLUTION "attempt to call field 'getResult' (a nil value)"

Svira

Active Member
Joined
Jan 27, 2008
Messages
267
Solutions
11
Reaction score
36
Hello, I decided to come back to the tfs 0.4 fun
I was struggling a few days with the error in the topic, saw hundreds of posts from 2010 to 2020 WITHOUT a solution!

I decided to add a solution here, maybe I'll have this problem again someday, so it's worth writing it down somewhere!

Error:
[0:29:54.796] [Error - TalkAction Interface]
[0:29:54.796] data/talkactions/scripts/frags.lua:eek:nSay
[0:29:54.796] Description:
[0:29:54.796] data/talkactions/scripts/frags.lua:14: attempt to call field 'getResult' (a nil value)
[0:29:54.796] stack traceback:
[0:29:54.796] data/talkactions/scripts/frags.lua:14: in function <data/talkactions/scripts/frags.lua:6>

Solution:
Add in data/lib/004-database.lua
Lua:
if(result == nil) then
    print("> WARNING: Couldn't load database lib.")
    return
end

Result = createClass(nil)
Result:setAttributes({
    id = -1,
    query = ""
})

function Result:getID()
    return self.id
end

function Result:setID(_id)
    self.id = _id
end

function Result:getQuery()
    return self.query
end

function Result:setQuery(_query)
    self.query = _query
end

function Result:create(_query)
    self:setQuery(_query)
    local _id = db.storeQuery(self:getQuery())
    if(_id) then
        self:setID(_id)
    end

    return self:getID()
end

function Result:getRows(free)
    local free = free or false
    if(self:getID() == -1) then
        error("[Result:getRows] Result not set!")
    end

    local c = 0
    repeat
        c = c + 1
    until not self:next()

    local _query = self:getQuery()
    self:free()
    if(not free) then
        self:create(_query)
    end

    return c
end

function Result:getDataInt(s)
    if(self:getID() == -1) then
        error("[Result:getDataInt] Result not set!")
    end

    return result.getDataInt(self:getID(), s)
end

function Result:getDataLong(s)
    if(self:getID() == -1) then
        error("[Result:getDataLong] Result not set!")
    end

    return result.getDataLong(self:getID(), s)
end

function Result:getDataString(s)
    if(self:getID() == -1) then
        error("[Result:getDataString] Result not set!")
    end

    return result.getDataString(self:getID(), s)
end

function Result:getDataStream(s)
    if(self:getID() == -1) then
        error("[Result:getDataStream] Result not set!")
    end

    return result.getDataStream(self:getID(), s)
end

function Result:next()
    if(self:getID() == -1) then
        error("[Result:next] Result not set!")
    end

    return result.next(self:getID())
end

function Result:free()
    if(self:getID() == -1) then
        error("[Result:free] Result not set!")
    end

    self:setQuery("")
    local ret = result.free(self:getID())
    self:setID(-1)
    return ret
end

Result.numRows = Result.getRows
function db.getResult(query)
    if(type(query) ~= 'string') then
        return nil
    end

    local ret = Result:new()
    ret:create(query)
    return ret
end

and in data/craturescripts/scripts/login.lua:
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

Thx and have fun!
 
what about posting the real code lol
what code are you talking about? frags.lua? 004-DATABASE.LUA?
why do you need it, the error in the subject occurs in many positive situations.

I DON'T FINALLY KNOW WHAT YOU'RE ABOUT: d
 
this error shouldn't ever happen if you use a "complete" 0.4 distribution...

the error "attempt to call field 'ANYTHING' (a nil value)" is in 99% of the cases because the function doesn't exist...

if you used a complete distro it would not happen because the getResult function would be exactly where it should...

same with the login.lua part, it should be there by default...

and if your datapack is lacking these things, I can assume there will be many other things missing as well...
 
this error shouldn't ever happen if you use a "complete" 0.4 distribution...

the error "attempt to call field 'ANYTHING' (a nil value)" is in 99% of the cases because the function doesn't exist...

if you used a complete distro it would not happen because the getResult function would be exactly where it should...

same with the login.lua part, it should be there by default...

and if your datapack is lacking these things, I can assume there will be many other things missing as well...
I had a rev 3777 fire, original date and this error appears. There was no effective solution eiec publishes the ones that solved my problem.
 
Back
Top