Help with creating elements/properties

  • RamenNoods
    19th Jan 2023 Member 1 Permalink

    I've been working on a sort of test script by trying to add cheese and liquid cheese. Most of the code works just fine, but I seem to be having trouble with properties "HighTemperature", "HighTemperatureTransition", "LowTemperature", and "LowTemperatureTransition". The elements are just ignoring these properties. CHES(Cheese) is supposed to become LCHS(Liquid cheese) when high enough temp, and other way around for low temp.

    I pasted the whole script below so you can see (ignore indentation, its correct in the actual lua file)

     

    local ches = elem.allocate("RAMEN", "CHES")

    elem.element(ches, elem.element(elem.DEFAULT_PT_DMND))

    elem.element(ches, {

    Name = "CHES",

    Colour = 0xDCDC42,

    Description = "Cheese. Very cheesy.",

    Temperature = 295.15,

    Flammable = 0,

    MenuSection = elem.SC_SOLIDS,

    FallDown = 0,

    Weight = 100,

    Meltable = 1,

    Hardness = 45,

    HeatConduct = 120,

    HighTemperature = 348.15,

    HighTemperatureTransition = elem.RAMEN_PT_LCHS,

    AirLoss = 0.90,

    Diffusion = 0,

    Collision = 0

    })

     

    local lchs = elem.allocate("RAMEN", "LCHS")

    elem.element(lchs, elem.element(elem.DEFAULT_PT_MERC))

    elem.element(lchs, { Name = "LCHS",

    Colour = 0xEAEA55,

    Description = "Liquid cheese.",

    Temperature = 363.15,

    Flammable = 15,

    MenuSection = elem.SC_LIQUID,

    FallDown = 2,

    Weight = 35,

    Hardness = 48,

    HeatConduct = 100,

    LowTemperature = 348.15,

    HighTemperatureTransition = elem.RAMEN_PT_CHES,

    AirLoss = 0.90,

    Diffusion = 0,

    Collision = 0,

    Gravity = 0.03

    })

  • Jakav
    20th Jan 2023 Member 0 Permalink

    My guess is that the problem is that the temperature transitions aren't set correctly. My recommendation would be to pass the result of the element allocations. I presume every other property is working?

  • RebMiami
    3rd Mar 2023 Member 0 Permalink

    It might be that you're referencing elem.RAMEN_PT_LCHS before it's ever defined. Usually, I declare all my elements' identifiers at the top of the script and give them properties further down to prevent this. Also, LCHS specifies HighTemperatureTransition for turning back into CHES when it should probably be LowTemperatureTransition.

  • catLoveChips_2
    15th May 2023 Member 0 Permalink

    you need to firstly create all your elements then use the update functions to do this e.g:

    local function LCHSUpdate(i,x,y)

        if sim.partProperty(i, "temp") > threshold+273.15 then

            sim.partChangeType(i, elem.RAMEN_PT_CHES)

        end

    end

    elem.property(LCHS, "Update", LCHSUpdate)

    local function CHESUpdate(i,x,y)

        if sim.partProperty(i, "temp") > threshold2+273.15 then

            sim.partChangeType(i, elem.RAMEN_PT_LCHS)

        end

    end

    elem.property(CHES, "Update", CHESUpdate)

  • RebMiami
    15th May 2023 Member 0 Permalink

    @catLoveChips_2 (View Post)

     This would work, but I'd advise against doing it since it results in much more lag than using the heat transition properties. If you want to create a transition more complicated than "become X above/below Y heat", then this would be a better approach.

  • Hecker
    6th Jul 2023 Member 0 Permalink

    Isn't the temperature the exact same ? 

    this would seem to revert any changes right after they happen,

    348.15 kelvin - 75 Celsius ( I'm guessing you probably all ready know the game uses kelvin ) 


    I've gotten liquid cheese to turn into cheese when cooled, however melting cheese turns into molten cheese, using the meltable property and change the "Base" of the element from dmnd to ttan.

     

    --code below

     

    local ches = elem.allocate("RAMEN", "CHES")

    elem.element(ches, elem.element(elem.DEFAULT_PT_TTAN))

    elem.element(ches, {

    Name = "CHES",

    Colour = 0xDCDC42,

    Description = "Cheese. Very cheesy.",

    Temperature = 295.15,

    Flammable = 0,
    Meltable = 1,
    MenuSection = elem.SC_SOLIDS,

    FallDown = 0,

    Weight = 100,

    Meltable = 1,

    Hardness = 45,

    HeatConduct = 120,

    HighTemperature = 348.15,

    HighTemperatureTransition = elem.RAMEN_PT_LCHS,

    AirLoss = 0.90,

    Diffusion = 0,

    Collision = 0

    })

    local lchs = elem.allocate("RAMEN", "LCHS")

    elem.element(lchs, elem.element(elem.DEFAULT_PT_MERC))

    elem.element(lchs, { Name = "LCHS",

    Colour = 0xEAEA55,

    Description = "Liquid cheese.",

    Temperature = 363.15,

    Flammable = 15,

    MenuSection = elem.SC_LIQUID,

    FallDown = 2,

    Weight = 35,

    Hardness = 48,

    HeatConduct = 100,

    LowTemperature = 323.15,

    LowTemperatureTransition = elem.RAMEN_PT_CHES,

    AirLoss = 0.90,

    Diffusion = 0,

    Collision = 0,

    Gravity = 0.03

    })