Brave New World

by canidae

RTS-like scenario for Factorio. Player character is removed, all work must be done by bots

Scenarios
2 years ago
0.16 - 1.1
8.96K

g User or Mod added inventory items?

5 months ago

Some mods like https://mods.factorio.com/mod/circuitissimo require an item in inventory to use.

How do I hack these in, or would you add the item?

5 months ago
(updated 5 months ago)

Easiest way to get you going is figure out the "INTERNAL NAME" of the item you want. If it's not posted you can find this from looking at the code.
Then in game hover over a box hit ` to bring up console and type:
/sc game.player.selected.insert{name="item-internal-name", count=2}
Where "item-internal-name" is the name of the item you want to add to that box.
for example:
/sc game.player.selected.insert{name="piercing-rounds-magazine", count=100}
Will drop 100 red ammo into a box.

You must be admin to do this.

5 months ago
(updated 4 months ago)

Excellent. I thank you.
Where could I hack this into BNW to have the item in inventory proper?
The mod https://mods.factorio.com/mod/circuitissimo does not have a 'box' to set them into, but checks player inventory when placing them according to the modders discord.

5 months ago

In BNW there is code that disallows many items to be inserted into a players inventory - this is a core design to the mod. I'm not familiar with circuitissimo. This seems to be your issue, look in control.lua at itemCountAllowed funtion. If you change return 0 to return count, you're modifying the mod to allow the player to carry everything. This of course goes against the design of what BNW is, or maybe I'm just not understanding the issue.

5 months ago
(updated 5 months ago)

The issue is the need to add to the limited number of items that can go in BNW inventory.
I do not want to add all items.
In circuitissimo it has a 'circuitissimo combinator' that you carry into the circuitissimo factory, like factissimo, that you can then place.

How do I add one specific item the BNW player can carry?

5 months ago

AH, in the itemCountAllowed function I can hack in the item name.

I'll see if I can do that.

5 months ago
(updated 5 months ago)

I hacked into

local function itemCountAllowed(name, count, player)

between modules and blueprints

`` elseif string.match(name, ".module.") then
-- allow modules
return count
-- allow combinator???
elseif string.match(name, "combinator") then
return math.min(20, count)
elseif name == "BlueprintAlignment-blueprint-holder" then

And it not let me add. Any hints?

5 months ago

elseif string.match(name, ".*combinator") then

notice the ".*" which will allow arithmetic, decider and constant combinators. And this is written to only allow upto 20 of each.

5 months ago

So I can just unzip, edit, and start factorio and it will rebuild, yes?

It no work... Why it no work?

5 months ago

Broke eh? No need to provide details, I'll just figure it out from the information provided above... Wait for it.

4 months ago
(updated 4 months ago)

While I wait, I'll say thanks for looking at this.

I found this https://github.com/Omnifarious/Braver_New_World/pull/2/commits/6a83e82b76008ae18d6adcdd601848c9a5af9e64
a PR that never got excepted that did what I was doing, but for another mod.

I guess the two lines I added had some sort of bug. I tried several combinations but never got it to add the item to inventory. I even set it to exactly the full name of just the decider-combinator (== "decider-combinator") and it would not let me put in inventory.

Looking forward to what you can find out.

P.S. is perhaps 'ghosts on water' messing with it?

4 months ago
(updated 4 months ago)

Dear friend;

I needed to /c game.reload_script() to get the changes into the scenario.

All works as it should.

Sorry to bug you.

4 months ago

Why not just post the code you wrote, so it can be peer reviewed. You have mentioned it doesn't work and that something is wrong with the code you wrote, but are not showing the code. Also when you test new code - either you edit the save game to update that code or you restart the game.

4 months ago
(updated 4 months ago)

I actually posted the code above...
I needed to '/c game.reload_script()' to push the changes to the scenario. Restart would not do it, and I did not know about editing the save, but it was explained that the reload_script() did that.

For reference of the code before editing
https://github.com/Omnifarious/Braver_New_World/blob/master/scenarios/bnw/control.lua
starting at Line 84

    elseif string.match(name, ".*module.*") then
        -- allow modules
        return count

-- added for compatibility for circuitissimo 
    elseif string.match(name, ".*combinator*") or string.match(name, ".*pole") then
        -- allow combinators for circuitissimo
        return math.min(50, count)
-- end compatibility for circuitissimo 

    elseif name == "BlueprintAlignment-blueprint-holder" then
        -- temporary holding location for original blueprint, should only ever be one of these.
        return count
    end
    return 0

Above is the two lines i added to be able to carry combinators and circuitissimo's wire-pole. It also allows wood poles, but I'll worry about that later.

So I can enter the circuitissimo combinator and place combinators and do wiring, but I cannot mine anything, so no mistakes, and blueprints are borked.

I am looking at capturing the surface change event and changing the mining value as the player changes surfaces, but I am open to any ideas on how to get the two mods working.

I am thinking of forking BNW and adding https://lua-api.factorio.com/latest/classes/LuaRemote.html to allow mods to add compatibility to BNW.

Are you interested?

Is there a discord or git or some other place more conducive to a code discussion?

4 months ago

and you said you added a string compare for "decider-combinator" but now your showing ".combinator" which is obviously wrong and not following what I previously posted as correct. Why won't you just paste the code here ? You're explaining what you added but not showing what you added ? I read code better than text. I'm very familiar with brave new world but not support here. My mod "Brave New Oarc" https://mods.factorio.com/mod/brave-new-oarc is based on both Oarc and BNW. My mod supports many other mods, including surface change mods and I can change how they work from within BNO.

4 months ago
(updated 4 months ago)

I do accept pull requests, though it can take me awhile to get to them. Part of it is that I really do not like Lua.

4 months ago

JustGoFly:
I did paste the code here. Twice. This is box changed ".*" to something else.

Is "Brave New Oarc" compatible with circuitissimo? Perhaps I'll give it a shot.

Omnifarious:
As I noted the PR request above is 2 years waiting...

4 months ago

I see the paste - I'm not asking for another - I'm saying this does not follow my recommendation:
elseif string.match(name, ".combinator") or string.match(name, ".*pole") then

use ".*combinator"

4 months ago
(updated 4 months ago)

Omni - what I'm considering is to put either a drop down or freeform text field in settings to allow a host to define:
1) additional items to provide at start of game. I've previously added support for red/green boxes from qty 4..8
2) additional items allowed to be held in player inventory - this would be a restricted list of items since things like grenades would be cheating.

4 months ago
(updated 4 months ago)

Isn't there a way for one mod to be able to modify data in another mod? What I would prefer is a well-known place for other mods to place inventory allowed items in. That means other people can write "make mod X work with BNW" mods.

This could also be done with items to put in chests at the start of the game.

4 months ago

Yes I do this with scrap-resources mod and linked chests, redefining and in some cases fixing other mods from within BNO. But this is for prototypes that are extended and accessible from other mods. Also those mods extend the arrays into some resource in data phase, the mods that want to change it would change it at a later data phase. For example from data.lua - scrap-resources adds a type of 'resources' and name 'scrap' and from within there defines an array that it works on called minable.results. You'd need to make a new prototype or modify an existing entity, that added your array to it, then other mods could use that prototype to access the array in a later data stage.

"scrap-resources" generates a new resource in data.lua to add "scrap" then defines a default setting for that scrap, then from within data-updates.lua of BNO I can modify: data.raw.resource.scrap.minable.results to redefine the scrap items acted on by factorio.

I had to consume the BNW code, to merge it with Oarc, and to add all the features I desired.

Another option is to define a remote interface that other mods can work with BNW and modify how it works via that interface. This would mean someone would send an array to BNW via the interface, and if not called the default list of items would be used. Look at how Krastorio2 adds an interface to enable defining what surface has creep. I use that interface in BNO to enable creep on "oarc" surface, and turn it off on "nauvis".

You could even make it configurable by admins from within the game. Enable a menu for admins only, with a graphic of the items, and qty, then add that item to a chest in the base. From Settings I've not seen graphics added, so it would be a bit more crude to have internal names to define items, but do-able.

New response