Search found 28 matches
- Thu Oct 21, 2021 11:33 pm
- Forum: Modding help
- Topic: How do associated characters work?
- Replies: 8
- Views: 2131
Re: How do associated characters work?
The reason the player.character is not included in the result is that it is controlled by the player. As the doc says, the function is for any characters that are associated with a player but "are NOT controlled by any player". Sorry I don't understand. The full section says Note: Charact...
- Thu Oct 21, 2021 10:48 pm
- Forum: Modding help
- Topic: Serialise instances of classes to JSON
- Replies: 8
- Views: 2241
Re: Serialise instances of classes to JSON
Not sure what you are doing. But have you tried simply creating a list of fields you want to serialize for e.g. an inserter. Then loop over that list and for each field store serpent.block(entity[field])? I haven't tried that, I'm new to Lua so would you mind giving an example? I've managed to get ...
- Thu Oct 21, 2021 10:41 pm
- Forum: Won't implement
- Topic: Rename on_player_changed_position to on_character_changed_position?
- Replies: 9
- Views: 2726
Re: Rename on_player_changed_position to on_character_changed_position?
D'oh you're right, my mistake. I got confused by the documentation talking about players/characters as if they're different.
- Wed Oct 20, 2021 7:25 pm
- Forum: Won't implement
- Topic: Rename on_player_changed_position to on_character_changed_position?
- Replies: 9
- Views: 2726
Rename on_player_changed_position to on_character_changed_position?
The event on_player_changed_position provides a player_index , but it's not the player that's updated - it's the player's character. To be more accurate, the event should be called on_character_changed_position , which should provide the same parameters (for convenience), plus the unit_number of cha...
- Wed Oct 20, 2021 7:18 pm
- Forum: Modding help
- Topic: How do associated characters work?
- Replies: 8
- Views: 2131
How do associated characters work?
What's the purpose of LuaPlayer.get_associated_characters()? I've run a quick test and it doesn't return anything - why isn't LuaPlayer.character included in the result (when the player is connected)?
- Wed Oct 20, 2021 6:57 pm
- Forum: Modding help
- Topic: Serialise instances of classes to JSON
- Replies: 8
- Views: 2241
Re: Serialise instances of classes to JSON
I've found this topic which is similar. https://forums.factorio.com/viewtopic.php?t=74131&p=448975. Rseding91 replied, and said none of the options would happen. I agree that modifying the source classes to add serialisation would be very detrimental, but I'd ask if Factorio could provide a util...
- Tue Oct 19, 2021 6:15 am
- Forum: Modding help
- Topic: Serialise instances of classes to JSON
- Replies: 8
- Views: 2241
Re: Serialise instances of classes to JSON
Sorry, I'm confused by your answer. I think you're describing, at a high level, how to convert an object to a table/JSON - that's something I can do manually, but it's a lot of work. I think it might be possible to generate code programmatically. I'd start by categorising each class into one of thre...
- Mon Oct 18, 2021 6:53 pm
- Forum: Modding help
- Topic: Serialise instances of classes to JSON
- Replies: 8
- Views: 2241
Serialise instances of classes to JSON
I want to export as much live data as possible from Factorio. I'm aiming to create a live map of Factorio, in the style of the Minecraft mod Dynmap. I also hope to make a platform that will be a good basis for some other mods, as well as learning some new tech. To do this I want to react to Factorio...