Printing text and including custom lua files help

GanararkGanarark Join Date: 2012-11-04 Member: 166967Members
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

Comments

  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    Initially I would guess that print is an unknown state at that point, however, if you want help with finding a solution, always post the error log, as that provides the information on what is going wrong. There is no info there to help us help you at all :(
  • GanararkGanarark Join Date: 2012-11-04 Member: 166967Members
    there is no error log, and the print is a working function, its in many other lua used for debuging and such like server.lua
  • ChaosXBeingChaosXBeing Join Date: 2012-10-12 Member: 162114Members
    Have you tried getting rid of the infinite loop there?
  • GanararkGanarark Join Date: 2012-11-04 Member: 166967Members
  • DghelneshiDghelneshi Aims to surpass Fana in post edits. Join Date: 2011-11-01 Member: 130634Members, Squad Five Blue, Reinforced - Shadow
    edited November 2012
    <!--quoteo(post=2013295:date=Nov 7 2012, 12:08 AM:name=Ganarark)--><div class='quotetop'>QUOTE (Ganarark @ Nov 7 2012, 12:08 AM) <a href="index.php?act=findpost&pid=2013295"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->infi loop?<!--QuoteEnd--></div><!--QuoteEEnd-->
    <!--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>
  • WilsonWilson Join Date: 2010-07-26 Member: 72867Members
    edited November 2012
    I got this working. Here's what my new Client.lua looked like:

    <!--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.
  • GanararkGanarark Join Date: 2012-11-04 Member: 166967Members
    ahh thank u so much!
  • GanararkGanarark Join Date: 2012-11-04 Member: 166967Members
    argh still not loading in the menu no print text, everything is the same as yours, mod gets mounted, its enabled title changes so i know xml is working but no text
  • WilsonWilson Join Date: 2010-07-26 Member: 72867Members
    Loading in the menu? You need to start a game on a local server for this to print to console.
  • GanararkGanarark Join Date: 2012-11-04 Member: 166967Members
    oooooooo i was trying to get it to load on the menu :O
Sign In or Register to comment.