Printing text and including custom lua files help
so im struggling to get text to print out on the console, im using print("blah blah") func and its really not happening for me.
so yeah heres my code
game_setup.xml // using this to include my custom lua
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><game>
<name>ns2</name>
<description>Natural ponys 2</description>
<client>lua/hello/client.lua</client> // custom lua will load correct client.lua
</game><!--c2--></div><!--ec2-->
client.lua
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Client.lua") // loads real client.lua
//Script.Load("lua/Shared.lua")
script.load("lua/Global.lua")
Print("text outside of func")
while true do
Print("text in func")
end
Event.Hook("UpdateClient", Update)<!--c2--></div><!--ec2-->
im just trying to be able to include my own lua's and be able to print text on the console window
anyone shed some light on what im doing wrong
so yeah heres my code
game_setup.xml // using this to include my custom lua
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><game>
<name>ns2</name>
<description>Natural ponys 2</description>
<client>lua/hello/client.lua</client> // custom lua will load correct client.lua
</game><!--c2--></div><!--ec2-->
client.lua
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Client.lua") // loads real client.lua
//Script.Load("lua/Shared.lua")
script.load("lua/Global.lua")
Print("text outside of func")
while true do
Print("text in func")
end
Event.Hook("UpdateClient", Update)<!--c2--></div><!--ec2-->
im just trying to be able to include my own lua's and be able to print text on the console window
anyone shed some light on what im doing wrong
Comments
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->while true do
Print("text in func")
end<!--c2--></div><!--ec2-->
This is an infinite loop. "while <i>condition </i>do <i>stuff </i>end" will repeat <i>stuff</i> over and over again while the <i>condition</i> is true. Once the thread running the code encounters this, it will never do anything else anymore since "true" is obviously always true, so it will Print("text in func") over and over again.
I personally think it's an issue with your mod setup. How do you start your mod exactly?
Edit: There's also two typos in this line: <b><u>s</u>cript.load("lua/Global.lua")</b> should be <b><u>S</u>cript.Load("lua/Global<u>s</u>.lua")</b>
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("lua/Client.lua") //loads real client.lua
Print("test_print")
Event.Hook("UpdateClient", OnUpdateClient)<!--c2--></div><!--ec2-->
Your Event.Hook with Update was causing an error. It works with OnUpdateClient.
Here is my game_setup.xml, the only thing I changed was linking to Client_test.lua which is the file above.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><game>
<name>ns2</name>
<description>Natural Selection 2</description>
<client>lua/Client_test.lua</client>
<server>lua/Server.lua</server>
<loading>lua/Loading.lua</loading>
<soundinfo>sound/NS2.soundinfo</soundinfo>
</game><!--c2--></div><!--ec2-->
It can be easy to miss in the console, but this line appears as a result:
Client : 0.000000 : test_print
If you have hot loading enabled (use -hotload as a launch command) then you can resave your new Client.lua file and it will print the line again at the bottom of the console.