Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local iod = elements.allocate("chem", "iod")
- elements.element(iod, elements.element(elements.DEFAULT_PT_STNE))
- elements.property(iod, "Name", "IODN")
- elements.property(iod, "Colour", 0x1E1A2E)
- elements.property(iod, "Description", "Iodine. Reactive non-metal. Sublimes.")
- elements.property(iod, "Gravity", 1)
- elements.property(iod, "Weight", 90)
- elements.property(iod, "HeatConduct", 90)
- elements.property(iod, "Hardness", 1)
- local gasiod = elements.allocate("chem", "giod")
- elements.element(gasiod, elements.element(elements.DEFAULT_PT_HYGN))
- elements.property(gasiod, "Name", "GIOD")
- elements.property(gasiod, "MenuVisible", 0)
- elements.property(gasiod, "Gravity", 0.1)
- elements.property(gasiod, "Diffusion", 1)
- elements.property(gasiod, "Colour", 0x963296)
- elements.property(gasiod, "Hardness", 1)
- function propiod(i,x,y,s,nt)
- local eltemp = tpt.get_property("temp", i)
- local eltmp = tpt.get_property("tmp", i)
- if eltemp >= 267.9 then
- if eltemp < 386.85 then
- local chance = math.floor(150000 / ((eltemp - 265.9)*0.1)^3) -- solid phase equilibrium
- if math.random(1, chance) == 1 then
- tpt.set_property("type", "giod", i)
- end
- end
- end
- if nt > 0 then
- for dx = -1, 1, 1 do
- for dy = -1, 1, 1 do
- local eltype = tpt.get_property("type", x+dx, y+dy)
- if (eltype == elements.DEFAULT_PT_BRMT or eltype == elements.DEFAULT_PT_IRON) then -- react with brmt or iron
- tpt.set_property("temp", eltemp + 3, i)
- if eltemp > 313.15 then
- tpt.set_property("temp", eltemp + 6, i)
- end
- end
- if eltype == elements.DEFAULT_PT_NEUT then -- change tmp to 1 and absorb neut
- if eltmp < 1 then
- tpt.set_property("tmp", 1, i)
- tpt.delete(x+dx, y+dy)
- end
- end
- end
- end
- end
- if eltmp == 1 then -- radioactive decay (tmp is 1)
- if math.random(1, 500) == 1 then
- local vxrand = math.random(-30,30)
- local vyrand = math.random(-30,0)
- if math.abs(vxrand) + math.abs(vyrand) > 15 then
- tpt.set_property("type", "elec", i)
- tpt.set_property("vx", vxrand/10, i)
- tpt.set_property("vy", vyrand/10, i)
- tpt.set_property("life", 680, i)
- tpt.create(x+math.random(-1,1), y+math.random(-1,1), "nble")
- end
- end
- end
- end
- function propgasiod(i,x,y,s,nt)
- local eltemp = tpt.get_property("temp", i)
- local eltmp = tpt.get_property("temp", i)
- if eltemp < 386.85 then
- if eltemp >= 268.9 then
- local chance = math.floor(((eltemp - 265.9)*0.1)^3 * 80) -- vapor phase equilibrium
- if math.random(1, chance) == 1 then
- tpt.set_property("type", "iodn", i)
- end
- else
- tpt.set_property("type", "iodn", i)
- end
- end
- if nt > 0 then
- for dx= -1, 1, 1 do
- for dy = -1, 1, 1 do
- local eltype = tpt.get_property("type", x+dx, y+dy)
- if eltype == elements.DEFAULT_PT_BRMT then
- if eltemp > 356.85 then
- tpt.set_property("temp", eltemp + 96, i)
- if eltemp > 1203.15 then
- tpt.delete(x+dx, y+dy)
- tpt.create(x+dx, y+dy, "fire")
- tpt.set_property("type", "lava", i)
- tpt.set_property("ctype", "salt", i)
- return
- end
- end
- end
- if eltype == elements.DEFAULT_PT_IRON then
- tpt.set_property ("temp", eltemp + 2, i)
- if eltemp > 573.15 then
- tpt.set_property ("temp", eltemp + 5, i)
- if eltemp > 773.15 then
- tpt.set_property("temp", eltemp + 12, i)
- if eltemp > 1223.15 then
- if math.random(1, 100) == 1 then
- tpt.delete(x+dx, y+dy)
- tpt.create(x+dx, y+dy, "fire")
- tpt.set_property("type", "fire", x+dx, y+dy)
- tpt.set_property("type", "lava", i)
- tpt.set_property("ctype", "salt", i)
- return
- end
- end
- end
- end
- end
- if eltype == elements.DEFAULT_PT_NEUT then
- if tpt.get_property("tmp", i) < 1 then
- tpt.set_property("tmp", 1, i)
- tpt.delete(x+dx, y+dy)
- end
- end
- end
- end
- end
- if tpt.get_property("tmp", i) == 1 then
- if math.random(1, 500) == 1 then
- local vxrand = math.random(-30,30)
- local vyrand = math.random(-30,30)
- if math.abs(vxrand) + math.abs(vyrand) > 20 then
- tpt.set_property("type", "elec", i)
- tpt.set_property("vx", vxrand/10, i)
- tpt.set_property("vy", vyrand/10, i)
- tpt.set_property("life", 680, i)
- tpt.create(x+math.random(-1,1), y+math.random(-1,1), "nble")
- end
- end
- end
- end
- function graphiod(i, colr, colg, colb)
- if tpt.get_property("tmp2", i) == 0 then
- tpt.set_property("tmp2", math.random(1,5) * 5, i)
- end
- local colfact = tpt.get_property("tmp2", i)
- return 1, 0x00000001, 255, 24+colfact, 20+colfact, 40+colfact, 0, 0, 0, 0
- end
- elements.property(iod, "HighTemperature", 386.85)
- elements.property(iod, "HighTemperatureTransition", elements.CHEM_PT_GIOD)
- elements.property(iod, "Update", propiod)
- elements.property(iod, "Graphics", graphiod)
- elements.property(gasiod, "Update", propgasiod)
Advertisement
Add Comment
Please, Sign In to add comment