Avorion Wiki
Explore
Main Page
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Admin noticeboard
Avorion Community
Official forum
Discord
Twitter
Reddit
Facebook
Steam
Gamepedia
Gamepedia support
Report a bad ad
Help Wiki
Contact us
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
FANDOM
Explore
Current Wiki
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Avorion Wiki
356
pages
Explore
Main Page
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Admin noticeboard
Avorion Community
Official forum
Discord
Twitter
Reddit
Facebook
Steam
Gamepedia
Gamepedia support
Report a bad ad
Help Wiki
Contact us
Editing
Debugging Scripts
(section)
Back to page
Edit
VisualEditor
View history
Talk (0)
Edit Page
Debugging Scripts
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== 'print' debugging == An easy way to debug scripts is to add regular calls to <code>print()</code> or <code>eprint()</code> while writing your script. You can open the in-game console with a button. '''Note:''' The in-game console isn't configured to a working button by default, you will have to configure it manually yourself. * <code>print()</code> will print regular output to the console * <code>eprint()</code> will print error output to the console Depending on where the function was executed, the output will have different colors in the console, making it easy to distinguish client-prints from server-prints. Please consult the [[Scripting API]] for more information to these functions. === Advanced print debugging === You can set up a function in a script where you can easily toggle print debugging on and off, which will allow you to leave your 'print' statements in the mod. You would want it to look something like this: <source lang="lua"> local _Debug = 0 function myFunc1(_Arg1) debugPrint("Entering myFunc1 - _Arg1 is " .. tostring(_Arg1)) return _Arg1 + 5 end function debugPrint(_Msg) if _Debug == 1 then print(_Msg) end end </source> This would print "Entering myFunc1 - _Arg1 is 5" if you ran myFunc1(5) somewhere in your script, but only if you set _Debug to 1. Using this, you can toggle debug information on and off whenever you want. === printTable() === Use the <code>printTable()</code> function to recursively print a table. It's defined in '''data/scripts/lib/utility.lua'''. === Logging === Another easy way to debug scripts, mostly while they're being used by players already, is to use logging. You can use the <code>printlog()</code> function, that behaves similarly to <code>print()</code>, but prints to the logfile instead of the console. Depending on whether that function is called on the client or server, it will print to the client or server logfile.
Summary:
Please note that all contributions to the Avorion Wiki are considered to be released under the CC BY-SA 3.0
Cancel
Editing help
(opens in new window)
Follow on IG
TikTok
Join Fan Lab