Page 1 of 2

read file

Posted: Thu Aug 29, 2019 6:20 pm
by gabberworld
adding support for read file or read json file ?

Re: read file

Posted: Thu Aug 29, 2019 6:39 pm
by eradicator
Will be added shortly after hell freezes over.

Re: read file

Posted: Thu Aug 29, 2019 6:44 pm
by gabberworld
eradicator wrote: Thu Aug 29, 2019 6:39 pm Will be added shortly after hell freezes over.
does Antarctica count, for me it looks like hell.

Re: read file

Posted: Thu Aug 29, 2019 7:06 pm
by eradicator
gabberworld wrote: Thu Aug 29, 2019 6:44 pm
eradicator wrote: Thu Aug 29, 2019 6:39 pm Will be added shortly after hell freezes over.
does Antarctica count, for me it looks like hell.
I called Satan and he said he only goes there on vacations. So: nope.

Re: read file

Posted: Thu Aug 29, 2019 7:45 pm
by slippycheeze
eradicator wrote: Thu Aug 29, 2019 6:39 pm Will be added shortly after hell freezes over.
...and at the risk of speaking for the developers, I'm in 100 percent agreement here: they won't add this, just like they won't add any other path for getting external input into the game. The intent seems to be very much the same as other games, where mods live in a very constrained sandbox, and they can't escape it easily.

I was pretty surprised that WriteFile dumps data instantly even in normal running, since most games sandbox that more heavily. There are no easy ways to get input working though.

PS: of course it is possible to escape the sandbox in Factorio, just as in every game, with sufficient creative thought. I wouldn't advise it, but you can probably figure out ways to bypass the restrictions if you try hard enough. After all, someone literally encoded data in small colored squares in one corner of the display to exfiltrate data from WoW, then read it by sampling that part of the screen and decoding it. So ... always possible, but never easy. :)

Re: read file

Posted: Thu Aug 29, 2019 8:02 pm
by gabberworld
you can't really look this game like other games.

they made at here very good modding stuff, not many game have this kind modding like it's here

Re: read file

Posted: Thu Aug 29, 2019 9:08 pm
by gabberworld
it's they decision tho if they want give us more power over the game

Re: read file

Posted: Fri Aug 30, 2019 7:45 am
by eradicator
gabberworld wrote: Thu Aug 29, 2019 9:08 pm it's they decision tho if they want give us more power over the game
Mainly they want to prevent crashes/desyncs. And reading random files from the system is *impossible* to make desync free, so it's not going to happen. You can read lua files from your mod directory because that's (within reason) guaranteed to be equal on all computers with the same mod version. If you want to read json, then encode your json as a string in a lua file and read that. If you want to read the whole harddisk of anybodys computer... then overthink your life decisions.

Re: read file

Posted: Fri Aug 30, 2019 8:42 am
by gabberworld
eradicator wrote: Fri Aug 30, 2019 7:45 am
gabberworld wrote: Thu Aug 29, 2019 9:08 pm it's they decision tho if they want give us more power over the game
Mainly they want to prevent crashes/desyncs. And reading random files from the system is *impossible* to make desync free, so it's not going to happen. You can read lua files from your mod directory because that's (within reason) guaranteed to be equal on all computers with the same mod version. If you want to read json, then encode your json as a string in a lua file and read that. If you want to read the whole harddisk of anybodys computer... then overthink your life decisions.
i think'ed more like same way like write_file works, but read whole harddisk of anybodys computer sounds great too

Re: read file

Posted: Fri Aug 30, 2019 9:17 am
by eradicator
gabberworld wrote: Fri Aug 30, 2019 8:42 am i think'ed more like same way like write_file works, but read whole harddisk of anybodys computer sounds great too
Maybe you should go to hell and personally file the request directly to Satan.

Re: read file

