[Solved] [Duplicate] Replacing starting items

Place to get help with not working mods / modding interface.
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 430
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

[Solved] [Duplicate] Replacing starting items

Post by BraveCaperCat »

In the base game, you start with a burner mining drill, stone furnace and wood. How do I change this so that I start with certain items in my mod? Specifically, I want to change this to: A recycler, an assembler, solar panel and power pole. This way, players using my mod can start by producing pistols for free, (my mod adds this recipe) recycle the pistols into iron plates and copper plates (truly comical) and turn the iron plates into whatever else they need. (like iron gearwheels) It would likely be multiple solar panels, or higher quality ones. (my mod already requires quality) I'll note that I want to be able to do this in the data stage, preferably with as little changes as necessary.
Last edited by BraveCaperCat on Mon Oct 28, 2024 12:04 pm, edited 1 time in total.
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
User avatar
jamiechi1
Filter Inserter
Filter Inserter
Posts: 289
Joined: Wed Jan 03, 2018 10:12 pm

Re: Replacing starting items

Post by jamiechi1 »

Basically you need to use a remote interface to Freeplay.
This lets you access the stuff already there and add new stuff.
Here is a thread that discusses this.
viewtopic.php?t=113643
I think this is where I got the information to make my own early start mod.

I don't remember where all this code came from. Some of it inspired from the above thread.
This mod consists entirely of one file.
The contents of Control.lua:

Code: Select all


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

   local player = game.players[event.player_index]

   -- need these researched
   player.force.technologies["robotics"].researched = true --
   player.force.technologies["logistic-system"].researched = true --
   player.force.technologies["logistic-robotics"].researched = true --
   player.force.technologies["construction-robotics"].researched = true --
   player.force.technologies["worker-robots-storage-1"].researched = true 
   player.force.technologies["worker-robots-speed-1"].researched = true 

end
)


local crashsite_disable = false   
local skip_intro = true


local function add_CreatedItem_to_Freeplay(new_items)
   if remote.interfaces["freeplay"].get_created_items
   then
      local items = remote.call('freeplay','get_created_items')
      for name,count in pairs(new_items) 
      do
         if (not items[name]) or (items[name] and items[name] < count) 
         then
            items[name] = count
         end
      end
      remote.call('freeplay','set_created_items', items)
   end
end  -- function add_CreatedItem_to_Freeplay

local function add_DebrisItem_to_Freeplay(new_items)
   if remote.interfaces["freeplay"].get_debris_items
   then
      local items = remote.call('freeplay','get_debris_items')
      for name,count in pairs(new_items) 
      do
         if (not items[name]) or (items[name] and items[name] < count) 
         then
            items[name] = count
         end
      end
      remote.call('freeplay','set_debris_items', items)
   end
end  -- function add_DebrisItem_to_Freeplay


local function doStuff()
   if remote.interfaces["freeplay"] 
      then
     
         remote.call("freeplay", "set_skip_intro", skip_intro)
    
      add_CreatedItem_to_Freeplay( 
         {
            --["light-armor"]=1,    -- 4x4
            --["heavy-armor"]=1,    -- 6x6
            --["modular-armor"]=1,  -- 8x8
            ["power-armor"]=1,    -- 10x10
            
            -- ["power-armor-mk2"]=1, -- 12x12
            -- ["fusion-reactor-equipment"]=4, -- early power
            -- ["exoskeleton-equipment"]=1,
            ["personal-roboport-equipment"]=2,
            ["battery-equipment"]=4,
            ["solar-panel-equipment"]=16,


            ["construction-robot"]=20,
            ["logistic-robot"]=100,
            ["passive-provider-chest"]=50,
            --["active-provider-chest"]=20,
            ["storage-chest"]=50,
            --["buffer-chest"]=20,
            ["requester-chest"]=20,
            ["roboport"]=50,

            --["lab"]=2,
            --["assembling-machine-1"]=12,
            
            -- sometimes need this to make items that need a fluid input
            --["assembling-machine-2"]=2,
            
            -- ["burner-mining-drill"]=10,
            -- ["stone-furnace"]=50,
            ["wooden-chest"]=10,
            
            ["small-electric-pole"] = 50,
            
            -- ["iron-plate"]=1000,
            -- ["iron-stick"]=200,
            -- ["iron-gear-wheel"]=250,
            -- ["iron-chest"]=100,
            
            -- ["copper-plate"]=500,
            -- ["copper-cable"]=400,
            
            ["electronic-circuit"]=100,
            
            ["boiler"]=8,
            ["steam-engine"]=16,
            
            -- ["pump"]=10,
            ["pipe-to-ground"]=10,
            ["pipe"]=50,
                                    
            -- ["steel-plate"]=500,
            -- ["steel-chest"]=10,
            
            ["transport-belt"]=200,
            ["underground-belt"]=20,
            ["splitter"]=20,
            
            ["inserter"]=50,
            ["burner-inserter"]=20,
            ["long-handed-inserter"]=50,
            
            --["small-lamp"]=10,
            --["landfill"]=500,
         }
      )
   end
