Get player surface during on_nth_tick

Place to get help with not working mods / modding interface.
Post Reply
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2541
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Get player surface during on_nth_tick

Post by FuryoftheStars »

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

Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: Get player surface during on_nth_tick

Post by Xorimuth »

FuryoftheStars wrote:
Sat Nov 06, 2021 3:09 pm
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.
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.

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

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2541
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Get player surface during on_nth_tick

Post by FuryoftheStars »

Xorimuth wrote:
Sat Nov 06, 2021 3:19 pm
FuryoftheStars wrote:
Sat Nov 06, 2021 3:09 pm
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.
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.

PS this is data stage modding not control stage modding :)
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!

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

Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: Get player surface during on_nth_tick

Post by Xorimuth »

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....
Oh no I am actually an idiot... control.lua is of course 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

mrvn
Smart Inserter
Smart Inserter
Posts: 5709
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Get player surface during on_nth_tick

Post by mrvn »

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.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2541
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Get player surface during on_nth_tick

Post by FuryoftheStars »

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.
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

Post Reply

Return to “Modding help”