Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local BGLD = elem.allocate("LBPHACKER", "BGLD") -- * Allocate element ID.
- elem.element(BGLD, elem.element(elem.DEFAULT_PT_GOLD)) -- * Base it off GOLD.
- elem.property(BGLD, "Name", "BGLD") -- * Name it BGLD in the menu.
- elem.property(BGLD, "Color", 0x238AD6) -- * Give it a bluish colour.
- elem.property(BGLD, "HighTemperatureTransition", 1500) -- * Make it a bit more difficult to melt.
- elem.property(BGLD, "Graphics", function(i, r, g, b) -- * A lot like GOLD's graphics function.
- return 0, ren.PMODE_FLAT, 255,
- r + math.random(-5, 4),
- g + math.random(-5, 4),
- b + math.random(-5, 4)
- end)
- elem.property(elem.DEFAULT_PT_LAVA, "Update", function(i, x, y, ...)
- -- * If this particle is molten IRON...
- if sim.partProperty(i, "ctype") == elem.DEFAULT_PT_IRON then
- -- * ... then look for molten GOLD neighbours...
- local gold_neighbours = {}
- for ny = y - 1, y + 1 do
- for nx = x - 1, x + 1 do
- local id = sim.partID(nx, ny)
- if id
- and sim.partProperty(id, "type") == elem.DEFAULT_PT_LAVA
- and sim.partProperty(id, "ctype") == elem.DEFAULT_PT_GOLD
- and math.random(1, 100) <= 70 then -- * Accept this neighbour with a 70% chance.
- gold_neighbours[#gold_neighbours + 1] = id
- end
- end
- end
- -- * If there are at least three such neighbours...
- if #gold_neighbours >= 3 then
- -- * ... then turn turn all of them and this particle into BGLD.
- sim.partProperty(gold_neighbours[1], "ctype", BGLD)
- sim.partProperty(gold_neighbours[2], "ctype", BGLD)
- sim.partProperty(gold_neighbours[3], "ctype", BGLD)
- sim.partProperty(i , "ctype", BGLD)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement