Page 1 of 1

Inventory howto: Impossible to close function

Posted: Sat Mar 26, 2016 9:03 pm
by Psiweapon
In this fragment, if you uncomment the commented out lines (as instructed to), the function becomes impossible to close with an "end".

I thought it was improper indenting of the if and elseif blocks, but I tried to give them proper indent and it's still impossible to close.

Code: Select all

function _M:use(item)
    if not item then return end
    game:unregisterDialog(self)

    local act = item.action

    --if act == "use" then
        --self.actor:playerUseItem(self.object, self.item, self.inven, self.onuse)
        --self.onuse(self.inven, self.item, self.object, true)
    --else
    if act == "drop" then
        self.actor:doDrop(self.inven, self.item, function() self.onuse(self.inven, self.item, self.object, false) end)
    elseif act == "wear" then
        self.actor:doWear(self.inven, self.item, self.object)
        self.onuse(self.inven, self.item, self.object, false)
    elseif act == "takeoff" then
        self.actor:doTakeoff(self.inven, self.item, self.object)
        self.onuse(self.inven, self.item, self.object, false)
    end
end

Re: Inventory howto: Impossible to close function

Posted: Sat Mar 26, 2016 10:11 pm
by HousePet
Did you merge the else and the if into an elseif?

Re: Inventory howto: Impossible to close function

Posted: Sat Mar 26, 2016 10:53 pm
by Psiweapon
Yay, it worked.

Felt weird that there was an else + if, but hey, what do I know? Evidently, very little. Thanks!

Re: Inventory howto: Impossible to close function

Posted: Sun Mar 27, 2016 12:00 am
by Psiweapon
Resolved, this thread can be closed.