end -- function doStuff

script.on_init(doStuff)
-- script.on_configuration_changed(doStuff)

User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 430
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Re: [Solved] [Duplicate] Replacing starting items

Post by BraveCaperCat »

jamiechi1 wrote: Sun Oct 27, 2024 4:36 am Basically you need to use a remote interface to Freeplay.
This lets you access the stuff already there and add new stuff.
Here is a thread that discusses this.
viewtopic.php?t=113643
I think this is where I got the information to make my own early start mod.

I don't remember where all this code came from. Some of it inspired from the above thread.
This mod consists entirely of one file.
The contents of Control.lua:

Code: Select all


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

   local player = game.players[event.player_index]

   -- need these researched
   player.force.technologies["robotics"].researched = true --
   player.force.technologies["logistic-system"].researched = true --
   player.force.technologies["logistic-robotics"].researched = true --
   player.force.technologies["construction-robotics"].researched = true --
   player.force.technologies["worker-robots-storage-1"].researched = true 
   player.force.technologies["worker-robots-speed-1"].researched = true 

end
)


local crashsite_disable = false   
local skip_intro = true


local function add_CreatedItem_to_Freeplay(new_items)
   if remote.interfaces["freeplay"].get_created_items
   then
      local items = remote.call('freeplay','get_created_items')
      for name,count in pairs(new_items) 
      do
         if (not items[name]) or (items[name] and items[name] < count) 
         then
            items[name] = count
         end
      end
      remote.call('freeplay','set_created_items', items)
   end
end  -- function add_CreatedItem_to_Freeplay

local function add_DebrisItem_to_Freeplay(new_items)
   if remote.interfaces["freeplay"].get_debris_items
   then
      local items = remote.call('freeplay','get_debris_items')
      for name,count in pairs(new_items) 
      do
         if (not items[name]) or (items[name] and items[name] < count) 
         then
            items[name] = count
         end
      end
      remote.call('freeplay','set_debris_items', items)
   end
end  -- function add_DebrisItem_to_Freeplay


local function doStuff()
   if remote.interfaces["freeplay"] 
      then
     
         remote.call("freeplay", "set_skip_intro", skip_intro)
    
      add_CreatedItem_to_Freeplay( 
         {
            --["light-armor"]=1,    -- 4x4
            --["heavy-armor"]=1,    -- 6x6
            --["modular-armor"]=1,  -- 8x8
            ["power-armor"]=1,    -- 10x10
            
            -- ["power-armor-mk2"]=1, -- 12x12
            -- ["fusion-reactor-equipment"]=4, -- early power
            -- ["exoskeleton-equipment"]=1,
            ["personal-roboport-equipment"]=2,
            ["battery-equipment"]=4,
            ["solar-panel-equipment"]=16,


            ["construction-robot"]=20,
            ["logistic-robot"]=100,
            ["passive-provider-chest"]=50,
            --["active-provider-chest"]=20,
            ["storage-chest"]=50,
            --["buffer-chest"]=20,
            ["requester-chest"]=20,
            ["roboport"]=50,

            --["lab"]=2,
            --["assembling-machine-1"]=12,
            
            -- sometimes need this to make items that need a fluid input
            --["assembling-machine-2"]=2,
            
            -- ["burner-mining-drill"]=10,
            -- ["stone-furnace"]=50,
            ["wooden-chest"]=10,
            
            ["small-electric-pole"] = 50,
            
            -- ["iron-plate"]=1000,
            -- ["iron-stick"]=200,
            -- ["iron-gear-wheel"]=250,
            -- ["iron-chest"]=100,
            
            -- ["copper-plate"]=500,
            -- ["copper-cable"]=400,
            
            ["electronic-circuit"]=100,
            
            ["boiler"]=8,
            ["steam-engine"]=16,
            
            -- ["pump"]=10,
            ["pipe-to-ground"]=10,
            ["pipe"]=50,
                                    
            -- ["steel-plate"]=500,
            -- ["steel-chest"]=10,
            
            ["transport-belt"]=200,
            ["underground-belt"]=20,
            ["splitter"]=20,
            
            ["inserter"]=50,
            ["burner-inserter"]=20,
            ["long-handed-inserter"]=50,
            
            --["small-lamp"]=10,
            --["landfill"]=500,
         }
      )
   end
end -- function doStuff

script.on_init(doStuff)
-- script.on_configuration_changed(doStuff)

Thank you! It works now. (I didn't use the above code though, I used the much simpler code from the linked thread)
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Post Reply

Return to “Modding help”