Script help

  • Dawgie
    29th Jun 2012 Member 0 Permalink

    Ok i am trying to make a new liquid but everytime i go to run it I keep getting that "then expected near "="

    this is what I have

     

     

    tpt.el.watr.name="MGLQ"
    tpt.el.watr.temp=255
    function heat()
    if tpt.get_property(temp)=256 then
    tpt.set_property (temp 0 watr)

     

    Positive comments only I am new at lua.

  • Darkwrist
    29th Jun 2012 Member 0 Permalink

    @Dawgie (View Post)

     same here but i think the lines after "function heat()" are wrong.well i know scripting elements in such a way i can give you correct code if you can give me properties you want.

  • plead-for-destruction
    29th Jun 2012 Member 0 Permalink
    @Dawgie (View Post)
    try putting quotation marks around the Value 256?

    im not great at Lua
  • boxmein
    29th Jun 2012 Former Staff 0 Permalink
    @Dawgie (View Post)
    With a single = you're assigning get_property a value of 256 which wouldn't work.
    [This] page told me you should replace it with ==.
    So the new line would be
    if tpt.get_property (temp) == 256 then
  • plead-for-destruction
    29th Jun 2012 Member 0 Permalink
    @boxmein (View Post)
    == would be the correct term i suppose, but == means the same as = :/
  • boxmein
    29th Jun 2012 Former Staff 0 Permalink
    @plead-for-destruction (View Post)
    It's a safe bet to use ==, because = almost always means assignment. (Pascal is different)
    > edit edit edit: rephrased
  • jacob1
    29th Jun 2012 Developer 0 Permalink
    @plead-for-destruction (View Post)
    == and = are different, you have to use the right one or it won't work.

    @Dawgie (View Post)
    You also don't have an end at the end. Actually, you need to ends, one to end the if statement and one to end the function
  • vertigo
    29th Jun 2012 Member 0 Permalink

    Here is the fixed code*

    ---------------------------------------------------------------------------

    tpt.el.eqve.name="TEST" --Giving it a name
    tpt.el.eqve.enabled=1
    tpt.el.eqve.menu=1
    tpt.el.eqve.menusection=10 --adding it to the menusection "Specials"
    tpt.el.eqve.heat=255   --setting its starting heat
    tpt.el.eqve.gravity=2  --gravity
    tpt.el.eqve.falldown=2 --state of matter (Liquid)
       function Heat_Loop()
          if tpt.get_property("temp","eqve") == 256
             then do
                tpt.set_property("temp",0"eqve")
             end
          end
       end
    end
    tpt.register_step(Heat_Loop)

    ------------------------------------------------------------------

    this should work but it doesnt. It doesnt even rename the element.

    By the way you had many things wrong to start off with. (Not to be negative, im a noob too. i started the day before yesterday.)

    here are the basic mistakes you made:

    ----------------------------------------------

    tpt.el.watr.name="MGLQ" --i changed this to make sure that the name wasnt the problem.
    tpt.el.watr.temp=255 --there is no property called temp. use tpt.el.watr.heat=255
       function heat()   --always use correct indentation.
       if tpt.get_property(temp)=256 then --here it should be in more lines. and = should be ==. Like so:

          if tpt.get_property("temp","watr")

             then  --im not sure if you should use then or then do here.
             tpt.set_property (temp 0 watr) --right here it should be tpt.set_property("temp",0,"watr")

        end --you forgot to write end to end the "then" and the functionand "if"

    end

    tpt.register_step(heat) --this will make the function run every frame, otherwise it runs only once.

    ---------------------------------------------

    ~Vertigo

  • plead-for-destruction
    29th Jun 2012 Member 0 Permalink
    @jacob1 (View Post)
    i know they are different in that way...
  • Dawgie
    29th Jun 2012 Member 0 Permalink
    @vertigo (View Post)
    Ok i tried your script and it gave me an new error I am using lua edit and it says that ")' expected near eqve"