game.write_to_clipboard
- LuziferSenpai
- Filter Inserter
- Posts: 392
- Joined: Tue Jul 08, 2014 10:06 am
- Contact:
game.write_to_clipboard
Hey,
it would be cool if we could get a the function in the Title to copy a String into the Clipboard of the User.
Greetz,
Luzifer
it would be cool if we could get a the function in the Title to copy a String into the Clipboard of the User.
Greetz,
Luzifer
Re: game.write_to_clipboard
That would be dangerous in the hands of sloppy modders.
Put in on_tick and have it dump a large amount of data to clipboard and the game would hopefully crash before the computer.
Put in on_tick and have it dump a large amount of data to clipboard and the game would hopefully crash before the computer.
- LuziferSenpai
- Filter Inserter
- Posts: 392
- Joined: Tue Jul 08, 2014 10:06 am
- Contact:
Re: game.write_to_clipboard
Yea, but that can happen with MANY thing, there is game.write_file toomat1k wrote: Sun Sep 15, 2019 6:15 pm That would be dangerous in the hands of sloppy modders.
Put in on_tick and have it dump a large amount of data to clipboard and the game would hopefully crash before the computer.

Re: game.write_to_clipboard
That however can't deny the players the ability to use copy/paste while the game is running. If on tick was used with write_to_clipboard then as long as the game was running you would be unable to use your clipboard. As anything you try copy will immediately be replaced by the game.LuziferSenpai wrote: Sun Sep 15, 2019 6:54 pmYea, but that can happen with MANY thing, there is game.write_file toomat1k wrote: Sun Sep 15, 2019 6:15 pm That would be dangerous in the hands of sloppy modders.
Put in on_tick and have it dump a large amount of data to clipboard and the game would hopefully crash before the computer.![]()
- LuziferSenpai
- Filter Inserter
- Posts: 392
- Joined: Tue Jul 08, 2014 10:06 am
- Contact:
Re: game.write_to_clipboard
Yea, still its useful
Re: game.write_to_clipboard
What about a command that itself runs lua? (like /c but puts the "return" value on clipboard)
for example.
This way a player must explicitly tell the game to do it, and can't be done randomly via script.
Code: Select all
/clipboard __modname__ return serpent.line(global.my_table)
This way a player must explicitly tell the game to do it, and can't be done randomly via script.
Re: game.write_to_clipboard
game.write_to_clipboard has a bunch of issues. Not sure if the benefits outweigh the annoyances.
Better off just having another kind of GUIelement you can add where you can specify what you want copied to the clipboard. If the user clicks that button, it shows a factorio supplied window of its own showing the text and a copy button to actually copy to the clipboard. Kind of like the existing Blueprint export window. It would show a text window previous and a Copy button as well as a Cancel button.
ClipboardElement(luaGUIelement ?)
text_to_clipboard : what the mod wants to send to the clipboard
This way:-
the mod can copy whatever into that element. It would look much like the existing blueprint export window.
the player *chooses* to click it. or they can ignore it.
the player can cancel if they don't like what they see.
no "per tick" nonsense.
no "overwriting clipboard" nuisance mods.
Why I'd want this:
standardise export of data via clipboard. common GUI element.
exfil settings from mods for whatever reason.
other blueprint-like settings can easily be exported without using write_file
notepad type mods can export and import todo lists for factory management.
Better off just having another kind of GUIelement you can add where you can specify what you want copied to the clipboard. If the user clicks that button, it shows a factorio supplied window of its own showing the text and a copy button to actually copy to the clipboard. Kind of like the existing Blueprint export window. It would show a text window previous and a Copy button as well as a Cancel button.
ClipboardElement(luaGUIelement ?)
text_to_clipboard : what the mod wants to send to the clipboard
This way:-
the mod can copy whatever into that element. It would look much like the existing blueprint export window.
the player *chooses* to click it. or they can ignore it.
the player can cancel if they don't like what they see.
no "per tick" nonsense.
no "overwriting clipboard" nuisance mods.
Why I'd want this:
standardise export of data via clipboard. common GUI element.
exfil settings from mods for whatever reason.
other blueprint-like settings can easily be exported without using write_file
notepad type mods can export and import todo lists for factory management.
Re: game.write_to_clipboard
Though i like the convenience of putting stuff on clipboard, functionality to do this already exists.
We do not need to re-invent the wheel.
Use log(), e.g. log(serpent.block(global)) then get it from your log file.
game.write_file is good too.
There's your standardized export of data.
Yeah and i can crash your factorio by doing while(true) log("hi") end.
But we do not describe while() loops as "dangerous".
Re: game.write_to_clipboard
Files just aren't the same as the clipboard. Its as simple as that. Especially when you're exporting/importing blueprint-like structures. These are GUI operations. Much easier to explain to a room of kids how to export a blueprint etc than dig through the filesystem if that was the only way. I know this because Ive needed to do it.
Take my trainstops csv mod. It lets you import/export every trainstop and edit it outside factorio in something like libreoffice as a spreadsheet table. I can do that because I can show the text box and have copy and paste. Yes I have a csv export. But its clumsy. How do I then import the data back in using same mechanism? I can't. Using the clipboard makes the whole GUI based operation smooth, safe and useful. No digging through file structures under AppData etc.
I fully understand why game.read_file isnt an option the devs would be excited about. I don't want factorio based malware. I'm sure there are possibilities for mitigating these kinds of threats. Go for it. Limit the folder structure etc. I'm not necessarily against it. I can definitely see the downside of enabling it however.
For my purposes its basically a need for a button that copies mod supplied text to the clipboard in an easy way that people can easily follow.
Take my trainstops csv mod. It lets you import/export every trainstop and edit it outside factorio in something like libreoffice as a spreadsheet table. I can do that because I can show the text box and have copy and paste. Yes I have a csv export. But its clumsy. How do I then import the data back in using same mechanism? I can't. Using the clipboard makes the whole GUI based operation smooth, safe and useful. No digging through file structures under AppData etc.
I fully understand why game.read_file isnt an option the devs would be excited about. I don't want factorio based malware. I'm sure there are possibilities for mitigating these kinds of threats. Go for it. Limit the folder structure etc. I'm not necessarily against it. I can definitely see the downside of enabling it however.
For my purposes its basically a need for a button that copies mod supplied text to the clipboard in an easy way that people can easily follow.
Re: game.write_to_clipboard
Importing things from a file or a players clipboard isn't doable because it would break determinism in multiplayer. There are other reasons as well, but that is the main one.adamius wrote: Wed Dec 18, 2019 11:07 am Take my trainstops csv mod. It lets you import/export every trainstop and edit it outside factorio in something like libreoffice as a spreadsheet table. I can do that because I can show the text box and have copy and paste. Yes I have a csv export. But its clumsy. How do I then import the data back in using same mechanism? I can't. Using the clipboard makes the whole GUI based operation smooth, safe and useful. No digging through file structures under AppData etc.
I fully understand why game.read_file isnt an option the devs would be excited about. I don't want factorio based malware. I'm sure there are possibilities for mitigating these kinds of threats. Go for it. Limit the folder structure etc. I'm not necessarily against it. I can definitely see the downside of enabling it however.
Re: game.write_to_clipboard
Correct. The devs have already said this. File access in general systems can be made deterministic but its a world of pain guaranteeing it. Not worth the desync reports. Pragmatically the pain involved wont make the game substantially more fun either.Importing things from a file or a players clipboard isn't doable because it would break determinism in multiplayer. There are other reasons as well, but that is the main one.
Don't conflate clipboard access with file access.Clipboard access is far more straightforward.