Writing to Files with Lua

User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Writing to Files with Lua

Post by Andrettin »

I can't seem to get Lua to work in Stratagus to write to files. This is an example of what I have been attempting:

Code: Select all

local op_file = io.open("example.txt", "w")
op_file:write("This is an example.")
op_file:close()
Any ideas on what I'm doing wrong? Or is writing to files through lua unsupported in Stratagus?
User avatar
jarod42
Posts: 101
Joined: Fri Jan 20, 2012 7:43 pm

Re: Writing to Files with Lua

Post by jarod42 »

Not all lua lib are loaded.
and if I remember correctly, `io` is not loaded for security reason.
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Writing to Files with Lua

Post by Andrettin »

jarod42 wrote:Not all lua lib are loaded.
and if I remember correctly, `io` is not loaded for security reason.
Ah, I see, thanks for the explanation!
francot514
Posts: 87
Joined: Wed May 21, 2014 6:26 am

Re: Writing to Files with Lua

Post by francot514 »

Where to find information about stratagus lua api functions??
User avatar
Kyran
Posts: 499
Joined: Sat Dec 31, 2011 5:19 pm
Location: Australia
Contact:

Re: Writing to Files with Lua

Post by Kyran »

04:27 jim4 why haven't you added wc1 support? this project sucks. i'm only going to use freecraft
05:06 jim4 finished wc1 support yet? i've been waiting for 6 years
05:10 jim4 new things scare me
francot514
Posts: 87
Joined: Wed May 21, 2014 6:26 am

Re: Writing to Files with Lua

Post by francot514 »

Thanks good infomation, seem is more complex than i tough, there is some kind of script editor that can easy add those to the maps, because right now i have discovered how to add triggers and i really want to use this...
User avatar
Kyran
Posts: 499
Joined: Sat Dec 31, 2011 5:19 pm
Location: Australia
Contact:

Re: Writing to Files with Lua

Post by Kyran »

You have look inside the ftm maps to get examples on how to use them.
04:27 jim4 why haven't you added wc1 support? this project sucks. i'm only going to use freecraft
05:06 jim4 finished wc1 support yet? i've been waiting for 6 years
05:10 jim4 new things scare me
francot514
Posts: 87
Joined: Wed May 21, 2014 6:26 am

Re: Writing to Files with Lua

Post by francot514 »

Yes, that is what i have done, i mean why the "triggers" and some other stuff didnt were added to the editor, to allow better and easy map events customization, or there is other tool for it...
User avatar
Kyran
Posts: 499
Joined: Sat Dec 31, 2011 5:19 pm
Location: Australia
Contact:

Re: Writing to Files with Lua

Post by Kyran »

You'll have to use a text editor. No other way exists.
04:27 jim4 why haven't you added wc1 support? this project sucks. i'm only going to use freecraft
05:06 jim4 finished wc1 support yet? i've been waiting for 6 years
05:10 jim4 new things scare me
User avatar
Andrettin
Posts: 433
Joined: Sun Jun 30, 2013 9:58 pm
Location: Vienna, Austria
Contact:

Re: Writing to Files with Lua

Post by Andrettin »

francot514 wrote:Yes, that is what i have done, i mean why the "triggers" and some other stuff didnt were added to the editor, to allow better and easy map events customization, or there is other tool for it...
Those would have to be added in with a text editor like Notepad++. It would of course be nice to be able to add triggers through the editors, and I want to get that in Wyrmsun someday.
Post Reply