Wind Turbines

by OwnlyMe

Animated wind turbines that turn into wind direction

Content
4 days ago
0.17 - 2.0
247
Power

b non-recoverable error

4 years ago
(updated 4 years ago)

Im getting a non-recoverable error,

Error while running event windturbines::on_nth_tick(61)
windturbines/control.lua:151: attempt to index field '?' (a nil value)
stack traceback:
windturbines/control.lua:151: in function 'destroy_turbine'
windturbines/control.lua:103: in function <windturbines/control.lua:90>

im running latest version as far as i can tell,

from examaning the code and adding some log entries in on_nth_tick(61, function(event) and else where

it appears that it runs through the loop a few times and then something destroys a turbine premeturely removing it from the global.turbines table
then
if global.turbines[unit_number].turbine then
global.turbines[unit_number].turbine.destroy()
end
tries to destroy it but global.turbines[unit_number] doesnt exist

i can work around the error, by adding "not(global.turbines[unit_number] == nil) and" for each destroy, but dont know whats removing it from the table

function destroy_turbine(unit_number, died)
if not global.turbines[unit_number] then return end
if died then
if global.turbines[unit_number].base and global.turbines[unit_number].base.valid then
global.turbines[unit_number].base.die(global.turbines[unit_number].base.force)
end
elseif global.turbines[unit_number].base then
global.turbines[unit_number].base.destroy()
end
if not(global.turbines[unit_number] == nil) and global.turbines[unit_number].turbine then
global.turbines[unit_number].turbine.destroy()
end
if not(global.turbines[unit_number] == nil) and global.turbines[unit_number].shadow then
global.turbines[unit_number].shadow.destroy()
end

if not(global.turbines[unit_number] == nil) and global.turbines[unit_number].collision_box then
    global.turbines[unit_number].collision_box.destroy()
end

global.turbines[unit_number]=nil

end

4 years ago
(updated 4 years ago)

i was ordering an entity to die which raised the corresponding event and triggered another destroy_turbine call
will be fixed in the next version (.5)

4 years ago

fixed :)

New response