Reading file by lua
Reading file by lua
I need to read file contents by lua
file was in directory script-output
and contains text
file was in directory script-output
and contains text
Re: Reading file by lua
That's not possible.
You can work around it though, at least in single player. Have your mod write to the file via serpent.dump to let's say output.lua
Create a symlink or the Linux equivalent in your mod folder pointing to output.lua
Now you can do something like: variable = require "output" in control.lua
Each time you update/rewrite the file you need to reload the game for the changes to be read.
Quite hacky
You can work around it though, at least in single player. Have your mod write to the file via serpent.dump to let's say output.lua
Create a symlink or the Linux equivalent in your mod folder pointing to output.lua
Now you can do something like: variable = require "output" in control.lua
Each time you update/rewrite the file you need to reload the game for the changes to be read.
Quite hacky
Re: Reading file by lua
It's it's unbelivable...
WHY I CAN"T JUST READ FILE?! FACTORIO, WHY YOUR LUA IS SO STRANGE!!!
WHYYYY>>>>
Okay...
Let's try to hack it like this, so this is strange.....
WHY I CAN"T JUST READ FILE?! FACTORIO, WHY YOUR LUA IS SO STRANGE!!!
WHYYYY>>>>
Okay...
Let's try to hack it like this, so this is strange.....
-
- Filter Inserter
- Posts: 952
- Joined: Sat May 23, 2015 12:10 pm
- Contact:
Re: Reading file by lua
because desyncscraftoBot wrote:It's it's unbelivable...
WHY I CAN"T JUST READ FILE?! FACTORIO, WHY YOUR LUA IS SO STRANGE!!!
WHYYYY>>>>
Okay...
Let's try to hack it like this, so this is strange.....
factorio relies on each mod doing the exact same thing on each client
arbitrary files don't allow that
Re: Reading file by lua
Wow wow relax. I don't think it even is neccecary to read/write files because what is in global tables stays there no matter how many times you restart Factorio. And I think that'd way easier too !craftoBot wrote:It's it's unbelivable...
WHY I CAN"T JUST READ FILE?! FACTORIO, WHY YOUR LUA IS SO STRANGE!!!
WHYYYY>>>>
Okay...
Let's try to hack it like this, so this is strange.....
Edit i take that back !
I'm now working on my The Underground mod and i wanted to just write down the entity names and their position relevant to the others in a file...
Last edited by jorgenRe on Wed Aug 12, 2015 5:58 pm, edited 1 time in total.
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^Thanks for listening to our suggestions, devs !
I would jump of joy if we could specify which tiles spawned in a surfaces
Re: Reading file by lua
ratchetfreak wrote:because desyncscraftoBot wrote:It's it's unbelivable...
WHY I CAN"T JUST READ FILE?! FACTORIO, WHY YOUR LUA IS SO STRANGE!!!
WHYYYY>>>>
Okay...
Let's try to hack it like this, so this is strange.....
factorio relies on each mod doing the exact same thing on each client
arbitrary files don't allow that
I can check for file existance, i need only to read file content to send it into sync tables.....
It's strange that standart io.* package of lua is removed
Re: Reading file by lua
I know, and i just need to export file from factorio to use by another program e.g texteditor and then import edited file back to gamejorgenRe wrote:Wow wow relax. I don't think it even is neccecary to read/write files because what is in global tables stays there no matter how many times you restart Factorio. And I think that'd way easier too !craftoBot wrote:It's it's unbelivable...
WHY I CAN"T JUST READ FILE?! FACTORIO, WHY YOUR LUA IS SO STRANGE!!!
WHYYYY>>>>
Okay...
Let's try to hack it like this, so this is strange.....
-
- Filter Inserter
- Posts: 952
- Joined: Sat May 23, 2015 12:10 pm
- Contact:
Re: Reading file by lua
then put the result data in a lua file that the mod importscraftoBot wrote: I know, and i just need to export file from factorio to use by another program e.g texteditor and then import edited file back to game
Re: Reading file by lua
I already understand, but i want this data in plain text, not lua, but i will do like this....ratchetfreak wrote:then put the result data in a lua file that the mod importscraftoBot wrote: I know, and i just need to export file from factorio to use by another program e.g texteditor and then import edited file back to game
Re: Reading file by lua
OMFG! I'm ashamed i did not think of that... For my defense, i play on Windows, on which you can do the same with an admin command line:Choumiko wrote:That's not possible.
You can work around it though, at least in single player. Have your mod write to the file via serpent.dump to let's say output.lua
Create a symlink or the Linux equivalent in your mod folder pointing to output.lua
Now you can do something like: variable = require "output" in control.lua
Each time you update/rewrite the file you need to reload the game for the changes to be read.
Quite hacky
mklink link target
Re: Reading file by lua
I think I understand the desync problem, but what if I want to make a mod that works only in single player? Then it would be perfectly ok to change the mod behavior from outside, or not?ratchetfreak wrote:because desyncscraftoBot wrote:It's it's unbelivable...
WHY I CAN"T JUST READ FILE?! FACTORIO, WHY YOUR LUA IS SO STRANGE!!!
WHYYYY>>>>
Okay...
Let's try to hack it like this, so this is strange.....
factorio relies on each mod doing the exact same thing on each client
arbitrary files don't allow that
I think it should be left to the discretion of the mod programmer whether or not to use methods that would not work in multiplayer, that means whether or not to read from files.
Re: Reading file by lua
I was planning to write a mod that cannot do things that the player cannot do, in essence a voice interface for playing Factorio, including some natural language understanding parts.
This should not cause any desyncs, but of course it would require to get some streaming data from the outside into a mod.
Has such a type of mod be considered (and maybe ruled out for certain reasons)?
This should not cause any desyncs, but of course it would require to get some streaming data from the outside into a mod.
Has such a type of mod be considered (and maybe ruled out for certain reasons)?
Re: Reading file by lua
Since 2015, the devs have added RCON support to the headless server. This allows arbitrary input while keeping multiplayer compatibility.
Re: Reading file by lua
cant you just use this require hack with different filenames?
edit: works only on start
edit: works only on start
creator of 55 mods
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds
My api requests/suggestions: ui relative for overlay||Grenade arc||Player Modifiers||textbox::selection||Singleplayer RCON||disable car's ground sounds