Jump to content

Recommended Posts

Hello,

I'm new to DST modding and wondering if DST mod can write to external files.

At first, I was searching for a mod that could record character activities so that I could review my play history after I finished the game, like how many woods I collected each day, or when the ancient guardian died. Any kind of activity logging would be enough since then I can post-process the data to aggregate it. But I was out of luck and couldn't find any logging-related mod on the internet.

Then I decided to create one for myself and started learning about DST modding. It wasn't that bad since I was a bit familiar with Lua already. Soon I found out that DST hides the "io" module from the namespace of the mod scripts and I cannot open a file with "io.open". I assume this is on security concern, to prevent malicious mods from freely accessing users' file systems. There are some games where mods can write to a new file (in a limited way) like in factorio. I hope there's a way to do so in DST too.

So my questions are:

1. Is there a mod with a logging feature?

2. Is there a way to write to a custom file from DST mod?

3. Can I modify the game's code (bundled scripts) and forcefully unhide the io module and where should I look?

Any information is much appreciated since I'm digging through the codes cluelessly :/

Thank you in advance.

Thank you for the reply!

I misunderstood the error message, mistakenly thinking that io.open is hidden. I can certainly call the function now.

One more thing though, does SetPersistentString support appending? Since I want to update the log throughout the sessions, it would be better to be able to.

io.open doesn't seem to support 'a' mode, and I couldn't find TheSim:AppendPersistentString method or such (only Set, Get, and Erase)

 

There is not 'a', you need to read into memory and write again, unfortunately. The same for SetPersistentString 

In your case, it is better to seek different solution, for example, run a local server and message bewteen game and server using TheSim:QueryServer, or use luajit (there is a mod before, and it is now on github) to use socket and io library.

Edited by Rickzzs

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...