Page 1 of 1

Sandbox buttons and mods

Posted: Mon Feb 23, 2015 11:42 pm
by y.petremann
In sandbox scenario, there is two questions with two buttons, one to accept, the other to refuse ...
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
by

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
Replace :

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
by

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
Secondly, I may ask you if there is a correct way to insert a question like that after (or before) they appear ?

Re: Sandbox buttons and mods

Posted: Thu Feb 26, 2015 10:06 am
by kovarex
You are completely right, thanks for the help, it is fixed for 0.11.17
y.petremann wrote:Secondly, I may ask you if there is a correct way to insert a question like that after (or before) they appear ?
Well I believe that the best way is to insert the question independently of the main script story logic