Inventory howto: Impossible to close function

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Inventory howto: Impossible to close function

#1 Post 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

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Inventory howto: Impossible to close function

#2 Post by HousePet »

Did you merge the else and the if into an elseif?
My feedback meter decays into coding. Give me feedback and I make mods.

Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Re: Inventory howto: Impossible to close function

#3 Post by Psiweapon »

Yay, it worked.

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

Psiweapon
Wayist
Posts: 23
Joined: Sat Mar 19, 2016 3:38 pm

Re: Inventory howto: Impossible to close function

#4 Post by Psiweapon »

Resolved, this thread can be closed.

Post Reply