Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function neighbours(x,y,r,type)
- local array = {}
- for dx=-r,r do
- for dy=-r,r do
- if tpt.get_property("type", x+dx, y+dy) == type then array[#array+1] = sim.partID(x+dx, y+dy) end
- end
- end
- return array
- end
- local ntrm = elements.allocate("ELEMENT", "NTRM")
- elements.element(ntrm, elements.element(elements.DEFAULT_PT_PLUT))
- elements.property(ntrm, "Name", "NTRM")
- elements.property(ntrm, "Description", "Neutronium. Begins a chain reaction upon collision with neutrons.")
- elements.property(ntrm, "Colour", 0x00AAAA)
- elements.property(ntrm, "HighTemperature", 10001)
- elements.property(ntrm, "HighPressure", 257)
- local function ntrmUpdate(i,x,y,s,nt)
- local clife = tpt.get_property("life", i)
- local percent = 10
- local parts = neighbours(x, y, 1, elements.DEFAULT_PT_NEUT)
- if clife <= 0 then
- tpt.set_property("life", 3, i)
- end
- if clife > 0 and #parts > 0 and math.random(1, 1/(1-((1-percent/100)^(#parts)))) == 1 then
- local dx = math.random(-1,1)
- local dy = math.random(-1,1)
- if clife == 1 then
- sim.partCreate(-3, x+dx, y+dy, elements.DEFAULT_PT_NEUT)
- sim.partKill(i)
- else
- sim.partCreate(-3, x+dx, y+dy, elements.DEFAULT_PT_NEUT)
- tpt.set_property("life", clife-1, i)
- end
- end
- end
- elements.property(ntrm, "Update", ntrmUpdate)
Advertisement
Add Comment
Please, Sign In to add comment