migration and new lamp

Place to get help with not working mods / modding interface.
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

migration and new lamp

Post by rk84 »

I'm currenly trying to add new lamp to mod and it to work in current game I have added migration.
migration code.

Code: Select all

game.player.force.resetrecipes()
game.player.force.resettechnologies()
recipe does migrate to tech effects, but is not craftable for player. Tech was researched before adding and migrating new recipe.
Trying to reset via console does not seems help. I have tried these.

Code: Select all

game.player.force.reset()
game.player.force.recipes["red-lamp"].reload()
Recipe is usable in new game.

Also about this lamp that I try to add in game. I had idea of warning light that works when there is powershortage so I added buffer capacity of 1250. Rest is same as small lamp, but consumes lot less energy (0.05 per tick) and has red light with smaller radius.
Problem is it does not seem to get any buffer and the alert icon is flashing constantly even when powered.

ps. Why I remember using getenergy() for entities, but nowadays most of them returns nil. Like laser turret and it has buffer capacity too.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
kovarex
Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: migration and new lamp

Post by kovarex »

You need to manually enable the recipe in migration when the technology is already invented.

Here is example from the igration script:

Code: Select all

local forcelist = game.forces
for index, item in pairs(forcelist) do
  local technologies = item.technologies
  local recipes = item.recipes
  if technologies["logistics-2"].researched then
    recipes["fast-splitter"].enable()
  end
  if technologies["logistics-3"].researched then
    recipes["express-splitter"].enable()
  end
  if technologies["steel-processing"].researched then
    recipes["steel-axe"].enable()
    recipes["steel-chest"].enable()
  end
end
I will take a look on the getenergy, and extend it to be usable with more entities.
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: migration and new lamp

Post by rk84 »

kovarex wrote:You need to manually enable the recipe in migration when the technology is already invented.

Here is example from the migration script:

Code: Select all

local forcelist = game.forces
for index, item in pairs(forcelist) do
  local technologies = item.technologies
  local recipes = item.recipes
  if technologies["logistics-2"].researched then
    recipes["fast-splitter"].enable()
  end
  if technologies["logistics-3"].researched then
    recipes["express-splitter"].enable()
  end
  if technologies["steel-processing"].researched then
    recipes["steel-axe"].enable()
    recipes["steel-chest"].enable()
  end
end
Thank you for fast answer.

Edit: I think I will abandon buffer-capacity-lamp -idea. Adding new mini accumulator feels now like the proper way of doing it... oh wait the network will suck it dry... Have to go with seperated solar panels.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
kovarex
Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: migration and new lamp

Post by kovarex »

All you need for this to work is the getenergy and method to turn off/on the light right?
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: migration and new lamp

Post by rk84 »

kovarex wrote:All you need for this to work is the getenergy and method to turn off/on the light right?
This is bit of work in progress in my messy head and I have not though of any uses for script side. So at this point, I have used getenergy to just test things.

I think it as some emergency/danger/indicator -light.
Currently. It can work as indicator at night time and makes patrolling front lines more exiting :lol:
If it could be turn on during daytime too, it could make better job as indicating that power grid is on.
Input for circuit network sure would add more uses and I would make green lamp too.

Current usage.
Im planning base with seperated power network for lasers. The laser network's power source is steam engines and coal is supplied only when any gun turret takes ammo from request chests. So, when gun turrets start shooting, then boilers get coal, network turn on, red lamps light up and lasers start shooting.
I just realised that same inserters that inserts coal to boilers needs signal from laser network, but power from accumulator/solar network. Its gonna be messy.

Edit: My small factory. Red lights indicate laser network. I need to remove just one pole when I have enough solars and accumulator to support factory without coal. There is also train bringing copper from nearby mining site.
Image
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
Post Reply

Return to “Modding help”