make this GUI element respect mine-ability? Or hide it entirely?

Place to get help with not working mods / modding interface.
User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

make this GUI element respect mine-ability? Or hide it entirely?

Post by adamwong246 »

Image

I'm working on a mod that hides ores from the map and from the "first person" perspective. (See Bland Ores mod) Unfortunately, you can still manually scan the ground with the cursor to reveal otherwise invisible ore. Is there anyway to prevent this? I would like to either a) make the element respect mine-ability or b) hide the gui element entirely.

(In this example, the map is left unchanged and the user has mining_categories nil)
User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

Re: make this GUI element respect mine-ability? Or hide it entirely?

Post by adamwong246 »

That works🙏
cbhj1
Fast Inserter
Fast Inserter
Posts: 170
Joined: Tue Apr 25, 2017 2:53 pm
Contact:

Re: make this GUI element respect mine-ability? Or hide it entirely?

Post by cbhj1 »

Another wrinkle in what you describe is the same scanning can be done with a miner in hand. Even being able to place them off ore, their placement gui for expected resources will be the next snag.
User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

Re: make this GUI element respect mine-ability? Or hide it entirely?

Post by adamwong246 »

Another wrinkle in what you describe is the same scanning can be done with a miner in hand. Even being able to place them off ore, their placement gui for expected resources will be the next snag.
au contraire!

Code: Select all

local plain = "basic-solid";
local deep = "basic-solid-deep";
local deeper = "basic-solid-deeper";
local earth = "earth";
local silver = "silver";
local gold = "gold";

local deepResourceCategory = table.deepcopy(data.raw["resource-category"][plain]);
deepResourceCategory.name = deep;
local deeperResourceCategory = table.deepcopy(data.raw["resource-category"][plain]);
deeperResourceCategory.name = deeper;

local deepDrill = table.deepcopy(data.raw["mining-drill"]["electric-mining-drill"]);
deepDrill.name = "deep drill";
deepDrill.resource_categories = {plain, deep};
local deeperDrill = table.deepcopy(data.raw["mining-drill"]["electric-mining-drill"]);
deeperDrill.resource_categories = {plain, deep, deeper};
deeperDrill.name = "deeper drill";

local deepDrillRecipe = table.deepcopy(data.raw.recipe["electric-mining-drill"]);
deepDrillRecipe.normal.result = deepDrill.name;
deepDrillRecipe.expensive.result = deepDrill.name;
local deeperDrillRecipe = table.deepcopy(data.raw.recipe["electric-mining-drill"]);
deeperDrillRecipe.normal.result = deeperDrillRecipe.name;
deeperDrillRecipe.expensive.result = deeperDrillRecipe.name;

local earthResource = table.deepcopy(data.raw["resource"]["stone"]);
earthResource.name = "earth";
earthResource.minable.result = nil;
earthResource.infinite = true;
earthResource.minimum = 1;
earthResource.minable.results = {{
    name = "earth",
    probability = 0.9,
    amount = 1
}, {
    name = "stone",
    probability = 0.09,
    amount = 1
}, {
    name = "silver",
    probability = 0.009,
    amount = 1
}, {
    name = "gold",
    probability = 0.001,
    amount = 1
}};

local earthItem = table.deepcopy(data.raw["item"]["stone"]);
earthItem.name = earth;
earthItem.tint = {
    r = 1,
    g = 0,
    b = 0,
    a = 1
};

local silverResource = table.deepcopy(data.raw["resource"]["copper-ore"]);
silverResource.name = "silver";
-- silverResource.category = deep
-- silver.icons = {
--   icon= silver.icon,
--   tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
-- };

local silverItem = table.deepcopy(data.raw["item"]["copper-ore"]);
silverItem.name = silver;
silverItem.icons = { {
    icon = silver.icon,
    tint = {
        a = 0.75,
        b = 0,
        g = 0,
        r = 0
    }
}};
silverItem.icon = {};

local silverAutoplace = table.deepcopy(data.raw["autoplace-control"]["copper-ore"]);
silverAutoplace.name = silver;
silverAutoplace.localised_name = {"", "[entity=silver] ", {"entity-name.silver"}};

