Search found 1784 matches

by Pi-C
Mon Oct 27, 2025 1:25 am
Forum: Modding help
Topic: How to modify entity.tags?
Replies: 7
Views: 477

Re: How to modify entity.tags?


Where should I store data between deconstruction and cancelling deconstruction (Ctrl+Z)

I have no practical experience with this, but these events look useful:

on_cancelled_deconstruction
on_marked_for_deconstruction
on_player_deconstructed_area
on_pre_ghost_deconstructed



How should I ...
by Pi-C
Sun Oct 26, 2025 8:33 am
Forum: Modding help
Topic: How to modify entity.tags?
Replies: 7
Views: 477

Re: How to modify entity.tags?

FeelusM wrote: Sat Oct 25, 2025 11:21 pm Or I should save it in `storage.some_data[entity.unit_number]` and write boilerplate code for transferring it between `storage` and `ghost_entity.tags` for numerous events?
This is the way to go. :-)
by Pi-C
Sat Oct 25, 2025 10:26 pm
Forum: Modding help
Topic: How to modify entity.tags?
Replies: 7
Views: 477

Re: How to modify tags?

See the description of LuaEntity::tags:
The tags associated with this entity ghost. nil if this is not an entity ghost or when the ghost has no tags.
So I guess you can't add tags to your entity because you're dealing with real entities instead of entity ghosts …
by Pi-C
Wed Oct 22, 2025 7:26 pm
Forum: Modding help
Topic: Error message info.json file
Replies: 5
Views: 629

Re: Error message info.json file

Common mistakes are that
  • the last line before the closing brace '}' ends with a comma
  • the other lines after the opening brace '{' DO NOT end with a comma
I am not sure whether empty lines are allowed between the braces. In the above, 'line' refers to lines that actually contain text.
by Pi-C
Sun Oct 19, 2025 4:54 am
Forum: Modding help
Topic: Error message info.json file
Replies: 5
Views: 629

Re: Error message info.json file

You've got these two lines wrong:


"factorio_version": "2.0.69",
"dependencies": ["base >= 1.0.0"],

The mod should load if you change them to

"factorio_version": "2.0",
"dependencies": [
"base >= 2.0.69",
"space-age >= 2.0.69"
],
by Pi-C
Sun Oct 05, 2025 8:59 pm
Forum: Modding help
Topic: I managed it to crash the game without a error report
Replies: 16
Views: 989

Re: I managed it to crash the game without a error report


get_chunks() returns a LuaChunkIterator object. This can be saved in storage and the chunk handles can be retrieved one at a time with the next() function. Keep getting chunks a few at a time (e.g. in a "for n=1,5 do" loop) until it returns nil. if you need to do another scan, start over with a ...
by Pi-C
Sun Oct 05, 2025 4:23 pm
Forum: Modding help
Topic: I managed it to crash the game without a error report
Replies: 16
Views: 989

Re: I managed it to crash the game without a error report


If you only need to know if a chunk has water, and not where it is, instead of "find_tiles_filtered", use "count_tiles_filtered".


@Paned named the function spawn_morphed_fish(), so I guess it is relevant where the water tiles are located. This poses another problem: how do you determine where ...
by Pi-C
Sun Oct 05, 2025 4:07 pm
Forum: Modding help
Topic: I managed it to crash the game without a error report
Replies: 16
Views: 989

Re: I managed it to crash the game without a error report


The best improvement would be if your code runs on the on_chunk_generated event.

This will work in games where the mod has been active right from the start. But if the mod was added to a running game, you'd miss all chunks that have already been generated. You can avoid that if you build your ...
by Pi-C
Sun Oct 05, 2025 8:40 am
Forum: Resolved Requests
Topic: Missing info for LuaSurface::get_chunks()
Replies: 1
Views: 148

Missing info for LuaSurface::get_chunks()

The description of LuaTerritory::get_chunks() contains the following sentence:

Chunks may or may not be generated; use LuaSurface::is_chunk_generated to check a chunk's state before accessing it.

