Lua Text Script

  • Download
    21st Sep 2011 Member 0 Permalink
    So I was reading the wiki and I *still* couldn't understand the the Lua text function. Can anyone explain how to go about using it?
  • MasterMind555
    21st Sep 2011 Member 0 Permalink
    @Download (View Post)
    Ok
    Lua ( THANK GOD you didn't say "LUA" ) is a scripting language which you can make pretty much...console apps with. It's pretty much useless if it's not intergrated into another program ( In this case, The Powder Toy )
    The Lua script function let you write Lua Scripts that does things into .lua files and then executing them but write dofile("nameoffile.lua") In the Powder Toy Console.
    You should the basics of programming before starting to make lua scripts, if you don't have those basics, google Lua tutorials.

    Do you understand now?
  • Download
    21st Sep 2011 Member 0 Permalink
    I was talking about this:

    tpt.drawtext

    Draw text to the screen (for one frame, only useful in scripts), 3 overloads
    tpt.drawtext(number x, number y, string text)
    tpt.drawtext(number x, number y, string text, number red, number green, number blue)
    tpt.drawtext(number x, number y, string text, number red, number green, number blue, number alpha)
  • cctvdude99
    21st Sep 2011 Member 0 Permalink
    @Download
    You mean: tpt.drawtext()
    Simples, I think.
    For the text to appear permanently, you need to use tpt.register_step().

    Anyway, the 'number x' and 'number y' in the wiki are the x and y positions on the screen. Example:
    tpt.drawtext("100","100","text")
    That would a temporary word 'text' at the position (100,100).
    To make it appear permanently, while the script it running, you need a simple script file.
    function textdraw()
    tpt.drawtext("100","100","example text")
    end
    tpt.register_step(textdraw)


    That will draw the text 'example text' when you type 'dofile("yourscriptnamehere.txt")' into the console.
    It does not save, just incase you didn't know. ;)

    Edit: You posted 13 seconds before me, lol.
  • MasterMind555
    21st Sep 2011 Member 0 Permalink
    @Download (View Post)

    MasterMind555:


    You should the basics of programming before starting to make lua scripts, if you don't have those basics, google Lua tutorials.


    Be sure to read this part.
    ALL will become clear if you already know a bit of programming
  • Download
    21st Sep 2011 Member 0 Permalink
    Is there a way to draw the text in a certain element?
    I'm not trying to learn for scripting.... Only for this purpose.
  • cctvdude99
    21st Sep 2011 Member 0 Permalink
    @Download
    Nope, it's non-physical, temporary text only.

    I would recommend MGR (mniip's Grahpics) text drawing if you want to draw text physically. The font isn't very good, but it does the job. ;)
    https://powdertoy.co.uk/Discussions/Thread/View.html?Thread=8016

    Not sure if it's still working as it used to, it's part of TPTOS now, but give it a try, it might work. :D
  • MasterMind555
    21st Sep 2011 Member 0 Permalink
    @Download (View Post)
    I know but you're gonna have a hard time if you don't know BASICS of programming.
    Plus if you're slightly interested into computers, it will be useful later

    Also there should be a place with all the game's variables written, try to find that, it will help you alot
  • Download
    21st Sep 2011 Member 0 Permalink
    Okay thanks! It's just a pain to make font by hand and copy and paste.
    You're selling me something I'm trying to use ONE TIME >.>
  • cctvdude99
    21st Sep 2011 Member 0 Permalink
    @Download
    Yeah, if MGR isn't working right now, try just tracing the white parts of signs. It's simple and easy, but a pain if you have to draw out a lot of text. :I
Locked by Lockheedmartin: ANSWERED