Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- RAND, SRAN, GRAN, LRAN elements
- -- by nucular, Public Domain
- -- quite laggy at the moment :(
- local all = {}
- local gasses = {}
- local liquids = {}
- local solids = {}
- for k,v in pairs(tpt.el) do
- table.insert(all, v)
- if v.state == 1 then
- table.insert(solids, v)
- elseif v.state == 2 then
- table.insert(liquids, v)
- elseif v.state == 3 then
- table.insert(gasses, v)
- end
- end
- local function choice(t)
- return t[math.random(1, #t)]
- end
- local function randProp(id)
- tpt.parts[id].ctype = choice(all).id
- tpt.parts[id].life = math.random(0, 655)
- tpt.parts[id].tmp = math.random(0, 655)
- tpt.parts[id].tmp2 = math.random(0, 655)
- tpt.parts[id].vx = math.random(-10, 10)
- tpt.parts[id].vy = math.random(-10, 10)
- tpt.parts[id].temp = math.random(0, 655)
- end
- local RAND = elem.allocate("RANDOM", "RAND")
- elem.element(RAND, elem.element(elem.DEFAULT_PT_DMND))
- elem.property(RAND, "Name", "RAND")
- elem.property(RAND, "Colour", 0xFFFFFFFF)
- elem.property(RAND, "Description", "Explodes into a random element")
- elem.property(RAND, "MenuSection", elem.SC_SPECIAL)
- elem.property(RAND, "HighTemperature", 10000)
- elem.property(RAND, "LowTemperature", -1)
- tpt.element_func(
- function(i,x,y)
- for k,j in ipairs(sim.partNeighbours(x, y, 1, 1)) do
- if j then
- local t = tpt.parts[j].type
- if t == elem.DEFAULT_PT_FIRE or t == elem.DEFAULT_PT_PLSM or
- (t == RAND and tpt.parts[j].life > 10 and tpt.parts[i].life == 0) then
- tpt.parts[i].life = 50 + math.random(0, 60)
- end
- end
- end
- if tpt.parts[i].life == 1 then
- sim.partChangeType(i, choice(all).id)
- randProp(i)
- elseif tpt.parts[i].life > 1 then
- tpt.parts[i].life = tpt.parts[i].life - 1
- end
- end, RAND
- )
- local SRAN = elem.allocate("RANDOM", "SRAN")
- elem.element(SRAN, elem.element(elem.DEFAULT_PT_DUST))
- elem.property(SRAN, "Name", "SRAN")
- elem.property(SRAN, "Colour", 0xFFFFFFFF)
- elem.property(SRAN, "Description", "Explodes into a random solid or powder")
- elem.property(SRAN, "MenuSection", elem.SC_SPECIAL)
- elem.property(SRAN, "HighTemperature", 10000)
- elem.property(SRAN, "LowTemperature", -1)
- tpt.element_func(
- function(i,x,y)
- for k,j in ipairs(sim.partNeighbours(x, y, 1, 1)) do
- if j then
- local t = tpt.parts[j].type
- if t == elem.DEFAULT_PT_FIRE or t == elem.DEFAULT_PT_PLSM or
- (t == SRAN and tpt.parts[j].life > 10 and tpt.parts[i].life == 0) then
- tpt.parts[i].life = 50 + math.random(0, 60)
- end
- end
- end
- if tpt.parts[i].life == 1 then
- sim.partChangeType(i, choice(solids).id)
- randProp(i)
- elseif tpt.parts[i].life > 1 then
- tpt.parts[i].life = tpt.parts[i].life - 1
- end
- end, SRAN
- )
- local GRAN = elem.allocate("RANDOM", "GRAN")
- elem.element(GRAN, elem.element(elem.DEFAULT_PT_FOG))
- elem.property(GRAN, "Name", "GRAN")
- elem.property(GRAN, "Colour", 0xFFFFFFFF)
- elem.property(GRAN, "Description", "Explodes into a random gas")
- elem.property(GRAN, "MenuSection", elem.SC_SPECIAL)
- elem.property(GRAN, "HighTemperature", 10000)
- elem.property(GRAN, "LowTemperature", -1)
- tpt.element_func(
- function(i,x,y)
- for k,j in ipairs(sim.partNeighbours(x, y, 1, 1)) do
- if j then
- local t = tpt.parts[j].type
- if t == elem.DEFAULT_PT_FIRE or t == elem.DEFAULT_PT_PLSM or
- (t == GRAN and tpt.parts[j].life > 10 and tpt.parts[i].life == 0) then
- tpt.parts[i].life = 50 + math.random(0, 60)
- end
- end
- end
- if tpt.parts[i].life == 1 then
- sim.partChangeType(i, choice(gasses).id)
- randProp(i)
- elseif tpt.parts[i].life > 1 then
- tpt.parts[i].life = tpt.parts[i].life - 1
- end
- end, GRAN
- )
- local LRAN = elem.allocate("RANDOM", "LRAN")
- elem.element(LRAN, elem.element(elem.DEFAULT_PT_WATR))
- elem.property(LRAN, "Name", "LRAN")
- elem.property(LRAN, "Colour", 0xFFFFFFFF)
- elem.property(LRAN, "Description", "Explodes into a random liquid")
- elem.property(LRAN, "MenuSection", elem.SC_SPECIAL)
- elem.property(LRAN, "HighTemperature", 10000)
- elem.property(LRAN, "LowTemperature", -1)
- tpt.element_func(
- function(i,x,y)
- for k,j in ipairs(sim.partNeighbours(x, y, 1, 1)) do
- if j then
- local t = tpt.parts[j].type
- if t == elem.DEFAULT_PT_FIRE or t == elem.DEFAULT_PT_PLSM or
- (t == LRAN and tpt.parts[j].life > 10 and tpt.parts[i].life == 0) then
- tpt.parts[i].life = 50 + math.random(0, 60)
- end
- end
- end
- if tpt.parts[i].life == 1 then
- sim.partChangeType(i, choice(liquids).id)
- randProp(i)
- elseif tpt.parts[i].life > 1 then
- tpt.parts[i].life = tpt.parts[i].life - 1
- end
- end, LRAN
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement