Reading file by lua
Posted: Sun Aug 09, 2015 3:35 pm
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
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.....
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.....
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 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.....
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
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
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
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