Search found 3700 matches

by DaveMcW
Fri May 26, 2023 3:27 am
Forum: Modding help
Topic: entity.minable.results = random?
Replies: 8
Views: 1185

Re: entity.minable.results = random?

entity.minable.results does not support this.

You could use the control.lua event on_player_mined_entity to do whatever you want when a fish is mined.
by DaveMcW
Mon May 22, 2023 7:21 pm
Forum: Modding help
Topic: How to replace entities on tiles in a migration
Replies: 20
Views: 2709

Re: How to replace entities on tiles in a migration

AlmightyCrumpet wrote:
Mon May 22, 2023 3:42 pm
I'm confused, why would I migrate in the control.lua?
I only want this to run once, when updating to this version, so surely utilizing the migration functionality is ideal?
You can use migrations.lua, you don't need control.lua.

The reason to use lua is it offers more functionality than json.
by DaveMcW
Sun May 21, 2023 9:46 pm
Forum: Modding help
Topic: How to replace entities on tiles in a migration
Replies: 20
Views: 2709

Re: How to replace entities on tiles in a migration

You can use script.on_configuration_changed to migrate in control.lua. You need to keep your old data.lua entity names so they aren't deleted.
by DaveMcW
Sat May 13, 2023 1:57 am
Forum: Modding help
Topic: Control tanks/character/cars without player
Replies: 4
Views: 730

Re: Control tanks/character/cars without player