Posted: Fri Aug 30, 2019 3:24 pm
by slippycheeze
eradicator wrote: Fri Aug 30, 2019 7:45 am
gabberworld wrote: Thu Aug 29, 2019 9:08 pm it's they decision tho if they want give us more power over the game
Mainly they want to prevent crashes/desyncs. And reading random files from the system is *impossible* to make desync free, so it's not going to happen. You can read lua files from your mod directory because that's (within reason) guaranteed to be equal on all computers with the same mod version. If you want to read json, then encode your json as a string in a lua file and read that. If you want to read the whole harddisk of anybodys computer... then overthink your life decisions.
I should channel a Haskell fan and mention the IO monad... ;)

Re: read file

Posted: Fri Aug 30, 2019 4:02 pm
by Trebor
Ok, so you want to read an arbitrary file, follow these steps.
  • Install the Linux or Mac version of Factorio.
  • Create and install an unzipped mod, so directories are real directories.
  • Create in your mod directory a hard link to the file you want to read.
If Factorio follows soft links, create a soft link to /.

Re: read file

Posted: Fri Aug 30, 2019 5:14 pm
by eradicator
Trebor wrote: Fri Aug 30, 2019 4:02 pm Ok, so you want to read an arbitrary file, follow these steps.
You can not open non-.lua files even if they are inside the mod directory.

Re: read file

Posted: Fri Aug 30, 2019 5:16 pm
by Trebor
eradicator wrote: Fri Aug 30, 2019 5:14 pm
Trebor wrote: Fri Aug 30, 2019 4:02 pm Ok, so you want to read an arbitrary file, follow these steps.
You can not open non-.lua files even if they are inside the mod directory.
Just be creative with the hard link name.

Re: read file

Posted: Fri Aug 30, 2019 5:23 pm
by eradicator
Trebor wrote: Fri Aug 30, 2019 5:16 pm
eradicator wrote: Fri Aug 30, 2019 5:14 pm
Trebor wrote: Fri Aug 30, 2019 4:02 pm Ok, so you want to read an arbitrary file, follow these steps.
You can not open non-.lua files even if they are inside the mod directory.
Just be creative with the hard link name.
To what end? require() will simply throw an error if the file is trash.

Re: read file

Posted: Fri Aug 30, 2019 5:28 pm
by gabberworld
i think'ed use the require(), but that is a very ugly way todo

Re: read file

Posted: Fri Aug 30, 2019 5:38 pm
by eradicator
gabberworld wrote: Fri Aug 30, 2019 5:28 pm i think'ed use the require(), but that is a very ugly way todo
Back from hell so soon eh, i guess Satan didn't approve your request?

As this is already your second thread about "loading random files/mysql", maybe you should instead ask for help in the modding help forum and describe what you actually want to do. Factorio does infact have built-in support for converting json strings to lua tables for example.

Re: read file

Posted: Fri Aug 30, 2019 5:43 pm
by gabberworld
eradicator wrote: Fri Aug 30, 2019 5:38 pm
gabberworld wrote: Fri Aug 30, 2019 5:28 pm i think'ed use the require(), but that is a very ugly way todo
As this is already your second thread about "loading random files/mysql"
not sure what you talk at here, package.loadlib is totally different thing , it allows run custom maded lua dll's, if you mean that

Re: read file

Posted: Fri Aug 30, 2019 5:51 pm
by eradicator
gabberworld wrote: Fri Aug 30, 2019 5:43 pm
eradicator wrote: Fri Aug 30, 2019 5:38 pm
gabberworld wrote: Fri Aug 30, 2019 5:28 pm i think'ed use the require(), but that is a very ugly way todo
As this is already your second thread about "loading random files/mysql"
not sure what you talk at here, package.loadlib is totally different thing , it allows run custom maded lua dll's, if you mean that
It's totally the same thing in that it's "wanting to load some random file that is not lua code".

Re: read file

Posted: Fri Aug 30, 2019 5:55 pm
by gabberworld
only thing is lua stuff can be also build to inside dll soo technically its still lua code,

but that is nothing todo with read file request