Hello there !
I would like to make a mod, or a mod request :
I'd like to be able to switch a switch without the need to go inside it's window, by Alt+clicking on it, or middle clicking on it for exemple, or even simply clic on it bypassing the window if it has no other use.
The Discord's quick questions channel, after answering that its indeed not possible in vanilla game, kindly gave me all documentation needed about mod making when I said it would be a nice addition, and that I'd even love to try myself ; But after looking at it yesterday afternoon, I have to admit that I'm totally overwhelmed... ^^
Thanks.
Switch a switch with a simple clic
Re: Switch a switch with a simple clic
The power switch's GUI does have other uses, notably when using it with the circuit network, so I wouldn't advise bypassing it entirely.
However, you can add a custom-input to work with it.
data.lua:
Give an appropriate translation in locale/en/strings.cfg:
And finally handle the event in control.lua:
And that should do it!
However, you can add a custom-input to work with it.
data.lua:
Code: Select all
data:extend{
{
type = "custom-input",
name = "toggle-power-switch",
key_sequence = "ALT + mouse-button-1",
action = "lua",
consuming = "game-only"
}
}
Code: Select all
[controls]
toggle-power-switch=Toggle power switch
Code: Select all
script.on_event("toggle-power-switch", function(event)
local player = game.players[event.player_index]
local entity = player.selected
if entity and entity.valid and entity.type == "power-switch" then
entity.power_switch_state = not entity.power_switch_state
end
end)
Re: Switch a switch with a simple clic
Thanks for the quick answer !
Ah yes circuits, and I'm starting to think about it, will try to learn, so indeed lets prefer to keep the window ^^
So, I make it in a mod structure right ? I looked inside another mod to figure, made the files and folder, zip it, the game doesn't see it.
Is it ok if I did all that from windows alone ? I used notepad and renamed .txt as .lua. Made sure I have right file names and folder positions.
Ah yes circuits, and I'm starting to think about it, will try to learn, so indeed lets prefer to keep the window ^^
So, I make it in a mod structure right ? I looked inside another mod to figure, made the files and folder, zip it, the game doesn't see it.
Is it ok if I did all that from windows alone ? I used notepad and renamed .txt as .lua. Made sure I have right file names and folder positions.
Re: Switch a switch with a simple clic
You need an info.json file: https://wiki.factorio.com/Tutorial:Modd ... up_in_game
Re: Switch a switch with a simple clic
PFQNiet, it works, it works ! ^^
Still had to trial and error a bit, I'm ashamed to say that the lamest of those error was because I kept all the "CODE: SELECT ALL" in the files lmao
But damn it works ! I feel like a modder now After all, I almost made all the work !
Thanks much ! Big thanks ! It's uber practical, so smooth
Still had to trial and error a bit, I'm ashamed to say that the lamest of those error was because I kept all the "CODE: SELECT ALL" in the files lmao
But damn it works ! I feel like a modder now After all, I almost made all the work !
Thanks much ! Big thanks ! It's uber practical, so smooth
Re: Switch a switch with a simple clic
Welcome to the realm of modding Make sure you understand what the code is doing and I hope to see your creations in future!