This sentence is missing from the description of LuaSurface::get_chunks() . Without it, people may ...
by Pi-C
Sun Oct 05, 2025 7:58 am
Forum: Modding help
Topic: I managed it to crash the game without a error report
Replies: 16
Views: 989

Re: I managed it to crash the game without a error report


I believe surface.get_chunks() only returns generated chunks.

That's what I thought, too! However, when I was looking for the description of LuaSurface::get_chunks(), I noticed that there also is LuaTerritory::get_chunks() , which has a slightly different description:

"Chunks may or may not be ...
by Pi-C
Sat Oct 04, 2025 4:52 pm
Forum: Resolved Problems and Bugs
Topic: [2.0.69] on_chart_tag_modified not raised for changed text/icon
Replies: 2
Views: 544

Re: [2.0.69] on_chart_tag_modified not raised for changed text/icon

Sorry, I forgot to mention that the event is raised when tag icon or text are changed by a player. But it won't be raised when icon or text are changed by script.
by Pi-C
Sat Oct 04, 2025 4:45 pm
Forum: Resolved Problems and Bugs
Topic: [2.0.69] on_chart_tag_modified not raised for changed text/icon
Replies: 2
Views: 544

[2.0.69] on_chart_tag_modified not raised for changed text/icon

What?
According to the description, on_chart_tag_modified will be "[c]alled when a chart tag is modified by a player or by script." However, the event is only raised if tag position or tag surface have been changed – changes to icon or text are ignored.

How to reproduce
I've started a new game ...
by Pi-C
Sat Oct 04, 2025 2:17 pm
Forum: Modding help
Topic: I managed it to crash the game without a error report
Replies: 16
Views: 989

Re: I managed it to crash the game without a error report


i do like the second version better :)

Thank you for helping me out here.

But still. As soon as this code is fired my game freezes :(

is there something wrong with the .find_tiles_filtered function?

I don't see anything wrong with it. It does run in a newly started game (inverted the ...
by Pi-C
Fri Oct 03, 2025 7:41 pm
Forum: Modding help
Topic: I managed it to crash the game without a error report
Replies: 16
Views: 989

Re: I managed it to crash the game without a error report


uh, can you tell me why i have to use next there?
i thought i was going through the chunk table by the for loop - somehow i dont get it (sorry..)


If game.surfaces[1].find_tiles_filtered({area = area_fromChunk, name = arrayWithTiles}) doesn't find any water tiles, it won't return nil but ...
by Pi-C
Fri Oct 03, 2025 2:51 pm
Forum: Modding help
Topic: I managed it to crash the game without a error report
Replies: 16
Views: 989

Re: I managed it to crash the game without a error report

Not sure what causes your crash, but this is wrong:


if game.surfaces[1].find_tiles_filtered({area = area_fromChunk, name = arrayWithTiles}) then
game.print("found water")
end

LuaSurface::find_tiles_filtered will always return an array with 0 or more elements, so the condition is always true ...
by Pi-C
Sat Sep 27, 2025 8:56 am
Forum: Modding help
Topic: Is there an established way to 'remove' a prototype from the base game?
Replies: 4
Views: 328

Re: Is there an established way to 'remove' a prototype from the base game?

You may also want to add hidden_in_factoriopedia= true!
by Pi-C
Sat Sep 27, 2025 8:41 am
Forum: Modding help
Topic: Is there an established way to 'remove' a prototype from the base game?
Replies: 4
Views: 328

Re: Is there an established way to 'remove' a prototype from the base game?

You should never remove prototypes! If you do that, it's quite likely that you'll break things for other mods. What you can do is hide prototypes of entities, items etc., the recipes that make them, and unlocks in technologies. This way, other mods can still use the prototype to create their own ...
by Pi-C
Tue Sep 09, 2025 3:39 pm
Forum: Implemented mod requests
Topic: LuaPlayer::swap_players
Replies: 5
Views: 557

Re: LuaPlayer::swap_players


The characters need players attached …

Two players, two characters? Yes, that really wouldn't help my mod to exchange characters. However, it could be necessary (not sure, must check the code first) for my mod to update the character data (e.g. in games with modded characters, when the player's ...

Go to advanced search