Small question

  • SillyZettian
    16th June Member 0 Permalink

    When I make a Hightemperature/LowTemperature (vice versa with pressure) in my mod, and the elements. is set to a element in the mod, it doesn't form strangely. A example is 

    elements.property(elements.SLZN_PT_TALC, "HighTemperature", 1113.15)
    elements.property(elements.SLZN_PT_TALC, "HighTemperatureTransition", elements.SLZN_PT_TDTC)
    elements.property(elements.SLZN_PT_TALC, "HighPressure", 1)
    elements.property(elements.SLZN_PT_TALC, "HighPressureTransition", elements.SLZN_PT_PDTC)

     

    And when running it, it doesn't transition properly, both pressure and temperature transitions.

    Edited once by SillyZettian. Last: 16th June
  • 12034056
    16th June Member 0 Permalink

    elements.property doesn't return an error if the property value is nil, check if TDTC and PDTC have that exact name in elements.allocate, if iname property set in elements.allocate is different from "TDTC" or "PDTC" then elements.SLZN_PT_TDTC and elements.SLZN_PT_PDTC will be nil and the transition won't happen.

     

    It is a more common practice to refer to elements by their indexes, like this:

     

    local TALC = elem.allocate("SLZN","TALC")
    -- ...
    
    local TDTC = elem.allocate("SLZN","TDTC")
    -- ...
    
    local PDTC = elem.allocate("SLZN","PDTC")
    -- ...
    
    elements.property(TALC, "HighTemperature", 1113.15)
    elements.property(TALC, "HighTemperatureTransition", TDTC)
    elements.property(TALC, "HighPressure", 1)
    elements.property(TALC, "HighPressureTransition", PDTC)

    This way, if you want to change only the element identifier you don't need to change how it is referred everywhere in the code

  • SillyZettian
    16th June Member 0 Permalink

    And by the way, this is the entire 4 elements in the mod

    @12034056 (View Post)

     

    local TALC = elements.allocate("SLZN","TALC")
    --Talc, soft mineral.--
    elements.element(TALC, elements.element(elements.DEFAULT_PT_COAL))
    elements.property(TALC, 'Name', 'TALC')
    elements.property(TALC, 'Description', 'Talc, a extremely soft mineral that breaks easily. Bugged element. ')
    elements.property(TALC, 'Color', '0xF8F6EE')
    elements.property(TALC, "MenuSection", elements.SC_SOLIDS)
    elements.property(TALC, "Properties", elements.TYPE_SOLID)
    elements.property(TALC, 'MenuVisible', '7')
    elements.property(TALC, 'Loss', '10')
    elements.property(TALC, 'AirLoss', '1')
    elements.property(TALC, 'AirDrag', '0')
    elements.property(TALC, 'Advection', '0')
    elements.property(TALC, 'Weight', '100')
    elements.property(TALC, 'Diffusion', '0')
    elements.property(TALC, 'Falldown', '0')
    elements.property(TALC, 'Temperature', 283.15)
    elements.property(TALC, "HighTemperature", 1113.15)
    elements.property(TALC, "HighTemperatureTransition", TDTC)
    elements.property(TALC, "HighPressure", 2.05)
    elements.property(TALC, "HighPressureTransition", PDTC)

    local PDTC = elements.allocate("SLZN","PDTC")
    --Powdered Talc, Soft Mineral. --
    elements.element(PDTC, elements.element(elements.DEFAULT_PT_PQRT))
    elements.property(PDTC, 'Name', 'PDTC')
    elements.property(PDTC, 'Description', 'Powdered talc, formed when Talc breaks at very ligh amounts of pressure. Bugged element.')
    elements.property(PDTC, 'Color', '0xF8F6EE')
    elements.property(PDTC, "MenuSection", elements.SC_POWDERS)
    elements.property(PDTC, "Properties", elements.TYPE_PART)
    elements.property(PDTC, 'MenuVisible', '7')
    elements.property(PDTC, 'Weight', '84')
    elements.property(PDTC, 'Advection', '1')
    elements.property(PDTC, 'AirLoss', '0.91')
    elements.property(PDTC, 'AirDrag', '0.01')
    elements.property(PDTC, 'Gravity', '0.03')
    elements.property(PDTC, 'Diffusion', '0')
    elements.property(PDTC, 'Falldown', '1')
    elements.property(PDTC, 'Temperature', 283.15)
    elements.property(PDTC, "HighTemperature", 1113.15)
    elements.property(PDTC, "HighTemperatureTransition", TDPT)

    local TDTC = elements.allocate("SLZN","TDTC")
    --Themally Decomposed Talc, a mix of other minerals.--
    elements.element(TDTC, elements.element(elements.DEFAULT_PT_QRTZ))
    elements.property(TDTC, 'Name', 'TDTC')
    elements.property(TDTC, 'Description', 'Thermal Decomposed Talc, a mix of estatite and amorphous silica. Hidden element. Shh')
    elements.property(TDTC, 'Color', '0x7CC9A1')
    elements.property(TDTC, "MenuSection", elements.SC_SOLIDS)
    elements.property(TDTC, "Properties", elements.TYPE_SOLID)
    elements.property(TDTC, 'MenuVisible', '0')
    elements.property(TDTC, 'Loss', '10')
    elements.property(TDTC, 'AirLoss', '1')
    elements.property(TDTC, 'AirDrag', '0')
    elements.property(TDTC, 'Advection', '0')
    elements.property(TDTC, 'Weight', '100')
    elements.property(TDTC, 'Diffusion', '0')
    elements.property(TDTC, 'Falldown', '0')
    elements.property(TDTC, 'Temperature', 1135.15)
    elements.property(TDTC, "HighTemperature", 1773.15)
    elements.property(TDTC, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(TDTC, "HighPressure", 2.05)
    elements.property(TDTC, "HighPressureTransition", TDPT)

    local TDPT = elements.allocate("SLZN","TDPT")
    --Thermally Decomposed Powdered Talc, a mix of other minerals. --
    elements.element(TDPT, elements.element(elements.DEFAULT_PT_PQRT))
    elements.property(TDPT, 'Name', 'TDPT')
    elements.property(TDPT, 'Description', 'Powdered talc, formed when TDTC breaks at very light amounts of pressure. Hidden element. Shh.')
    elements.property(TDPT, 'Color', '0x7CC9A1')
    elements.property(TDPT, "MenuSection", elements.SC_POWDERS)
    elements.property(TDPT, "Properties", elements.TYPE_PART)
    elements.property(TDPT, 'MenuVisible', '0')
    elements.property(TDPT, 'Weight', '84')
    elements.property(TDPT, 'Advection', '1')
    elements.property(TDPT, 'AirLoss', '0.91')
    elements.property(TDPT, 'AirDrag', '0.01')
    elements.property(TDPT, 'Gravity', '0.03')
    elements.property(TDPT, 'Diffusion', '0')
    elements.property(TDPT, 'Falldown', '1')
    elements.property(TDPT, 'Temperature', 1135.15)
    elements.property(TDPT, "HighTemperature", 1772.15)
    elements.property(TDPT, "HighTemperatureTransition", TDTC)

     

     

    Yes, I did change the identifers to a more simple form.

     

     

     

     

    Edited once by SillyZettian. Last: 16th June
  • 12034056
    16th June Member 0 Permalink

    Lua, similarly to C++, is read from top to bottom, TDTC and PDTC have not been defined yet when the element transition is set, that's why it doesn't work for TALC, but works for TDPT. Moving all element allocations to the top should fix this

  • SillyZettian
    16th June Member 0 Permalink

    Thanks! Now it's fixed :)