Jump to content

How to fill a "drainable" item?


Bourbon

Recommended Posts

I am working on a Mod where the player can make projectiles from molten lead.

 

 

 

I already got the drainable item "scrapleadpot" working.

 

Also working is putting single bits of lead ("scraplead") into the pot and using the drainable pot.

 

But here is the issue: After that i cannot add more lead.

 

I tried making a recipe adding "scraplead" into the "potoflead", but i am missing something:

 

How do i make it so the player can put lead into the potof lead until it is full? It stops at half. I tried a workaround but it seems like a dead end.

 

In the end the player should be able to put 30 pieces of "scraplead" into the pot with the "potoflead" showing the coresponding fullness.

 

 

item scraplead
    {
        Weight    =    0.01,
        Type    =    Normal,
        DisplayName    = Scrap Lead,
        DisplayCategory = Item,
        Icon    =    scraplead,
        WorldStaticModel = BoxOfShotGunShells,
    }
    
    item scrapleadpot
    {
        Weight    =    3,
        Type    =    Drainable,
        UseWhileEquipped    =    FALSE,
        UseDelta    =    0.25,
        DisplayName    = Pot with lead,
        ReplaceOnDeplete    =    Pot,
        Icon    =    Pot_Water,
        IsCookable    =    TRUE,
        StaticModel = CookingPot,
        WorldStaticModel = CookingPotWater_Ground,

 

     recipe Put Lead in Pot
        {
              scraplead,
            Pot,
            
               Result:    scrapleadpot;1,
               Time:30.0,
        }
    
              recipe Add Lead in Pot
        {
              scraplead,
              destroy scrapleadpot,
            
               Result:    scrapleadpot;2,                                /*this gives me a half full pot, but after that i cannot add more*/
               Time:30.0,
        }

 

 

          recipe Add Lead in Pot
        {
              scraplead,
            destroy scrapleadpot=3,                     /*i tried a workaround with this but this does not seem like a good solution*/
            
               Result:    scrapleadpot;4,
               Time:30.0,
        }
    
               recipe Add Lead in Pot
        {
              scraplead,
            destroy scrapleadpot=4,
            
               Result:    scrapleadpot;5,
               Time:30.0,
        }
    
               recipe Add Lead in Pot
        {
              scraplead,
            destroy scrapleadpot=5,
            
               Result:    scrapleadpot;6,
               Time:30.0,


    }

 

 

 

 

 

 

 

This has nothing to do with the issue, but might be interesting:

 

I adapted the recepie from disinfecting bandages for my pot. This works as intended.

 

    recipe Mold 9mm projectiles
    {
        keep Bulletmold9mm,
        scrapleadpot;5,
        CanBeDoneFromFloor:true,
        Result:9mmbullet,
        Time:50.0,
        Heat:-0.22,
    }

 

 

 

 

 

Edited by Bourbon
Link to comment
Share on other sites

  • Bourbon changed the title to How to fill a "drainable" item?

Sooo i did a bit of digging in the PZ Base code, i found some code for refilling the Blowtorch. Makes sense, to use that. Both Blowtorch and Propanetank are Drainable. One gets depleted the other filled.

 

But i have not gotten it to work yet. Mabye someone can find something obvoius.

 

LUA:

 

function Recipe.OnCreate.RefillLeadPot,(items, result, player)
    local scrapleadpot = nil;
    local scraplead = nil;
    for i=0, items:size()-1 do
       if items:get(i):getType() == "scrapleadpot" then
           scrapleadpot = items:get(i);
       elseif items:get(i):getType() == "scraplead" then
           scraplead = items:get(i);
       end
    end
    result:setUsedDelta(scrapleadpot:getUsedDelta() + result:getUseDelta() * 30);

    while result:getUsedDelta() < 1 and scraplead:getUsedDelta() > 0 do
        result:setUsedDelta(result:getUsedDelta() + result:getUseDelta() * 30);
        scraplead:Use();
    end

    if result:getUsedDelta() > 1 then
        result:setUsedDelta(1);
    end
end
   

SCRIPT:

 

            recipe Put Lead in Pot
        {
              scraplead,
            Pot,
            
               Result:    scrapleadpot;1,
               Time:30.0,
        }
    
         recipe Add Lead in Pot
        {
              scraplead=1,
            destroy scrapleadpot,
            
               Result:    scrapleadpot,
               Time:30.0,
           
       OnCreate:Recipe.OnCreate.RefillLeadPot,

 

 

Link to comment
Share on other sites

I did not find a solution, so i tried a workaround and it worked.

 

 

I made the scrap lead drainable and then just added a pot as "keep" in the recipe.

 

So the player still needs a pot, but no weird filling in and out of the pot.

Link to comment
Share on other sites

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...