Problems on Debuging/Logging
Moderator: Forum Moderators
Problems on Debuging/Logging
Hi, I'm really new to Lua, and now I face some problems.
I don't know how to log the information. - -
I've tried print(), but I still don't know how to view the "console" that it print to.
I've also tried the following command, but it showed me that it is error.
So if you guys can tell me how to properly print out or save to file, it would be a big help.
Thx
P.S. for now I've used wesnoth.message() but the output in the game is limited to 5-6 lines, so it didn't help me much
I don't know how to log the information. - -
I've tried print(), but I still don't know how to view the "console" that it print to.
I've also tried the following command, but it showed me that it is error.
Code: Select all
local file = io.open("example.txt", "w")
file:write("....................")
file:close()
Thx
P.S. for now I've used wesnoth.message() but the output in the game is limited to 5-6 lines, so it didn't help me much
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Problems on Debuging/Logging
You can't. The io library and part of the os library are disallowed for security reasons. If they weren't, it will be possible for everyone with enough knowledge to load on the server a malicious add-on that executes arbitrary code.IArgosyI wrote:So if you guys can tell me how to properly print out or save to file, it would be a big help.
At most, you can use the print() function to print stuff on the Terminal (on Linux) or on the stdout.txt (on Windows). Look here to find it (you'll find it in the same directory where stderr.txt can be found, but only when Wesnoth is running):
http://wiki.wesnoth.org/EditingWesnoth# ... rectory.3F
http://forums.wesnoth.org/viewtopic.php?f=4&t=23894
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Re: Problems on Debuging/Logging
Wow thank you very much
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Problems on Debuging/Logging
However, when launching wesnoth (any program ?) from the console, you can redirect the stderr and stdout into a file or files.Elvish_Hunter wrote:You can't.IArgosyI wrote:So if you guys can tell me how to properly print out or save to file, it would be a big help.
In an ubuntu bash shell for instance (untested):
wesnoth -d --log-debug=all 1>stdout.txt 2>stderr.txt
Such files could (should) be added to a bug which you report.
On windows, I think one is forced to use the files with these names.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign