[0.11.20] Displaying range of turrets [v1.0.0]

Topics and discussion about specific mods
Post Reply
kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

[0.11.20] Displaying range of turrets [v1.0.0]

Post by kds71 »

Note: If you are using Factorio 0.12.x, you can get updated version of this mod here.

Another mod inspired by a reddit post.

This mod adds an item that allows you to check range of a turret.
Since version 0.0.3 it works with vanilla, DyTech and MoMods turrets only. All supported turrets (and their respective ranges) are listed in config.lua file in this mod - if you have a modded turret that is not listed here (or it is listed, but you are using a mod that changes range of this turret), you will have to edit config.lua file.

Features:
  • adds a new technology called "turrets range probing" (requires electronics and turrets)
  • adds a new item, "turret probe" with recipe unlocked by this technology
How to use:
  • click on a turret with a turret probe in your hand to see a range of this turret
  • click elsewhere (still with a turret probe in your hand) to remove displayed range from the screen
  • you may click on several turrets in a row to see their range together (to check for overlapping etc.)
Screenshot
I marked it with [0.11.20] because this is the version of Factorio that I'm currently using, but it probably works with older versions as well.

I would be grateful for your feedback :)
Changelog
Attachments
turrets-range_1.0.0.zip
(10.16 KiB) Downloaded 2969 times
Last edited by kds71 on Wed Aug 12, 2015 12:06 pm, edited 10 times in total.

Doublespin
Inserter
Inserter
Posts: 36
Joined: Thu May 21, 2015 12:46 pm
Contact:

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Post by Doublespin »

You can read out with data.raw table.
Search the site for "turret" then you will find the diffrent categories. I think most mods will add their turrets into these existing categories but if they make their own then you probably will have to adjust your code manually to them.

You can read them out with the pairs loop
And you should use the data-updates.lua which is loaded after the the diffrent mods. I dont know if it is possible with control.lua
Last edited by Doublespin on Thu Jun 11, 2015 10:02 pm, edited 2 times in total.
I'm not a native speaker (obviously), so I will appreciate every pm with corrections :)

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Post by kds71 »

Both data.lua and data-updates.lua (where data.raw is accessible) are processed when the game is being loaded. I need to read the range of turrets while the game is running, so control.lua is my only option - and you can't access data.raw from there.

Doublespin
Inserter
Inserter
Posts: 36
Joined: Thu May 21, 2015 12:46 pm
Contact:

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Post by Doublespin »

I dont know much about lua and factorio but maybe this will work???
save the name of the turrets with their range as a table.
In the control.lua you can cycle through the table with pairs so you wont need any hard coded names
You can fill the table with names and ranges in the data-updates.lua
I'm not a native speaker (obviously), so I will appreciate every pm with corrections :)

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Post by kds71 »

I'm affraid it is still impossible :) There is no way to create any variable that will be shared between data.lua (or data-updates.lua) and control.lua.

Well, I'm going to submit a request for implementing that as a new feature in the modding API, for now I'm going to simply hardcode turret ranges from the most popular mods in my control.lua file, it should be sufficient for a while.

Doublespin
Inserter
Inserter
Posts: 36
Joined: Thu May 21, 2015 12:46 pm
Contact:

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Post by Doublespin »

Ok just for the theory:
You can make a valid recipe with the free choice of name. So this will be your variable. The recipe can be disabled and hided. So a player wont see anything of it.
This name can be written in data-updates-lua and accessed in control.lua, right?? To make sorting easier you can create a crafting category.

I not saying you should do this(this sounds more like hacking :D), im just interested if it is possible :)
I'm not a native speaker (obviously), so I will appreciate every pm with corrections :)

User avatar
-root
Filter Inserter
Filter Inserter
Posts: 651
Joined: Tue Jul 01, 2014 11:24 pm
Contact:

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Post by -root »

this could be one of those incredibly handy mods...

is there anyway to make it like roboports where if you hover the mouse over it, it shows you the range? having to use an item to view the range isn't exactly ideal, i get there are limits in the modding API though....

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [WIP][0.11.20] Displaying range of turrets [v0.0.2]

Post by kds71 »

-root wrote:is there anyway to make it like roboports where if you hover the mouse over it, it shows you the range? having to use an item to view the range isn't exactly ideal, i get there are limits in the modding API though....
Yeah, it is not possible with current state of modding API :(

More positive note: I added support for DyTech and MoMods turrets and I exposed all turret ranges to config file, so you can add your own turrets rather easily now :)

Peter34
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Mon Nov 10, 2014 12:44 pm
Contact:

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Post by Peter34 »

Can more be done now, with the extra modding options in alpha 12?

Talguy
Fast Inserter
Fast Inserter
Posts: 105
Joined: Tue Apr 29, 2014 8:54 pm
Contact:

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Post by Talguy »

Bump :)

Would be awesome if this supports 0.12 :)

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Post by kds71 »

I updated this mod to work with Factorio 0.12.x, sorry for the delay.
Can more be done now, with the extra modding options in alpha 12?
Nope, sorry - there is still no way to read the range of a turret in Factorio 0.12.

Mozleron
Manual Inserter
Manual Inserter
Posts: 1
Joined: Wed May 18, 2016 3:26 pm
Contact:

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Post by Mozleron »

Having not delved into the depths that is the Factorio modding system, I'm wondering if there is a way to hook/piggyback on the mechanism used to see the connection range from power poles to see the firing range of turrets? It's clearly a system the devs put into place to display the functional range of an object. I'm just curious about how modular they made that bit of functionality, because it seems like it should be pretty easy to port to other objects in the game.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Post by Adil »

Nope, you can't have arbitrary overlay display for arbitrary entity in game.
Also, there were no connection range display last time I've checked (0.12.30). There's only coverage overlay and that one is hardcoded to be square at that.
Though, there might be some trick with data.lua scripting, I'll try to make that today.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: [0.11.20] Displaying range of turrets [v1.0.0]

Post by Adil »

Well, did it.
You still need updated version of this mod for inspecting them post-build.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Post Reply

Return to “Mods”