The main problem is that when you uses some mods that asks questions at the same time like test mode, it would consider that they have been answered since a button has been triggered.
Firstly, you can simply make theses changes :
Replace :
Code: Select all
function(event)
if event.name == defines.events.onguiclick then
local player = game.getplayer(event.playerindex)
if event.element.name == "button_use_chest" then
buildstartingchest(player)
end
player.gui.top.button_use_chest.destroy()
player.gui.top.button_no_chest.destroy()
return true
end
return false
end
Code: Select all
function(event)
if event.name == defines.events.onguiclick then
local player = game.getplayer(event.playerindex)
if event.element.name == "button_use_chest" then
buildstartingchest(player)
elseif event.element.name ~= "button_no_chest" then
return false
end
player.gui.top.button_use_chest.destroy()
player.gui.top.button_no_chest.destroy()
return true
end
return false
end
Code: Select all
function(event)
if event.name == defines.events.onguiclick then
local player = game.getplayer(event.playerindex)
if event.element.name == "button_technologies_researched" then
player.force.researchalltechnologies()
end
player.gui.top.button_technologies_researched.destroy()
player.gui.top.button_technologies_normal.destroy()
return true
end
return false
end
Code: Select all
function(event)
if event.name == defines.events.onguiclick then
local player = game.getplayer(event.playerindex)
if event.element.name == "button_technologies_researched" then
player.force.researchalltechnologies()
elseif event.element.name ~= "button_technologies_normal" then
return false
end
player.gui.top.button_technologies_researched.destroy()
player.gui.top.button_technologies_normal.destroy()
return true
end
return false
end