Help!

  • InuYasha777
    26th Mar 2014 Member 0 Permalink

    Hello everyone! I have problems with scripting. Can YOU tell me what' s wrong?

    Code:

    local LHYG = elements.allocate(IY, 'LHYG')

    elements.element(elements.IY_PT_LHYG, elements.element(elements.DEFAULT_PT_GLOW))

    elements.property(elements.IY_PT_LHYG, "Properties", elem.TYPE_LIQUID)

    elements.property(elements.IY_PT_LHYG, 'Name', 'LHYG')

    elements.property(elements.IY_PT_LHYG, 'Description', 'Liquid Hydrogenium.')

    elements.property(elements.IY_PT_LHYG, 'Color', '0x99FFFF')

    elements.property(elements.IY_PT_LHYG, 'MenuSection', '7')

    elements.property(elements.IY_PT_LYHG, 'Gravity', 0.4)

    elements.property(elements.IY_PT_LHYG, "Falldown", 2)

    elements.property(elements.IY_PT_LHYG, "State", elem.ST_LIQUID)

    elements.property(elements.IY_PT_LHYG, 'Flammable', '16384')

    elements.property(elements.IY_PT_LHYG, 'Explosive', '1')

    elements.property(elements.IY_PT_LHYG, 'Loss', '0')

    elements.property(elements.IY_PT_LHYG, 'AirLoss', '0')

    elements.property(elements.IY_PT_LHYG, 'AirDrag', '0')

    elements.property(elements.IY_PT_LHYG, 'Advection', '1')

    elements.property(elements.IY_PT_LHYG, 'Weight', '0.4')

    elements.property(elements.IY_PT_LHYG, 'Diffusion', '0')

    elements.property(elements.IY_PT_LHYG, 'Temperature', '17')

    elements.property(elements.IY_PT_LHYG, 'HotAir', '0')

    local function Lflare(i, colr, colg, colb)

    return 1, 0x00000004, 255, 184, 117, 3, 255, 184, 117, 3

    end

    tpt.graphics_func(Lflare, LHYG)

     

    It shows an error message like:

    "scripts\lhyg.lua:8: bad argument #1 to 'property'(number expected)"

    Thanks for your help!

    InuYasha777

    Edited 2 times by InuYasha777. Last: 26th Mar 2014
  • mniip
    26th Mar 2014 Developer 0 Permalink
    @InuYasha777 (View Post)
    I think you need to use
    LHYG
    and not
    elements.IY_PT_LHYG
    , as
    elements
    isn't automatically populated with elements you allocate.
  • InuYasha777
    26th Mar 2014 Member 0 Permalink

    @mniip

     No, that isn't it...

    It doesn't work.

    Another idea?

    Edited 3 times by InuYasha777. Last: 26th Mar 2014
  • mniip
    26th Mar 2014 Developer 1 Permalink
    @InuYasha777 (View Post)
    So you're telling me
    LHYG
    is nil too? Something is broken, it looks like
  • InuYasha777
    26th Mar 2014 Member 0 Permalink

    @mniip

    No, the other scripts are working, so the error is in the script.

     

    New Code:

     

    local LHYG = elements.allocate('IY', 'LHYG')
    elements.element(elements.IY_PT_LHYG, elements.element(elements.DEFAULT_PT_GLOW))
    elements.property(elements.IY_PT_LHYG, "Properties", elem.TYPE_LIQUID)
    elements.property(elements.IY_PT_LHYG, 'Name', 'LHYG')
    elements.property(elements.IY_PT_LHYG, 'Description', 'Liquid Hydrogenium.')
    elements.property(elements.IY_PT_LHYG, 'Color', 0x99FFFF)
    elements.property(elements.IY_PT_LHYG, 'MenuSection', 7)
    elements.property(elements.IY_PT_LHYG, 'Gravity', 0.4)
    elements.property(elements.IY_PT_LHYG, "Falldown", 2)
    elements.property(elements.IY_PT_LHYG, "State", elem.ST_LIQUID)
    elements.property(elements.IY_PT_LHYG, 'Flammable', 16384)
    elements.property(elements.IY_PT_LHYG, 'Explosive', 1)
    elements.property(elements.IY_PT_LHYG, 'Temperature', 17)
    local function Lflare(i, colr, colg, colb)
    return 1, 0x00000004, 255, 184, 117, 3, 255, 184, 117, 3
    end
    tpt.graphics_func(Lflare, LHYG)

     

    Now, the liquid is in TPT and also flammable and explosive. But there' s just one thing: the colour! It' s brown, but my colour is very light blue!

     

    Idea?

  • jacob1
    26th Mar 2014 Developer 0 Permalink
    @InuYasha777 (View Post)
    You are defining a graphics function but telling that to make your element brown, not 0x99FFFF like the property you set. Here is a fixed version, I looked here to figure it out: https://powdertoy.co.uk/Wiki/W/Lua.html#tpt.graphics_func

    Note that the graphics function here does nothing special that isn't done by default, maybe you want to add more properties? Or just remove it.

    local LHYG = elements.allocate('IY', 'LHYG')
    elements.element(LHYG, elements.element(elements.DEFAULT_PT_GLOW))
    elements.property(LHYG, "Properties", elem.TYPE_LIQUID)
    elements.property(LHYG, 'Name', 'LHYG')
    elements.property(LHYG, 'Description', 'Liquid Hydrogenium.')
    elements.property(LHYG, 'Color', 0x99FFFF)
    elements.property(LHYG, 'MenuSection', 7)
    elements.property(LHYG, 'Gravity', 0.4)
    elements.property(LHYG, "Falldown", 2)
    elements.property(LHYG, "State", elem.ST_LIQUID)
    elements.property(LHYG, 'Flammable', 16384)
    elements.property(LHYG, 'Explosive', 1)
    elements.property(LHYG, 'Temperature', 17)
    local function Lflare(i, colr, colg, colb)
    return 1, 0x00000004, 255, 153, 255, 255, 255, 153, 255, 255
    end
    tpt.graphics_func(Lflare, LHYG)


    @mniip (View Post)
    elements is filled with things you allocate, it's tpt.el that isn't.
    Edited once by jacob1. Last: 26th Mar 2014
  • InuYasha777
    26th Mar 2014 Member 0 Permalink

    OOOOOOOOOOOOOOOOOOOH! Thanks SOOOO much!

    Now it' s working. But what was wrong?

  • FeynmanLogomaker
    26th Mar 2014 Member 0 Permalink

    In the first one, you had a typo :)