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

Postby Andrettin » Thu Mar 13, 2014 11:45 pm

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

Postby jarod42 » Sun Mar 16, 2014 12:49 am

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

Postby Andrettin » Wed Mar 19, 2014 4:54 pm

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

Postby francot514 » Sun Apr 19, 2015 7:41 am

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

Postby Kyran » Sun Apr 19, 2015 1:40 pm

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

Postby francot514 » Mon Apr 20, 2015 5:52 am

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

Postby Kyran » Mon Apr 20, 2015 10:44 pm

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

Postby francot514 » Tue Apr 21, 2015 6:02 am

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

Postby Kyran » Wed Apr 22, 2015 12:04 am

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

Postby Andrettin » Wed Apr 22, 2015 3:12 am

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.

Who is online

Users browsing this forum: No registered users and 1 guest