Difference between revisions of "Text Output"

From Journey Modding Wiki
Jump to navigation Jump to search
(Created page with "There are a number of ways to get Lua to output data from the game to readable text. Right now this page just includes basics but there are a lot of specialized functions in t...")
 
 
Line 18: Line 18:




Here is a basic injectable script which opens a non-interactive console window the first time you execute it, and then whenever you use print() it prints text in the console; could be changed to use a function name other than print() if you don't want to see the stuff the game normally uses "print" for.
Here is a basic injectable script which opens a non-interactive console window the first time you execute it, without pausing the game, and then whenever you use print() it prints text in the console; could be changed to use a function name other than print() if you don't want to see the stuff the game normally uses "print" for.


Good for simply viewing stuff that you don't need to save, and barely slows down the game at all.
Good for simply viewing stuff that you don't need to save, and barely slows down the game at all.
Line 31: Line 31:
end
end
</nowiki>
</nowiki>


=== Print to a file ===
=== Print to a file ===

Latest revision as of 23:18, 22 October 2021

There are a number of ways to get Lua to output data from the game to readable text. Right now this page just includes basics but there are a lot of specialized functions in the game made by TGC, which would probably be useful to document.


print()

Probably just the default Lua print function, which outputs to stdout, although so far no way is known to view this without changing how the print() function works.


DebugPrint()

A custom TGC function that does print() if the global variable CONFIG equals anything other than "Gold", "PublicBeta", or "Demo".


Print to a console window

Here is a basic injectable script which opens a non-interactive console window the first time you execute it, without pausing the game, and then whenever you use print() it prints text in the console; could be changed to use a function name other than print() if you don't want to see the stuff the game normally uses "print" for.

Good for simply viewing stuff that you don't need to save, and barely slows down the game at all.

(Copied from a post in stackoverflow or something, can't remember)

local out = io.popen('find /v "" > con', "w")
function print(s)
  out:write(s.."\r\n") --\r because windows
  out:flush()
end

Print to a file

Here is a basic injectable function which prints to a file in your Journey directory, with the filename and extension being whatever "name" is. Might slow down the game if a lot is getting printed, and possibly crash if it's too much at once. It is probably good to use a function name other than "print" if you are using SpawnEvent or ActivateTriggerByName a lot, unless you modify those functions to remove the parts of them that print stuff, or else it might slow down your game a lot and rapidly grow the stdout.txt file.

function PrintToFile( s, name )
    name = name or "stdout.txt"
    file = io.open(name, "a")
    io.output(file)
    io.write(s.."\n")
    file:close()
end


DebugOut trigger

Seems like it is a trigger type that SHOULD print its "stdoutMessage" Var string to stdout whenever the trigger is activated, but simply changing the print() function doesn't make it print anything with that, and also setting CONFIG = "Debug" doesn't seem to help - so either the code that makes it work was removed, or some other unknown thing needs to be enabled and/or it prints to a different "stdout" that we don't know how to access yet.