Lua Help Thread

  • boxmein
    9th Jun 2012 Former Staff 1 Permalink
    @shutterbug (View Post)
    You actually have two strings in this code.
    "if mousex>188 and mousex<124 and mousey<121 and mousey>109 then(tpt.drawtext (188, 109, "
    and
    ")end"
    Note that testing and the last ) are left out. That's what it might mean.

    Basically, strings don't nest, meaning
    "Hello, "world" " is two strings and an invalid word "world".
    Inside strings, quotation marks are either swapped
    "Hello, 'world' "
    which will nest or escaped
    "Hello, \"world\" "
    which basically says to the computer that you want the quotation marks as characters and you don't want to end the string.

    String = Piece of text.
    TL;DR:
    image
  • shutterbug
    9th Jun 2012 Member 0 Permalink

    @DJspiderize (View Post)

    Use tpt.el.(4-character element name).flammable=00

     

    @boxmein (View Post)

    Ok, that helped, but I need to make a string inside of a string. I am trying to register a script to run on every frame, but that script contains a string. 

     

  • boxmein
    9th Jun 2012 Former Staff 0 Permalink
    @shutterbug (View Post)
    'code code "string" code'
    "code code \"string\" code" (might not work)
    BTW, I had those answers in the first post as well.
  • jacob1
    9th Jun 2012 Developer 0 Permalink
    @shutterbug (View Post)
    You also need to make it a function by writing "tpt. Register_step(function asdf() [code] end)", you can't just put your code in a string
  • DJspiderize
    9th Jun 2012 Member 0 Permalink

    @shutterbug (View Post)

    Ah thanks, I was just putting one zero instead of two :P

  • shutterbug
    9th Jun 2012 Member 0 Permalink

    @jacob1 (View Post)

    If my code is too long for the console what must I do?

    EDIT:Wait....

    EDIT2:scratch that... its giving me an error saying "( expected near asdf" :/ so... im gonna try to fix it... but if you can answer before then it would be nice ^^ 

    EDIT3: nope... I can't fix it....

  • jacob1
    10th Jun 2012 Developer 0 Permalink
    @shutterbug
    You might be able to do it in one line, but I know 2 will work. Type three separately:
    function test() [your code] end

    tpt.register_step(test)
  • mniip
    10th Jun 2012 Developer 0 Permalink

    jacob1:

    @shutterbug (View Post)
    You also need to make it a function by writing "tpt. Register_step(function asdf() [code] end)", you can't just put your code in a string


    you dont type function name in anonymous declaration
    tpt.register_step(function() code end)
  • shutterbug
    10th Jun 2012 Member 0 Permalink

    @jacob1 (View Post)

    'unexpected symbol near ['

    EDIT: just read mniip's post :P

    edit2: now it says 'unexpected symbol near ')''

    EDIT3:forgot the code, derp.

    tpt.register_step(function ( test ) if mousex>188 and mousex<124 and mousey<121 and mousey>109 then tpt.drawtext ( 188, 109, "testing" )  end)

  • mniip
    12th Jun 2012 Developer 0 Permalink
    tpt.mousex , not mousex