This works for characters, including characters in a car/tank. /c character = game.player.character target = game.player.selected script.on_event(defines.events.on_tick, function() if character and character.valid and target and target.valid then character.shooting_state = {state=defines.shooting.sh...
by DaveMcW
Sun Apr 30, 2023 2:11 am
Forum: Modding help
Topic: Place entity on the water edge
Replies: 10
Views: 1369

Re: Place entity on the water edge

The game will only read the data.lua fields that match the entity type. You can't add a recipe to an offshore pump. And you can't add water detection to an assembling machine.
by DaveMcW
Thu Apr 27, 2023 1:42 am
Forum: Modding help
Topic: Place entity on the water edge
Replies: 10
Views: 1369

Re: Place entity on the water edge

The offshore pump water detection feature is not exposed to modders. What you can do is make two entities. Entity 1 is an offshore pump, entity 2 is an assembling machine. Use the item to place entity 1. Then use control.lua scripting to swap to entity 2 in the on_built_entity and on_robot_built_ent...
by DaveMcW
Mon Apr 17, 2023 1:49 am
Forum: Gameplay Help
Topic: Circuit chest
Replies: 3
Views: 824

Re: Circuit chest

0eNrFVttuozAQ/ZVqnp2qkBAStPsX+7aqkAOTdrRgI2OizUb8+47xtiUpISHbqi9RfJnjM+fMYB9gUzRYGVIWkgNQplUNyc8D1PSkZOHm7L5CSIAsliBAydKNcswoRzPLdLkhJa020AogleNvSIJWXASorcx+zbZUWEYhVaPhPz2MsH0UgMqSJfSMusE+VU254Z1J8ArlOFupbJ+MgErXHKuVY+DwVveRgD0k8fw+4mNyMpj59YVwENboIt3gs9wRx3OQ53ZGjR0Z2/DMWz7djtkPl0KmGydn0BPksZtWyp...
by DaveMcW
Thu Mar 16, 2023 1:05 am
Forum: Modding help
Topic: Event for entity configuration changes
Replies: 2
Views: 632

Re: Event for entity configuration changes

This is the same issue as constant combinators. viewtopic.php?f=25&t=102702
by DaveMcW
Mon Mar 06, 2023 1:53 am
Forum: Ideas and Requests For Mods
Topic: "Demands"
Replies: 13
Views: 2183

Re: "Demands"

This is already in the game as the "Supply challenge" scenario.
by DaveMcW
Sun Feb 26, 2023 5:04 am
Forum: Modding help
Topic: Getting list of all generated chunks
Replies: 2
Views: 724

Re: Getting list of all generated chunks

Yes, the iterator can be stored. The stored iterator contains the current chunks, even if they were generated after it was created. It might not catch some newly created chunks, if they are inserted before the current position. When the iterator reaches the end of the list it stops iterating, even i...
by DaveMcW
Thu Feb 09, 2023 5:56 am
Forum: Modding help
Topic: A spider mod. The equipment is immediately inserted into the grid.
Replies: 7
Views: 1375

Re: A spider mod. The equipment is immediately inserted into the grid.

Yes, the grid is always created empty. It is hard to catch items when they are created because there is no event for it. You could watch the player's inventory though. function set_spider_inventory(grid) grid.put{name="battery-mk2-equipment", position={1,1}} end script.on_event(defines.eve...
by DaveMcW
Thu Feb 09, 2023 5:31 am
Forum: Modding help
Topic: A spider mod. The equipment is immediately inserted into the grid.
Replies: 7
Views: 1375

Re: A spider mod. The equipment is immediately inserted into the grid.

Code: Select all

script.on_event(defines.events.on_built_entity, function(event)
  if event.created_entity.name == "spidertron" then
    event.created_entity.grid.put{name="battery-mk2-equipment", position={1,1}}
  end
end)
by DaveMcW
Wed Feb 01, 2023 12:18 am
Forum: Modding help
Topic: Can I create a combinator with multiple input/output connection points?
Replies: 4
Views: 973

Re: Can I create a combinator with multiple input/output connection points?

No, the 4 WireConnectionPoint's correspond to 4 directions. You only get 1 red and 1 green input connection, and 1 red and 1 green output connection.

You have to use multiple entities if you want more connections.
by DaveMcW
Tue Jan 31, 2023 1:37 pm
Forum: Gameplay Help
Topic: Has anyone done or got tips for a "no steam" play?
Replies: 7
Views: 1371

Re: Has anyone done or got tips for a "no steam" play?

You can use a cheat to do it:

Code: Select all

/command game.player.insert{name="solar-panel", count=1}
by DaveMcW
Tue Jan 31, 2023 1:34 pm
Forum: Gameplay Help
Topic: Has anyone done or got tips for a "no steam" play?
Replies: 7
Views: 1371

Re: Has anyone done or got tips for a "no steam" play?

If you want to avoid all boilers, give yourself a single solar panel at the start to run your labs.
by DaveMcW
Sun Jan 29, 2023 10:04 pm
Forum: This Forum
Topic: "Copy blueprint" button in topic review section reloads the page
Replies: 1
Views: 1035

Re: "Copy blueprint" button in topic review section reloads the page

In HTML, <button> has type="submit" by default. This means an unmodified button will refresh the page.

To work around this, give the button type="button".

The button in the reply is unmodified because the blueprint script failed. Figuring out why it failed is trickier.
by DaveMcW
Mon Jan 23, 2023 3:50 am
Forum: Modding help
Topic: Migration file order
Replies: 9
Views: 1178

Re: Migration file order

It uses ascending order.
by DaveMcW
Mon Jan 16, 2023 3:29 am
Forum: Modding help
Topic: [Scripting Assistance] Help referencing procedurally generated recipe name
Replies: 1
Views: 532

Re: [Scripting Assistance] Help referencing procedurally generated recipe name

/c name = "biter-larva-2" pattern = "^(%w+)%-larva%-(%d+)$" species, i = name:match(pattern); game.print(species); game.print(i); Pattern explanation: ^ start of string $ end of string %w+ one or more alphanumeric characters %d+ one or more digits %- dash is a special character,...
by DaveMcW
Wed Jan 04, 2023 2:25 am
Forum: Modding help
Topic: inverted search limit filter
Replies: 4
Views: 789

Re: inverted search limit filter

Code: Select all

/c 
player = game.player
entity = game.player.selected
game.print( "Distance between " .. entity.name .. " and " .. player.name .. " is: " .. math.sqrt((entity.position.x - player.position.x)^2 + (entity.position.y - player.position.y)^2) )

Go to advanced search