Advertisement
Guest User

Blue gold

a guest
Jun 2nd, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. local BGLD = elem.allocate("LBPHACKER", "BGLD")        -- * Allocate element ID.
  2. elem.element(BGLD, elem.element(elem.DEFAULT_PT_GOLD)) -- * Base it off GOLD.
  3. elem.property(BGLD, "Name", "BGLD")                    -- * Name it BGLD in the menu.
  4. elem.property(BGLD, "Color", 0x238AD6)                 -- * Give it a bluish colour.
  5. elem.property(BGLD, "HighTemperatureTransition", 1500) -- * Make it a bit more difficult to melt.
  6. elem.property(BGLD, "Graphics", function(i, r, g, b)   -- * A lot like GOLD's graphics function.
  7.     return 0, ren.PMODE_FLAT, 255,
  8.         r + math.random(-5, 4),
  9.         g + math.random(-5, 4),
  10.         b + math.random(-5, 4)
  11. end)
  12.  
  13. elem.property(elem.DEFAULT_PT_LAVA, "Update", function(i, x, y, ...)
  14.  
  15.     -- * If this particle is molten IRON...
  16.     if sim.partProperty(i, "ctype") == elem.DEFAULT_PT_IRON then
  17.  
  18.         -- * ... then look for molten GOLD neighbours...
  19.         local gold_neighbours = {}
  20.         for ny = y - 1, y + 1 do
  21.             for nx = x - 1, x + 1 do
  22.                 local id = sim.partID(nx, ny)
  23.                 if id
  24.                 and sim.partProperty(id,  "type") == elem.DEFAULT_PT_LAVA
  25.                 and sim.partProperty(id, "ctype") == elem.DEFAULT_PT_GOLD
  26.                 and math.random(1, 100) <= 70 then -- * Accept this neighbour with a 70% chance.
  27.                     gold_neighbours[#gold_neighbours + 1] = id
  28.                 end
  29.             end
  30.         end
  31.  
  32.         -- * If there are at least three such neighbours...
  33.         if #gold_neighbours >= 3 then
  34.  
  35.             -- * ... then turn turn all of them and this particle into BGLD.
  36.             sim.partProperty(gold_neighbours[1], "ctype", BGLD)
  37.             sim.partProperty(gold_neighbours[2], "ctype", BGLD)
  38.             sim.partProperty(gold_neighbours[3], "ctype", BGLD)
  39.             sim.partProperty(i                 , "ctype", BGLD)
  40.         end
  41.     end
  42. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement