Get player surface during on_nth_tick
-
- Smart Inserter
- Posts: 2548
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Get player surface during on_nth_tick
To be specific, I'm trying to update the functionality of the mod Steinios Wind Sensor (a EvoGUI plugin mod) for use in another mod I'm making. However, in the wind sensor mod, they pull the wind data only from game.surfaces["nauvis"]. I'd like to change this so it'll pull from whichever surface the player is currently on, but player is unavailable in on_nth_tick, which I guess kind of makes sense. I'm not fluent enough in Factorio control stage modding to know how to solve this.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles
Re: Get player surface during on_nth_tick
All player objects are available in on_nth_tick using game.get_player(). Which player do you want though? Since that mod's description says single-player only, you can use game.get_player(1) to get access to the player. Each player has a surface attribute which you can use to get the surface.FuryoftheStars wrote: ↑Sat Nov 06, 2021 3:09 pmTo be specific, I'm trying to update the functionality of the mod Steinios Wind Sensor (a EvoGUI plugin mod) for use in another mod I'm making. However, in the wind sensor mod, they pull the wind data only from game.surfaces["nauvis"]. I'd like to change this so it'll pull from whichever surface the player is currently on, but player is unavailable in on_nth_tick, which I guess kind of makes sense. I'm not fluent enough in Factorio control stage modding to know how to solve this.
PS this is data stage modding not control stage modding
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
-
- Smart Inserter
- Posts: 2548
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Get player surface during on_nth_tick
The old wind sensor mod is single player, but is EvoGUI? I don't see that in it's description and what parts of the code I've been able to parse do make references to player objects like it should support multi. That game.get_player() may work, though, thanks!Xorimuth wrote: ↑Sat Nov 06, 2021 3:19 pmAll player objects are available in on_nth_tick using game.get_player(). Which player do you want though? Since that mod's description says single-player only, you can use game.get_player(1) to get access to the player. Each player has a surface attribute which you can use to get the surface.FuryoftheStars wrote: ↑Sat Nov 06, 2021 3:09 pmTo be specific, I'm trying to update the functionality of the mod Steinios Wind Sensor (a EvoGUI plugin mod) for use in another mod I'm making. However, in the wind sensor mod, they pull the wind data only from game.surfaces["nauvis"]. I'd like to change this so it'll pull from whichever surface the player is currently on, but player is unavailable in on_nth_tick, which I guess kind of makes sense. I'm not fluent enough in Factorio control stage modding to know how to solve this.
PS this is data stage modding not control stage modding
Oh, this is going to be confusing if control.lua is called data stage and there are data.lua files that are a different stage....
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles
Re: Get player surface during on_nth_tick
Oh no I am actually an idiot... control.lua is of course control stage modding.FuryoftheStars wrote: ↑Sat Nov 06, 2021 3:27 pm
Oh, this is going to be confusing if control.lua is called data stage and there are data.lua files that are a different stage....
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Re: Get player surface during on_nth_tick
Shouldn't this be a sensor you place on a surface and then it shows the direction on that surface?
If it's something the player carries around then you have to keep a list of all players and update each players sensor.
If it's something the player carries around then you have to keep a list of all players and update each players sensor.
-
- Smart Inserter
- Posts: 2548
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Get player surface during on_nth_tick
Well, I don’t think the EvoGUI mod works that way. I don’t think I can tie it’s readout to the presence of an entity. And I didn’t want to have to create my own UI….
That said, as I’ve been mulling this situation around more, I think while the EvoGUI mod may itself work ok with multiplayer and multisurface, I’m not so sure that using its remote.call function to add and update what that mod refers to as sensors will. As a part of the remote.call functions, it does not take in player information. This means I’m either adding one sensor that gets its data overwritten from each player, or I put a separate sensor for each player that is visible to all players, cluttering the UI.
That said, as I’ve been mulling this situation around more, I think while the EvoGUI mod may itself work ok with multiplayer and multisurface, I’m not so sure that using its remote.call function to add and update what that mod refers to as sensors will. As a part of the remote.call functions, it does not take in player information. This means I’m either adding one sensor that gets its data overwritten from each player, or I put a separate sensor for each player that is visible to all players, cluttering the UI.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles