Additional turrets

by sore68

Adds more turrets and shells.

Content
7 years ago
0.14 - 0.15
76
Combat

b Howitzer bug

7 years ago

Hi, great mod but i can't make the howitzer work. When i load ammo and power it a red cross appears on it's ammo inventory and it does not fire. And i some times got an error that says additional turrets control.lua attempted to perform arithmetic on field '?' nil value and game closes

7 years ago

Error while running event Additional-Turret::on_tick (ID 0)
Additional-Turret/control.lua:1086: attempt to perform arithmetic on field '?' (a string value)
This is the error

7 years ago

i have the same problem

7 years ago
(updated 7 years ago)

1: Crash - repro
I only seem to get the issue when powering up more than 1 Howitzer at the same time.
(i.e If I place the howitzers one-by-one in an already powered area, I can play without any issue. If I place howitzer first, then place a power-pole so that it touches 2+ Howitzers, 100% crash within a minute or so.)

2: Crash - cause
I thought the issue might be that the offending line(and the following line) was not grabbing x-and-y coordinates of radar-scan-events, but this modified code did not help:
---begin paste---
local offsetX = tonumber(target[1]) + math.random(0,offsetR) * math.sin(math.random()(math.pi2))
local offsetY = tonumber(target[2]) + math.random(0,offsetR) * math.sin(math.random()(math.pi2))
---end paste---

What does the "ID 0" for "Tick" mean? Usually you would have a delta-time coming in for a Tick-function... hmm... I could try making sure the Tick does not receive a NIL argument. Why it would get this, I do not understand.

[EDIT]
Solved the crash!
Turns out "target" is nil when 2 or more Howitzers gets activated at the same time. Replacing the lines above with this, safeguards the crash. However, I'm not 100% sure if ammunition is counted correctly in networked situations. You'll have to evaluate this code yourself, Sore68. It's working well enough for me to continue my singleplayer game. ^_^
local offsetX = tonumber(target[1])
local offsetY = tonumber(target[2])
if (offsetX and offsetY) then
offsetX = offsetX + math.random(0,offsetR) * math.sin(math.random()(math.pi2))
offsetY = offsetY + math.random(0,offsetR) * math.sin(math.random()(math.pi2))

3: Heavy Howitzer not working properly
I've spent some time going through the script/testing, but I have yet to figure some stuff out before I can locate the reason behind the Howitzer not firing dependently... Even with a single howitzer, in creative mode.
(On that note - comment your code, dude! :D )

[EDIT]
Finally managed to make the Howitzer work...!!!
The Howitzer attempts to fire at certain intervals.
However, the scan-function keeps resetting the variable you use for storing the "target" found by the scanner. Thus, if the scanner does a new scan that contains no targets, before the Howitzer has fired - the Howitzer will never fire.
The offending is (around line 798)
function On_Scanned(event)
...
event.radar.backer_name = ""
...
Removing/commenting this line makes the howitzer fire reliably.

Though - because of how the radar works (only updating the oldest sector) it feels like it would be so much better to use a global list that could be shared with other Howitzers and a random target(in range) would be chosen before each attack.

4: Grovelling
I adore the automation that the Howitzer adds to the gameplay (when it works), but I personally see little to no use for the other turrets. So for me the other turrets merely clogs up the research interface. In the best of worlds - the Howitzer would be a separate mod. :) But that's kind of splitting hairs...
Thank you for making the mod! :)

7 years ago
(updated 7 years ago)

Can you upload that file? with the permission of the author of course
I still can't make it work. It fires once or twice if i'm lucky in random times then never again.

7 years ago
(updated 7 years ago)

I have done some balancing changes for my own pleasure... (Mainly MUCH higher scan-rate, MUCH higher energy cost and increased range to account for my "RailWorld" with extremely low frequency of ore)
...so, I don't really wish to upload as a separate (and possibly confusing) mod which risks causing flack for either me and/or Sore68.

The changes are limited to two text(lua) files, and resides inside a zip-file that you can easily open and edit yourself. All you need is a program like "Winzip" or "Winrar". Just open the mod, open the corresponding files, paste in the new code, save, update the archive, done! :)
I do believe the actual bugs are confined to "Control.lua", so you could try only changing that one first and I think you will avoid my re-balancing changes. Not 100% sure about this though. :)

1: Additional-Turret_0.1.5\Control.lua
https://justpaste.it/16yan

2: Additional-Turret_0.1.5\prototypes\Artillery-Turret.lua
https://justpaste.it/16ybb

NB: Mods are located in: C:\Users[USER]\AppData\Roaming\Factorio\mods
REMEMBER: Always make a backup when you're doing stuff like this. :)

7 years ago

Thank you for the response. I'll try this out now.

7 years ago

Thank you for bug report and comments. :)

I'll take a look at the error as much as possible.

And there is no problem with the derived version.
If you want to add, share, or do something, you can do it.

Thank you!! :D

New response