Jump to content

[SOLVED] Trouble with filling the drainable item


Izeick

Recommended Posts

Hi everyone. I spent two nights trying to solve a problem with my mod. I wanna create a bag that can be filled with money. I was able to write part of money taking out code, but filling is too hard for me. At the bottom I paste my current code. At the moment, when I try to fill the bag by one unit (500$ is 1 unit; 5000$ is max), it is immediately filled completely. Please help who understands

 

[LUA] media/lua/server/moneybag.lua

function Recipe.OnCreate.moneyin(items, result, player)
        for i=0, items:size()-1 do
                if items:get(i):getType() == "PERCOM.moneybag" then
                        if items:get(i):getUsedDelta() == 0 then
                                result:setUsedDelta(0.1)
                        else
                                result:setUsedDelta(items:get(i):getUsedDelta() + 0.1)
                        end
                end
        end
end
 
 
 
[SCRIPT] media/scripts/PERCOM_recipes.txt
 

module PERCOM
{
imports
    {
        Base
    }
item moneybag
    {
        Weight = 1.1,
        Type = Drainable,
        UseWhileEquipped = FALSE,

        DisappearOnUse = FALSE,
        UseDelta = 0.1,
        DisplayName = Moneybag,
        Icon = Moneybag,
        WeightEmpty = 0.1,
    }
    
recipe put500dollars
    {
        destroy moneybag,
        Money = 500,
            
        Result: moneybag,
        Time: 1,
        Category: Money,
        CanBeDoneFromFloor: TRUE,
        OnCreate: Recipe.OnCreate.
moneyin,
        
    }

    
recipe take500dollars
    {
        PERCOM.moneybag = 1,
        
        Result: Money = 500,
        Time: 1,
        Category: Money,
        CanBeDoneFromFloor: TRUE,
    }
}

Edited by Izeick
Link to comment
Share on other sites

  • Izeick changed the title to [SOLVED] Trouble with filling the drainable item

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...