Last active
April 25, 2024 23:13
-
-
Save rdococ/fc7b12df6464595f49918c95ef79935e to your computer and use it in GitHub Desktop.
Exotic Particles for TPT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Exotic Particles v7 | |
== | |
This script features several elements based on bizarre and hypothetical forms of matter. | |
- Build forcefields with Higgs bosons | |
- Reverse time by shooting tachyons into black holes (though be careful, you cannot 'unrevert'!) | |
- Create perpetual motion by mixing negative mass with gravitons | |
- Use muons to catalyze nuclear fusion | |
- Power your creations with explosive positronium | |
- Siphon heat from the matter of a neutron star | |
Elements | |
= | |
- HIGS | |
Higgs bosons. Generate pressure, "condenses" tachyons into more HIGS. | |
- TACH | |
Tachyons break the light speed barrier and accelerate continuously. | |
Feed them to GSNG to force the simulation to rewind and erase their existence from the timeline. | |
- MUON | |
Muons, the heavier sibling to the electron. Damages electronics and catalyzes fusion reactions. | |
- NMTR | |
Negative mass matter. Generates negative gravity and drag, cancels out regular matter. | |
Interactions with GRVT are very fun. | |
- POSM | |
Positronium. Light, volatile semi-antimatter gas. | |
Spontaneously explodes with heat and PHOT. | |
- NEUM | |
Neutronium. Dense matter made entirely out of neutrons. | |
Absorbs regular matter, turning it into more neutronium and generating heat & pressure. | |
Collapses into QGPL with too much energy. | |
ELEC can be used to strip away at neutronium, producing QGPL. | |
- GSNG | |
Gravitational equivalent to SING. Consumes all matter and energy that enters it. | |
Emits Hawking radiation consisting of hot ELEC. | |
- SFLD | |
Superfluid, climbs the walls of its containers. Evaporates into NBLE. | |
- BOSE | |
Bose-Einstein condensate. Gas in an unusual quantum state, disappears with warmth. | |
- QGPL | |
Quark-gluon plasma. Extremely hot, generates massive pressure. Decays into subatomic particles when cooled down. | |
Changelog | |
= | |
v7: | |
- Tweaked POSM explosion | |
- Added more elements to MUON fusion | |
- Made TACH motion cooler | |
- Fixed TACH using negative TMP values | |
v6: | |
- Removed pressure requirements for MUON-catalyzed fusion | |
- MUON-catalyzed fusion is no longer 'cold' | |
- Gave NMTR behaviour more like AMTR | |
- Several changes to NEUM | |
v5: | |
- MUON no longer penetrates matter | |
- MUON now triggers cold fusion in HYGN, NBLE | |
- Graphical changes to NEUM, GSNG | |
v4: | |
- Reduced QGPL pressure | |
- Miscellaneous changes | |
v3: | |
- Removed PLEK, added MUON | |
- Many TACH changes - moves substantially differently, now only reverts with GSNG | |
- Made HIGS just generate pressure | |
- GSNG now only emits ELEC, no longer conducts heat | |
v2: | |
- Added POSM | |
- Removed NEUM pressure effect, reduced gravitational effect & weight | |
]] | |
local HIGS = elem.allocate("exotics", "higs") -- Higgs boson | |
local TACH = elem.allocate("exotics", "tach") -- Tachyon | |
local MUON = elem.allocate("exotics", "muon") -- Muon | |
local NMTR = elem.allocate("exotics", "nmtr") -- Negative mass matter | |
local POSM = elem.allocate("exotics", "posm") -- Positronium | |
local NEUM = elem.allocate("exotics", "neum") -- Neutronium | |
local GSNG = elem.allocate("exotics", "gsng") -- More realistic black hole | |
local SFLD = elem.allocate("exotics", "sfld") -- Superfluid | |
local BOSE = elem.allocate("exotics", "bose") -- Bose-Einstein condensate | |
local QGPL = elem.allocate("exotics", "qgpl") -- Quark-gluon plasma | |
local elem, sim = elements, sim | |
local random, floor, min, max, sin, cos, atan2, sqrt, abs, ceil, exp = math.random, math.floor, math.min, math.max, math.sin, math.cos, math.atan2, math.sqrt, math.abs, math.ceil, math.exp | |
local pi = math.pi | |
local unpack = unpack | |
local partCreate, partProperty, partKill, partExists = sim.partCreate, sim.partProperty, sim.partKill, sim.partExists | |
local permMap = {[0] = true, [3] = true, [4] = true, [5] = true, [6] = elem.TYPE_LIQUID, [7] = true, [10] = elem.TYPE_POWDER, [11] = true, [12] = true, [13] = elem.TYPE_GAS, [14] = true, [15] = elem.TYPE_ENERGY, [16] = true, [17] = true, [18] = true, [255] = true} | |
local function wallPermeable(tx, ty, prop) | |
tx, ty = floor(tx), floor(ty) | |
local wall = tpt.get_wallmap(tx, ty) | |
local elec = tpt.get_elecmap(tx, ty) | |
if permMap[wall] == true or permMap[wall] == prop then | |
return true | |
end | |
if wall == 2 and elec then | |
return true | |
end | |
return false | |
end | |
local indestructible = { | |
[elem.DEFAULT_PT_DMND] = true, | |
[elem.DEFAULT_PT_CLNE] = true, | |
[elem.DEFAULT_PT_VOID] = true | |
} | |
--[[SUBATOMIC PARTICLES]] | |
elem.element(HIGS, elem.element(elem.DEFAULT_PT_ELEC)) | |
elem.property(HIGS, "Name", "HIGS") | |
elem.property(HIGS, "MenuSection", elem.SC_NUCLEAR) | |
elem.property(HIGS, "Description", "Higgs boson. Generates pressure, converts tachyons into more of itself.") | |
elem.property(HIGS, "Color", 0xFFBB88) | |
elem.property(HIGS, "HotAir", 0.025) | |
elem.property(HIGS, "Properties", elem.TYPE_ENERGY + elem.PROP_LIFE_DEC + elem.PROP_LIFE_KILL_DEC) | |
elem.property(HIGS, "Create", function (self, x, y, type, v) | |
partProperty(self, sim.FIELD_LIFE, random(20, 60)) | |
local angle, speed = random() * pi * 2, 2 + random() * 0.4 | |
partProperty(self, sim.FIELD_VX, cos(angle) * speed) | |
partProperty(self, sim.FIELD_VY, sin(angle) * speed) | |
end) | |
elem.property(HIGS, "Graphics", function (self, r, g, b) | |
return 1, ren.PMODE_FLAT + ren.FIRE_ADD, 255, r, g, b, 64, r, g, b | |
end) | |
local flash = 0 | |
local rewinds = {} | |
local function findTachyon(tmp) | |
for part in sim.parts() do | |
if partProperty(part, sim.FIELD_TYPE) == TACH and partProperty(part, sim.FIELD_TMP) == tmp then | |
return part | |
end | |
end | |
end | |
local function rewind(tmp, first) | |
local found | |
if not first then | |
found = findTachyon(tmp) | |
if not found then return end | |
end | |
while true do | |
local restored = sim.historyRestore() | |
found = findTachyon(tmp) | |
if not restored or not found then break end | |
end | |
if found then | |
partProperty(found, sim.FIELD_TMP2, 1) | |
partKill(found) | |
end | |
sim.takeSnapshot() | |
flash = 30 | |
end | |
elem.element(TACH, elem.element(elem.DEFAULT_PT_ELEC)) | |
elem.property(TACH, "Name", "TACH") | |
elem.property(TACH, "MenuSection", elem.SC_NUCLEAR) | |
elem.property(TACH, "Description", "Tachyons. Exotic, faster-than-light particles. Will UNDO the simulation if erased by GSNG.") | |
elem.property(TACH, "Color", 0x8855FF) | |
elem.property(TACH, "Properties", elem.TYPE_ENERGY + elem.PROP_LIFE_DEC + elem.PROP_LIFE_KILL_DEC) | |
elem.property(TACH, "Create", function (self, x, y, type, v) | |
partProperty(self, sim.FIELD_TMP, random(0, 2^31-1)) | |
partProperty(self, sim.FIELD_LIFE, random(10, 60)) | |
partProperty(self, sim.FIELD_TMP2, random(0, 10)) | |
local angle, speed = random() * pi * 2, random() * 6 + 3 | |
partProperty(self, sim.FIELD_VX, cos(angle) * speed) | |
partProperty(self, sim.FIELD_VY, sin(angle) * speed) | |
end) | |
elem.property(TACH, "Update", function (self, x, y, s, nt) | |
local vx, vy = partProperty(self, sim.FIELD_VX), partProperty(self, sim.FIELD_VY) | |
if random(1, 3) == 1 then | |
local extended, rewinding = false, false | |
for dx = -2, 2 do | |
for dy = -2, 2 do | |
local part = sim.photons(x + dx, y + dy) | |
if part and partExists(part) then | |
local type = partProperty(part, sim.FIELD_TYPE) | |
if not extended and type == elem.DEFAULT_PT_PROT then | |
if random(1, 5) == 1 then | |
partKill(part) | |
end | |
partProperty(self, sim.FIELD_LIFE, partProperty(self, sim.FIELD_LIFE) + 5) | |
partProperty(self, sim.FIELD_TMP2, partProperty(self, sim.FIELD_TMP2) - 5) | |
extended = true | |
elseif type == HIGS then | |
partCreate(-3, x, y, HIGS) | |
partKill(self) | |
return | |
end | |
end | |
local part = sim.pmap(x + dx, y + dy) | |
if part and partExists(part) then | |
local type = partProperty(part, sim.FIELD_TYPE) | |
if type == GSNG then | |
table.insert(rewinds, partProperty(self, sim.FIELD_TMP)) | |
rewinding = true | |
end | |
end | |
if rewinding then break end | |
end | |
if rewinding then break end | |
end | |
end | |
local angle = atan2(vy, vx) | |
local life, tmp2 = partProperty(self, sim.FIELD_LIFE), partProperty(self, sim.FIELD_TMP2) | |
local speed = 3 + 1.1 ^ (tmp2 - 20) | |
partProperty(self, sim.FIELD_VX, cos(angle) * speed) | |
partProperty(self, sim.FIELD_VY, sin(angle) * speed) | |
partProperty(self, sim.FIELD_TMP2, partProperty(self, sim.FIELD_TMP2) + 1) | |
end) | |
elem.property(TACH, "Graphics", function (self, r, g, b) | |
return 1, ren.PMODE_FLAT + ren.FIRE_BLEND + ren.PMODE_GLOW, 255, r, g, b, 96, r, g, b | |
end) | |
event.register(event.tick, function () | |
if flash <= 0 then return end | |
graphics.fillRect(0, 0, sim.XRES, sim.YRES, 0x88, 0x55, 0xFF, min(flash * 255 / 30, 128)) | |
end) | |
event.register(event.aftersim, function () | |
if flash > 0 then | |
flash = flash - 1 | |
end | |
if #rewinds <= 0 then return end | |
local first = true | |
print("Reverted") | |
for _, tmp in ipairs(rewinds) do | |
rewind(tmp, first) | |
first = false | |
end | |
rewinds = {} | |
end) | |
local electronics = { | |
[elem.DEFAULT_PT_PSCN] = true, | |
[elem.DEFAULT_PT_NSCN] = true, | |
[elem.DEFAULT_PT_PTCT] = true, | |
[elem.DEFAULT_PT_NTCT] = true, | |
[elem.DEFAULT_PT_INST] = true | |
} | |
elem.element(MUON, elem.element(elem.DEFAULT_PT_ELEC)) | |
elem.property(MUON, "Name", "MUON") | |
elem.property(MUON, "MenuSection", elem.SC_NUCLEAR) | |
elem.property(MUON, "Description", "Muons, the heavy sibling to electrons. Jams electronics, catalyzes fusion.") | |
elem.property(MUON, "Color", 0xDDEE55) | |
elem.property(MUON, "Properties", elem.TYPE_ENERGY + elem.PROP_LIFE_DEC + elem.PROP_LIFE_KILL_DEC) | |
elem.property(MUON, "Create", function (self, x, y, type, v) | |
partProperty(self, sim.FIELD_LIFE, random(10, 100)) | |
local angle, speed = random() * pi * 2, random() * 1 + 2 | |
partProperty(self, sim.FIELD_VX, cos(angle) * speed) | |
partProperty(self, sim.FIELD_VY, sin(angle) * speed) | |
end) | |
elem.property(MUON, "Update", function (self, x, y, s, nt) | |
local vx, vy = partProperty(self, sim.FIELD_VX), partProperty(self, sim.FIELD_VY) | |
local speed = sqrt(vx ^ 2 + vy ^ 2) | |
if random(1, 10) ~= 1 then return end | |
for part, nx, ny in sim.neighbors(x, y, 2, 2) do | |
if part and sim.partExists(part) then | |
local type, ctype, life = partProperty(part, sim.FIELD_TYPE), partProperty(part, sim.FIELD_CTYPE), partProperty(part, sim.FIELD_LIFE) | |
local cx, cy = nx / sim.CELL, ny / sim.CELL | |
local pressure = sim.pressure(cx, cy) | |
if type == elem.DEFAULT_PT_SPRK and electronics[ctype] or electronics[type] and life > 0 or type == elem.DEFAULT_PT_SWCH and life > 0 and life < 10 or type == elem.DEFAULT_PT_WIRE and ctype > 0 then | |
partProperty(part, sim.FIELD_TYPE, random() < 0.5 and elem.DEFAULT_PT_BREC or elem.DEFAULT_PT_NTCT) | |
partKill(self) | |
return | |
elseif type == elem.DEFAULT_PT_HYGN then | |
--[[ | |
Typical fusion: | |
Requirements: 2000 degrees & 50 pressure | |
Results: NBLE (with tmp = 1), PLSM, NEUT, yellow PHOT, 10% chance of an ELEC, +30 pressure, +1000±250 degrees | |
]] | |
partKill(self) | |
sim.pressure(cx, cy, pressure + 30) | |
partProperty(part, sim.FIELD_TYPE, elem.DEFAULT_PT_NBLE) | |
partProperty(part, sim.FIELD_TEMP, partProperty(part, sim.FIELD_TEMP) + 1000) | |
partProperty(part, sim.FIELD_TMP, 1) | |
partCreate(-3, x, y, elem.DEFAULT_PT_NEUT) | |
partProperty(partCreate(-3, nx, ny, elem.DEFAULT_PT_PHOT), sim.FIELD_CTYPE, 8126464) | |
if random(1, 10) == 1 then | |
partCreate(-3, nx, ny, elem.DEFAULT_PT_ELEC) | |
end | |
return | |
elseif type == elem.DEFAULT_PT_NBLE then | |
--[[ | |
Typical fusion: | |
Requirements: 5000 degrees & 100 pressure | |
Results: PLSM, NEUT, red PHOT, CO2, +50 pressure, =9000 degrees | |
]] | |
partKill(self) | |
sim.pressure(cx, cy, pressure + 50) | |
partProperty(part, sim.FIELD_TYPE, elem.DEFAULT_PT_CO2) | |
partProperty(part, sim.FIELD_TEMP, 9000) | |
partCreate(-3, x, y, elem.DEFAULT_PT_NEUT) | |
partProperty(partCreate(-3, nx, ny, elem.DEFAULT_PT_PHOT), sim.FIELD_CTYPE, 260046848) | |
return | |
elseif type == elem.DEFAULT_PT_CO2 then | |
--[[ | |
When CO2 is at 200 pressure and heated to 9,500 degrees, it will transform into O2, add 100 pressure, | |
release 1 NEUT and have a 2% chance of additionally releasing one ELEC. | |
Both the NEUT and the ELEC are spawned at the maximum temperature. | |
]] | |
partKill(self) | |
sim.pressure(cx, cy, pressure + 100) | |
partProperty(part, sim.FIELD_TYPE, elem.DEFAULT_PT_OXYG) | |
partProperty(part, sim.FIELD_TEMP, 9500) | |
partCreate(-3, x, y, elem.DEFAULT_PT_NEUT) | |
if random(1, 100) <= 2 then | |
partCreate(-3, x, y, elem.DEFAULT_PT_ELEC) | |
end | |
return | |
elseif type == elem.DEFAULT_PT_OXYG then | |
--[[When OXYG is at 250 pressure, heated to 9720 degrees and encountered with high Newtonian gravity, it will fuse itself to molten BMTL and create a shockwave of the maximum possible temperature and pressure in TPT if under the influence of a gravitational well. This also creates GRVT.]] | |
partKill(self) | |
partProperty(part, sim.FIELD_TYPE, elem.DEFAULT_PT_BMTL) | |
if sim.gravMap(x / sim.CELL, y / sim.CELL) > 20 then | |
sim.pressure(cx, cy, sim.MAX_PRESSURE) | |
partProperty(part, sim.FIELD_TEMP, sim.MAX_TEMP) | |
partCreate(-3, x, y, elem.DEFAULT_PT_GRVT) | |
end | |
return | |
end | |
end | |
end | |
end) | |
elem.property(MUON, "Graphics", function (self, r, g, b) | |
return 1, ren.PMODE_FLAT + ren.FIRE_ADD, 255, r, g, b, 64, r, g, b | |
end) | |
--[[EXOTIC STATES OF MATTER]] | |
elem.element(NMTR, elem.element(elem.DEFAULT_PT_BOYL)) | |
elem.property(NMTR, "Name", "NMTR") | |
elem.property(NMTR, "MenuSection", elem.SC_NUCLEAR) | |
elem.property(NMTR, "Description", "Negative matter. Produces negative gravity and drag, cancels out regular matter.") | |
elem.property(NMTR, "Color", 0x332255) | |
elem.property(NMTR, "Gravity", 0.1) | |
elem.property(NMTR, "Diffusion", 1) | |
elem.property(NMTR, "Advection", -0.7) | |
elem.property(NMTR, "AirDrag", -0.02) | |
elem.property(NMTR, "PhotonReflectWavelengths", 0) | |
elem.property(NMTR, "Update", function (self, x, y, s, nt) | |
sim.gravMap(x / sim.CELL, y / sim.CELL, 1, 1, -0.02) | |
if random(1, 5) == 1 then | |
for dx = -2, 2 do | |
for dy = -2, 2 do | |
local part = sim.pmap(x + dx, y + dy) | |
if part and partExists(part) then | |
local type = partProperty(part, sim.FIELD_TYPE) | |
if type ~= NMTR and type ~= TACH and not indestructible[type] then | |
partKill(self) | |
partKill(part) | |
return | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.property(NMTR, "Graphics", function (self, r, g, b) | |
return 1, ren.PMODE_FLAT + ren.FIRE_BLEND, 255, r, g, b, 128, r, g, b | |
end) | |
elem.element(NEUM, elem.element(elem.DEFAULT_PT_STNE)) | |
elem.property(NEUM, "Name", "NEUM") | |
elem.property(NEUM, "MenuSection", elem.SC_NUCLEAR) | |
elem.property(NEUM, "Description", "Neutronium. Dense matter state. Consumes regular matter and heats up, explodes into QGPL.") | |
elem.property(NEUM, "Color", 0x44BBFF) | |
elem.property(NEUM, "Weight", 99) | |
elem.property(NEUM, "Gravity", 0.9) | |
elem.property(NEUM, "HeatConduct", 60) | |
elem.property(NEUM, "Temperature", 299.15) | |
elem.property(NEUM, "Properties", elem.TYPE_POWDER) | |
elem.property(NEUM, "HighTemperature", math.huge) | |
elem.property(NEUM, "HighPressure", math.huge) | |
elem.property(NEUM, "Update", function (self, x, y, s, nt) | |
if partProperty(self, sim.FIELD_TEMP) >= 9500 or sim.pressure(x / sim.CELL, y / sim.CELL) >= 100 then | |
partCreate(-3, x, y, QGPL) | |
partKill(self) | |
return | |
end | |
if random(1, 5) == 1 then | |
for dx = -2, 2 do | |
for dy = -2, 2 do | |
local part = sim.pmap(x + dx, y + dy) | |
if part and partExists(part) and random(1, 20) == 1 then | |
local type = partProperty(part, sim.FIELD_TYPE) | |
if type ~= NEUM and not indestructible[type] then | |
if random(1, 2) == 1 then | |
partProperty(part, sim.FIELD_TYPE, NEUM) | |
else | |
partKill(part) | |
end | |
partProperty(self, sim.FIELD_TEMP, partProperty(self, sim.FIELD_TEMP) + 6000) | |
sim.pressure(x / sim.CELL, y / sim.CELL, 1, 1, sim.pressure(x / sim.CELL, y / sim.CELL) + 1) | |
end | |
end | |
local part = sim.photons(x + dx, y + dy) | |
if part and partExists(part) then | |
local type = partProperty(part, sim.FIELD_TYPE) | |
if type == elem.DEFAULT_PT_ELEC then | |
partCreate(-3, x, y, QGPL) | |
partKill(self) | |
partKill(part) | |
return | |
end | |
end | |
end | |
end | |
end | |
sim.gravMap(x / sim.CELL, y / sim.CELL, 1, 1, 0.1) | |
end) | |
elem.property(NEUM, "Graphics", function (self, r, g, b) | |
return 1, ren.PMODE_FLAT + ren.FIRE_BLEND, 255, r, g, b, 120, 10, 40, 120 | |
end) | |
sim.can_move(elem.DEFAULT_PT_NEUT, NEUM, 2) | |
local function annihilatePOSM(self, x, y) | |
partCreate(-3, x, y, elem.DEFAULT_PT_PLSM) | |
partCreate(-3, x, y, elem.DEFAULT_PT_PHOT) | |
sim.pressure(x / sim.CELL, y / sim.CELL, 1, 1, sim.pressure(x / sim.CELL, y / sim.CELL) + 20) | |
partKill(self) | |
end | |
elem.element(POSM, elem.element(elem.DEFAULT_PT_HYGN)) | |
elem.property(POSM, "Name", "POSM") | |
elem.property(POSM, "MenuSection", elem.SC_NUCLEAR) | |
elem.property(POSM, "Description", "Positronium. Volatile, part-antimatter gas. Explodes with warmth and PHOT.") | |
elem.property(POSM, "Color", 0xAA4444) | |
elem.property(POSM, "Weight", 0) | |
elem.property(POSM, "HeatConduct", 60) | |
elem.property(POSM, "Temperature", 70) | |
elem.property(POSM, "Diffusion", 2) | |
elem.property(POSM, "Properties", elem.TYPE_GAS) | |
elem.property(POSM, "HighTemperature", math.huge) | |
elem.property(POSM, "HighPressure", math.huge) | |
elem.property(POSM, "Update", function (self, x, y, s, nt) | |
if random(1, 3) == 1 and partProperty(self, sim.FIELD_TEMP) >= 273.15 then | |
return annihilatePOSM(self, x, y) | |
end | |
if random(1, 5) == 1 then | |
for dx = -2, 2 do | |
for dy = -2, 2 do | |
local part = sim.photons(x + dx, y + dy) | |
if part and partExists(part) and partProperty(part, sim.FIELD_TYPE) == PHOT then | |
return annihilatePOSM(self, x, y) | |
end | |
end | |
end | |
end | |
end) | |
elem.property(POSM, "Graphics", function (self, r, g, b) | |
return 1, ren.PMODE_BLUR + ren.FIRE_BLEND, 255, r, g, b, 64, r, g, b | |
end) | |
elem.element(GSNG, elem.element(elem.DEFAULT_PT_GRAV)) | |
elem.property(GSNG, "Name", "GSNG") | |
elem.property(GSNG, "MenuSection", elem.SC_NUCLEAR) | |
elem.property(GSNG, "Description", "Gravitational singularity. Requires Newtonian gravity. Grows as it consumes particles, decays over time.") | |
elem.property(GSNG, "Color", 0x222222) | |
elem.property(GSNG, "Loss", 1) | |
elem.property(GSNG, "Falldown", 2) | |
elem.property(GSNG, "Advection", 0) | |
elem.property(GSNG, "Flammable", 0) | |
elem.property(GSNG, "Hardness", 0) | |
elem.property(GSNG, "HeatConduct", 0) | |
elem.property(GSNG, "Temperature", 0) | |
elem.property(GSNG, "PhotonReflectWavelengths", 0) | |
elem.property(GSNG, "Properties", elem.TYPE_LIQUID + elem.PROP_BLACK + elem.PROP_NEUTABSORB + elem.PROP_DEADLY + elem.PROP_NOAMBHEAT) | |
elem.property(GSNG, "Update", function (self, x, y, s, nt) | |
if nt > 0 and random(1, 10) == 1 then | |
local dx, dy = random() * 6 - 3, random() * 6 - 3 | |
if not sim.pmap(x + dx, y + dy) then | |
local temp = partProperty(self, sim.FIELD_TEMP) | |
if random(1, 10) == 1 then | |
partKill(self) | |
end | |
if random(1, 5) == 1 then | |
local part = partCreate(-3, x + dx, y + dy, elem.DEFAULT_PT_ELEC) | |
partProperty(part, sim.FIELD_TEMP, temp) | |
local dist = sqrt(dx ^ 2 + dy ^ 2) | |
local speed = random() + 12 | |
partProperty(part, sim.FIELD_VX, dx * speed / dist) | |
partProperty(part, sim.FIELD_VY, dy * speed / dist) | |
partProperty(part, sim.FIELD_TEMP, random(100, 1000) + 273.15) | |
end | |
return | |
end | |
end | |
if random(1, 10) == 1 then | |
for dx = -2, 2 do | |
for dy = -2, 2 do | |
local part = sim.pmap(x + dx, y + dy) | |
if part and partExists(part) then | |
local type = partProperty(part, sim.FIELD_TYPE) | |
if type ~= GSNG and type ~= NMTR and not indestructible[type] then | |
if random(1, 2) == 1 then | |
partProperty(part, sim.FIELD_TYPE, GSNG) | |
else | |
partKill(part) | |
end | |
end | |
local part = sim.photons(x + dx, y + dy) | |
if part and partExists(part) and partProperty(part, sim.FIELD_TYPE) ~= TACH then | |
partKill(part) | |
end | |
else | |
local part = sim.photons(x + dx, y + dy) | |
if part and partExists(part) and partProperty(part, sim.FIELD_TYPE) ~= TACH then | |
if random(1, 2) == 1 then | |
partProperty(part, sim.FIELD_TYPE, GSNG) | |
else | |
partKill(part) | |
end | |
end | |
end | |
end | |
end | |
end | |
sim.gravMap(x / sim.CELL, y / sim.CELL, 1, 1, 2) | |
end) | |
elem.property(GSNG, "Graphics", function (self, r, g, b) | |
return 1, ren.FIRE_BLEND, 255, r, g, b, 255, 0x18, 0x18, 0x18 | |
end) | |
sim.can_move(HIGS, GSNG, 2) | |
sim.can_move(TACH, GSNG, 2) | |
sim.can_move(MUON, GSNG, 2) | |
sim.can_move(elem.DEFAULT_PT_ELEC, GSNG, 2) | |
sim.can_move(elem.DEFAULT_PT_PROT, GSNG, 2) | |
sim.can_move(elem.DEFAULT_PT_PHOT, GSNG, 2) | |
local function sfldBlocked(x, y) | |
if not wallPermeable(x / sim.CELL, y / sim.CELL, elem.TYPE_LIQUID) then return true end | |
local part = sim.pmap(x, y) | |
if part and partExists(part) then | |
local type = partProperty(part, sim.FIELD_TYPE) | |
return type ~= SFLD and sim.can_move(SFLD, type) == 0 | |
end | |
return false | |
end | |
elem.element(SFLD, elem.element(elem.DEFAULT_PT_WATR)) | |
elem.property(SFLD, "Name", "SFLD") | |
elem.property(SFLD, "Description", "Superfluid. Extremely cold fluid, likes to climb containers.") | |
elem.property(SFLD, "Color", 0x88DDEE) | |
elem.property(SFLD, "Temperature", 0) | |
elem.property(SFLD, "LowTemperature", -math.huge) | |
elem.property(SFLD, "HighPressure", math.huge) | |
elem.property(SFLD, "LowPressure", -math.huge) | |
elem.property(SFLD, "HighTemperature", 10) | |
elem.property(SFLD, "HighTemperatureTransition", elem.DEFAULT_PT_NBLE) | |
elem.property(SFLD, "Update", function (self, x, y, s, nt) | |
local vx, vy = partProperty(self, sim.FIELD_VX), partProperty(self, sim.FIELD_VY) | |
if vy > 0.2 then | |
return | |
end | |
local dir = random(0, 1) * 2 - 1 | |
for dx = -dir * 3, dir * 3, dir * 6 do | |
if sfldBlocked(x + dx, y) then | |
partProperty(self, sim.FIELD_VY, -2) | |
partProperty(self, sim.FIELD_VX, vx + (sfldBlocked(x + dx / 2, y - 1) and 0 or dx / 3)) | |
return | |
end | |
end | |
end) | |
elem.element(BOSE, elem.element(elem.DEFAULT_PT_NBLE)) | |
elem.property(BOSE, "Name", "BOSE") | |
elem.property(BOSE, "Description", "Bose-Einstein condensate. Strange quantum gas, disintegrates with warmth.") | |
elem.property(BOSE, "Color", 0xFF44AA) | |
elem.property(BOSE, "Temperature", 0) | |
elem.property(BOSE, "HotAir", 0.001) | |
elem.property(BOSE, "Diffusion", 4) | |
elem.property(BOSE, "HeatConduct", 0) | |
elem.property(BOSE, "Properties", elem.TYPE_GAS) | |
elem.property(BOSE, "PhotonReflectWavelengths", fullSpectrum) | |
elem.property(BOSE, "LowTemperature", -math.huge) | |
elem.property(BOSE, "HighTemperature", math.huge) | |
elem.property(BOSE, "HighPressure", math.huge) | |
elem.property(BOSE, "LowPressure", -math.huge) | |
elem.property(BOSE, "Create", function (self, x, y, type, v) | |
local angle, speed = random() * pi * 2, random() * 3 | |
partProperty(self, sim.FIELD_VX, cos(angle) * speed) | |
partProperty(self, sim.FIELD_VY, sin(angle) * speed) | |
end) | |
elem.property(BOSE, "Update", function (self, x, y, s, nt) | |
if partProperty(self, sim.FIELD_TEMP) > 10 and random(1, 20) == 1 then | |
partKill(self) | |
return | |
end | |
end) | |
elem.property(BOSE, "Graphics", function (self, r, g, b) | |
return 1, ren.FIRE_ADD, 255, r, g, b, 128, r, g, b | |
end) | |
local condense = { | |
elem.DEFAULT_PT_PROT, | |
elem.DEFAULT_PT_NEUT, | |
elem.DEFAULT_PT_ELEC, | |
elem.DEFAULT_PT_HYGN, | |
elem.DEFAULT_PT_NBLE | |
} | |
elem.element(QGPL, elem.element(elem.DEFAULT_PT_PLSM)) | |
elem.property(QGPL, "Name", "QGPL") | |
elem.property(QGPL, "Description", "Quark-gluon plasma. Extremely hot, generates massive amounts of pressure. Cools into elementary particles.") | |
elem.property(QGPL, "Color", 0xFFAA22) | |
elem.property(QGPL, "Gravity", 0) | |
elem.property(QGPL, "Temperature", 9999) | |
elem.property(QGPL, "HotAir", 0.02) | |
elem.property(QGPL, "Advection", 0.1) | |
elem.property(QGPL, "Diffusion", 1) | |
elem.property(QGPL, "Loss", 0.95) | |
elem.property(QGPL, "Properties", elem.TYPE_GAS) | |
elem.property(QGPL, "HighTemperature", math.huge) | |
elem.property(QGPL, "HighPressure", math.huge) | |
elem.property(QGPL, "LowTemperature", -math.huge) | |
elem.property(QGPL, "LowPressure", -math.huge) | |
elem.property(QGPL, "Create", function (self, x, y, type, v) | |
local angle, speed = random() * pi * 2, 5 | |
partProperty(self, sim.FIELD_VX, cos(angle) * speed) | |
partProperty(self, sim.FIELD_VY, sin(angle) * speed) | |
partProperty(self, sim.FIELD_TMP, random(0, 255)) | |
end) | |
elem.property(QGPL, "Update", function (self, x, y, s, nt) | |
if partProperty(self, sim.FIELD_TEMP) <= 5000 then | |
partCreate(-3, x, y, condense[random(1, #condense)]) | |
partKill(self) | |
return | |
end | |
end) | |
elem.property(QGPL, "Graphics", function (self, r, g, b) | |
g = partProperty(self, sim.FIELD_TMP) | |
b = 0x88 - g / 4 | |
return 0, ren.FIRE_ADD, 255, r, g, b, 255, r, g, b | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment