WHY ARE YOU TAN (scripting help)

  • SillyZettian
    12th June Member 0 Permalink

    So I'm making a mod, and one of the elements is ZN30 (Zinc) and every thing with it is fine, except for ONE thing. It's somehow tan. I'm using hex code "0xBAC4C8" which is perfectly fine, but it appears TAN on the element, but is grey in the TPT element GUI. here's the scripting.

     

     

     

    local mods = elements.allocate("SLZN","ZINC")
    --ZN30 (Zinc)--
    elements.element(elements.SLZN_PT_ZINC, elements.element(elements.DEFAULT_PT_IRON))
    elements.property(elements.SLZN_PT_ZINC, 'Name', 'ZN30')
    elements.property(elements.SLZN_PT_ZINC, 'Description', 'Zinc, conductor that can be mixed with Copper to make Brass')
    elements.property(elements.SLZN_PT_ZINC, "MenuSection", elements.SC_SOLIDS)
    elements.property(elements.SLZN_PT_ZINC, "Properties", elements.PROP_CONDUCTS+elements.TYPE_SOLID+elements.PROP_HOT_GLOW+elements.PROP_LIFE_DEC)
    elements.property(elements.SLZN_PT_ZINC, 'MenuVisible', '7')
    elements.property(elements.SLZN_PT_ZINC, 'Flammable', '0')
    elements.property(elements.SLZN_PT_ZINC, 'Loss', '10')
    elements.property(elements.SLZN_PT_ZINC, 'AirLoss', '1')
    elements.property(elements.SLZN_PT_ZINC, 'AirDrag', '0')
    elements.property(elements.SLZN_PT_ZINC, 'Advection', '0')
    elements.property(elements.SLZN_PT_ZINC, 'Weight', '100')
    elements.property(elements.SLZN_PT_ZINC, 'Diffusion', '0')
    elements.property(elements.SLZN_PT_ZINC, 'Falldown', '0')
    elements.property(elements.SLZN_PT_ZINC, 'Temperature', 283.15)
    elements.property(elements.SLZN_PT_ZINC, "HighTemperature", 692.68)
    elements.property(elements.SLZN_PT_ZINC, "HighTemperatureTransition", elements.DEFAULT_PT_LAVA)
    elements.property(elements.SLZN_PT_ZINC, 'Color', '0xBAC4C8')

     

     

     

     

     

     

     

  • 12034056
    12th June Member 1 Permalink

    It is because it has a PROP_HOT_GLOW property with a low melting point. PROP_HOT_GLOW isn't very realistic, if you aim for realism I recommend implementing the glow in Graphics function instead, like it is done for TUNG.

     

    function ZN30Graphics(i,r,g,b)
      return 0, 1, 255, r + math.min(50, 0.25 * math.max(0, sim.partProperty(i,"temp")-492.68)), g, b, 0, 0, 0, 0
    end
    elements.property(elements.SLZN_PT_ZINC, 'Graphics', ZN30Graphics)
  • SillyZettian
    12th June Member 0 Permalink

    oh, thanks. 2nd issue because I've been studing the lua api for 2 months now yet I'm not too good with it. The zinc is meant to melt with CU29, to form BRSS. I decided changing the element idenifier from ZINC to ZN30 and that's all that's also new. I've already made the BRSS and CU29 elements and this is a script I made to mix with ZN30 and CU29 when molten. 

     

    function BRASSALLOY(i, x, y, s, n)
    if sim.partProperty(i, "type") == elements.DEFAULT_PT_LAVA then
    if sim.partProperty(i, "ctype") == elements.SLZN_PT_ZN30 then
    local BRASSALLOY = tpt.get_property("type",x+math.random(-1,1),y+math.random(-1,1))
    if BRASSALLOY == tpt.element('lava') then
    if sim.partProperty(i, "ctype") == elements.SLZN_PT_CU29 then
    sim.partChangeType(i,tpt.element('BRSS'))
    end
    end
    end
    end
    end

     

     

     

    The bigger issue is that this doesn't work and doesn't break the whole script, just it doesn't melt into BRSS and stays 2 different elements when cooled. 

    Edited once by SillyZettian. Last: 12th June
  • 12034056
    13th June Member 1 Permalink

    LAVA won't run its ctype's update function, this should be handled within the LAVA update:

    function BRASSALLOY(i,x,y)
      if sim.partProperty(i,"ctype") == elem.SLZN_PT_ZN30 then
        local r = sim.pmap(x + math.random(-1,1), y + math.random(-1,1))
        if r ~= nil then
          if sim.partProperty(r, "type") == elem.DEFAULT_PT_LAVA and sim.partProperty(r, "ctype") == elem.SLZN_PT_CU29 then
            if math.random(2) == 1 then
              sim.partProperty(i, "ctype", elem.SLZN_PT_BRSS)
            else
              sim.partProperty(r, "ctype", elem.SLZN_PT_BRSS)
            end
          end
        end
      end
    end
    elem.property(elem.DEFAULT_PT_LAVA, "Update", BRASSALLOY, elem.UPDATE_BEFORE)

    elem.UPDATE_BEFORE makes it so it will run after the default update function instead of replacing it

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

    After adding about 8+ more elements, the lava scripting broke :(

    Edited 2 times by SillyZettian. Last: 20th June
  • SillyZettian
    20th June Member 0 Permalink

    The scripting broke somehow

  • 12034056
    20th June Member 0 Permalink

    What is its current behavior and what is the expected behavior?

     

    All scripting should be in one function:

    function lava_upd(i,x,y)
      if sim.partProperty(i,"ctype") == elem.ELEMENT_PT_A then
        -- ...
      elseif sim.partProperty(i,"ctype") == elem.ELEMENT_PT_B then
        -- ...
      end
    end
    elem.property(elem.DEFAULT_PT_LAVA, "Update", lava_upd, elem.UPDATE_BEFORE)

     

    Try using tpt.log(...) function to display variables on screen for easier debugging

  • whistletails
    23rd June Member 0 Permalink
    This post has been removed by jacob1: unhelpful