local goldResource = table.deepcopy(data.raw["resource"]["copper-ore"]);
goldResource.name = gold;
-- goldResource.category = deeper;
-- gold.icons = {
--     icon = gold.icon,
--     tint = {
--         a = 0.5,
--         b = 0.1,
--         g = 0.1,
--         r = 0.1
--     }
-- };
-- gold.icon = nil;
local goldItem = table.deepcopy(data.raw["item"]["copper-ore"]);
goldItem.name = gold;
goldItem.icons = {{
    icon = goldItem.icon,
    tint = {
        a = 1,
        b = 0,
        g = 1,
        r = 0
    }
}};
goldItem.icon = {};

local goldAutoplace = table.deepcopy(data.raw["autoplace-control"]["copper-ore"]);
goldAutoplace.name = gold;
goldAutoplace.localised_name = {"", "[entity=gold] ", {"entity-name.gold"}};


data:extend({
  -- deepResourceCategory, deeperResourceCategory, deepDrill, deeperDrill, deepDrillRecipe, deeperDrillRecipe,
  earthItem, earthResource, 
  silverResource, silverItem, silverAutoplace,
  goldResource, goldItem, goldAutoplace,
});


             
for _, resource in pairs(data.raw.resource) do

    resource.selectable_in_game = false;

    if (resource.name == "earth") then
        -- resource.category = deep;
        resource.highlight = false;
        resource.map_grid = false;
        resource.map_color = {0, 0, 0, 0};
        resource.resource_patch_search_radius = false

    end

    local oreSheet = resource.stages.sheet

    
    -- if (resource.name == "copper-ore" or resource.name == "iron-ore") then
    --     resource.category = deep;
    -- end

    -- if (resource.name ~= "stone" and resource.name ~= "coal") then
    --     oreSheet.tint = {0, 0, 0, 0};
    --     oreSheet.hr_version.tint = {0, 0, 0, 0};
    -- end

    -- if (resource.name == "silver") then
    --     resource.category = deep;
    -- elseif resource.name == "gold" then
    --     resource.category = deeper;
    -- end


    data:extend({resource});
end

-- local character = table.deepcopy(data.raw["character"]["character"]);
-- character.mining_categories = nil;
-- character.reach_resource_distance = -1;
-- data:extend({character});
The secret is to make new miners that mine on a different category of resource. Those higher tier miners are locked behind research, so I think those ores really are hidden.
User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

Re: make this GUI element respect mine-ability? Or hide it entirely?

Post by adamwong246 »

One more thing- every space is covered in "earth" ore, making every space mine-able. You can now put a mining drill anywhere

Code: Select all

script.on_event(defines.events.on_chunk_generated, function(event)

    for x = event.area.left_top.x + 0, event.area.right_bottom.x - 1 do
        for y = event.area.left_top.y + 0, event.area.right_bottom.y - 1 do
            event.surface.create_entity({
                name = "earth",
                amount = 1,
                position = {x, y}
            })

        end
    end
end)
User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

Re: make this GUI element respect mine-ability? Or hide it entirely?

Post by adamwong246 »

cbhj1 wrote: Wed Sep 21, 2022 12:52 pm Another wrinkle in what you describe is the same scanning can be done with a miner in hand. Even being able to place them off ore, their placement gui for expected resources will be the next snag.
Is this what you were referring to? These green squares?
Image
User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

Re: make this GUI element respect mine-ability? Or hide it entirely?

Post by adamwong246 »

or perhaps this one?

Image
cbhj1
Fast Inserter
Fast Inserter
Posts: 170
Joined: Tue Apr 25, 2017 2:53 pm
Contact:

Re: make this GUI element respect mine-ability? Or hide it entirely?

Post by cbhj1 »

this is the one Image
User avatar
adamwong246
Fast Inserter
Fast Inserter
Posts: 148
Joined: Tue Dec 01, 2020 5:01 am
Contact:

Re: make this GUI element respect mine-ability? Or hide it entirely?

Post by adamwong246 »

Dang it, you called it right. I doubt it is likely but maybe this element can be hidden?
Post Reply

Return to “Modding help”