Jump to content

[Modding Help] Using Delta on Item while Building


RedPanda33

Recommended Posts

I am trying to balance the game to a more reasonable usage and weight system (like a pencil's weight being 10g (weight = 0.01) instead of vanilla 100g ... o-ô).

Currently adjusting delta values for each item.

In this example Rope. Having declared a delta for it but want to make it decreasable instead of simple using it up entirely.

My current issue is the following:

Log walls using up an entire Rope-Stack (same for Twine), but I want to get that reduced until it reaches 0.0 delta.

 

Has anyone an idea how to logically program this in ISBuildungMenu.lua:821 to 843? Or am I on the wrong side of "consumable" directories and files regarding UseDelta values? I would "copy" some other logics and try to lern from those, like soap, propane torch and so on, but I cannot find any regarding file for that matter.

Thanks in advance!

Link to comment
Share on other sites

Did you try to set the item type as "Drainable" in the item definition ? And add also Usedelta and set it up ?

Like that :

item CandleLit
    {
        LightDistance    =    3,
        Weight    =    0.2,
        Type    =    Drainable,
        TorchCone    =    FALSE,
        UseDelta    =    0.003,
        LightStrength    =    0.6,
        DisplayName    =    Lit Candle,
        ActivatedItem    =    TRUE,
        Icon    =    CandleLit,
        cantBeConsolided = TRUE,
    }

Link to comment
Share on other sites

I think you also need to define how much quantity of your drainable you want to drain in the recipe itself.

 

Example :

recipe Make Cake Batter
    {
       Bowl,
       Flour=2,
       Butter;15,
       Sugar=3,
       Egg/WildEggs,
       Yeast,
       Milk,

       Result:CakeBatter,
       NeedToBeLearn:true,
       Time:50.0,
       Category:Cooking,
       OnGiveXP:Give10CookingXP,
    }
 

Sugar & Flour are drainables :
    item Sugar
    {
        Weight    =    1,
        Type    =    Drainable,
        UseWhileEquipped    =    FALSE,
        UseDelta    =    0.16,
        DisplayName    =    Sugar,
        Icon    =    Sugar,
        EvolvedRecipe = HotDrink:1,
    }

 

So my assumption is that it will drain : UseDelta x number in the recipe.

Example here : the Sugar will be drained for 0.16 x 3 = 0.48 units.

 

Did you dug into java code to find the drainable java code and figure our how it works ?

Link to comment
Share on other sites

14 hours ago, Asilar said:

I think you also need to define how much quantity of your drainable you want to drain in the recipe itself.

 

Example :

recipe Make Cake Batter
    {
       Bowl,
       Flour=2,
       Butter;15,
       Sugar=3,
       Egg/WildEggs,
       Yeast,
       Milk,

       Result:CakeBatter,
       NeedToBeLearn:true,
       Time:50.0,
       Category:Cooking,
       OnGiveXP:Give10CookingXP,
    }
 

Sugar & Flour are drainables :
    item Sugar
    {
        Weight    =    1,
        Type    =    Drainable,
        UseWhileEquipped    =    FALSE,
        UseDelta    =    0.16,
        DisplayName    =    Sugar,
        Icon    =    Sugar,
        EvolvedRecipe = HotDrink:1,
    }

 

So my assumption is that it will drain : UseDelta x number in the recipe.

Example here : the Sugar will be drained for 0.16 x 3 = 0.48 units.

 

Did you dug into java code to find the drainable java code and figure our how it works ?

Adding recipes in, well, recipe.txt isn't an issue, but the recipe I want to edit is located in the building system ( LogWall - ISBuildungMenu.lua ) and if I change the code like

 

    local numRippedSheets = ISBuildMenu.countMaterial(player, "Base.RippedSheets") + ISBuildMenu.countMaterial(player, "Base.RippedSheetsDirty")
    local numTwine = ISBuildMenu.countMaterial(player, "Base.Twine")
    local numRope = ISBuildMenu.countMaterial(player, "Base.Rope")
    if numRippedSheets >= 2 then
        tooltip.description = tooltip.description .. " <RGB:1,1,1>" .. getItemNameFromFullType("Base.RippedSheets") .. " 2 ";
    elseif numTwine >= 0.1 then
        tooltip.description = tooltip.description .. " <RGB:1,1,1>" .. getItemNameFromFullType("Base.Twine") .. " 0.7 ";
    elseif numRope >= 0.5 then
        tooltip.description = tooltip.description .. " <RGB:1,1,1>" .. getItemNameFromFullType("Base.Rope") .. " 0.5 ";
    else
        tooltip.description = tooltip.description .. " <RGB:1,0,0>" .. getItemNameFromFullType("Base.RippedSheets") .. " " .. numRippedSheets .. "/2 <LINE> " .. getText("ContextMenu_or") .. " " .. getItemNameFromFullType("Base.Twine") .. " " .. numTwine .. "/0.7 <LINE> " .. getText("ContextMenu_or") .. " " .. getItemNameFromFullType("Base.Rope") .. " " .. numRope .. "/0.5 ";
        if not ISBuildMenu.cheat then
            logOption.onSelect = nil;
            logOption.notAvailable = true;
        end
    end
          
          [... further below ...]
          
          ISBuildMenu.canBuildLogWall = function(player)
    local logs = ISBuildMenu.countMaterial(player, "Base.Log")
    local sheets = ISBuildMenu.countMaterial(player, "Base.RippedSheets") + ISBuildMenu.countMaterial(player, "Base.RippedSheetsDirty")
    local twine = ISBuildMenu.countMaterial(player, "Base.Twine")
    local rope = ISBuildMenu.countMaterial(player, "Base.Rope")
    return logs >= 5 and (sheets >= 2 or twine >= 0.7 or rope >= 0.5)
end

ISBuildMenu.onLogWall = function(worldobjects, player)
    local wall = ISWoodenWall:new("carpentry_02_80", "carpentry_02_81", nil);
    wall.modData["need:Base.Log"] = "5";
	local sheets = ISBuildMenu.countMaterial(player, "Base.RippedSheets");
	local sheetsDirty = ISBuildMenu.countMaterial(player, "Base.RippedSheetsDirty");
	if sheets > 2 then sheets = 2; sheetsDirty = 0 end
	if sheetsDirty > 2 then sheetsDirty = 2; sheets = 0 end
	if sheets < 2 and sheetsDirty > 0 then sheetsDirty = 2 - sheets; end
    if sheets + sheetsDirty >= 2 then
		if sheets > 0 then wall.modData["need:Base.RippedSheets"] = tostring(sheets); end
		if sheetsDirty > 0 then wall.modData["need:Base.RippedSheetsDirty"] = tostring(sheetsDirty); end
    elseif ISBuildMenu.countMaterial(player, "Base.Twine") >= 0.7 then
        wall.modData["need:Base.Twine"] = "0.7";
    elseif ISBuildMenu.countMaterial(player, "Base.Rope") >= 0.5 then
        wall.modData["need:Base.Rope"] = "0.5";
    end
    wall.modData["xp:Woodwork"] = 5;
    wall.player = player;
	wall.noNeedHammer = true
	wall.canBarricade = false
	wall.name = "Log Wall"
    getCell():setDrag(wall, player);
end

it will rather use up the entire item, be it 0.5 / 0.7 delta (respective to their items) 0.1 or even full delta capacity.

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