Last active
January 19, 2024 21:38
-
-
Save rdococ/87039b56a87dd73548572d560179da05 to your computer and use it in GitHub Desktop.
Lua mod for TPT adding several alchemical substances
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
--[[ | |
Alchemistry v7 | |
This mod is all things antiquity. Includes various acids, powders and organic substances using their historical names and believed reactions from the time. Things you can do: | |
- Craft several acids from 'green vitriol' | |
- Boil acids to precipitate dissolved substances | |
- Dissolve gold | |
- Transmute iron to silver, and silver to gold | |
- Manufacture gunpowder | |
- Craft poultices that heal STKM and destroy VIRS | |
- Craft parchment & ink to write your alchemical recipes on (assumes a 1D writing system ;)) | |
v7: | |
- CNBR recovers SLFV as well as MERC | |
- MERC & SULF -> CNBR recipe doubled in yield to match roasting behaviour | |
- Fix conductivity of HRSV | |
- CNBR now sinks under MERC | |
- Descriptions changed | |
v6: | |
- Added CNBR | |
v5: | |
- Fixed SILV photon colouring | |
- Added MIAS, HRSV | |
v4: | |
- SILV partially resists corrosion | |
- Transmutations no longer destroy the acid | |
v3: | |
- Added SULF/SLFV, POLT, SILV | |
- Added a couple metal transmutation recipes | |
- Recipe for GUN | |
- OIVL must now be heated to produce other liquors | |
- Acids can be saturated, and boiled to recover the dissolved material | |
- SLTP now grows PLNT | |
- Include BUBW in water-based reactions | |
- SPRV requires water to condense | |
- Improved VTRL -> OIVL reaction | |
- Corrected OIVL & OVLV temperature thresholds | |
- Other minor changes | |
v2: | |
- Added TNIN, INK, HIDE & PRCH | |
]] | |
local elem, sim = elements, sim | |
local random, floor, min, max = math.random, math.floor, math.min, math.max | |
local function set(tbl, ...) for _, el in ipairs({...}) do tbl[el] = true end end | |
local VTRL, OIVL, OVLV, SPRS, SPRV, SLTP, AQFR, AQFV, TNIN, INK, HIDE, PRCH, SULF, SLFV, POLT, SILV, MIAS, HRSV, CNBR = | |
-- BASED ON: | |
elem.allocate("alchemistry", "vtrl"), -- Green vitriol/iron(II) sulphate (FeSO4) | |
elem.allocate("alchemistry", "oivl"), -- Oil of vitriol/sulphuric acid (H2SO4) | |
elem.allocate("alchemistry", "ovlv"), -- Vapour | |
elem.allocate("alchemistry", "sprs"), -- Spirit of salt/hydrochloric acid (HCl) | |
elem.allocate("alchemistry", "sprv"), -- Vapour | |
elem.allocate("alchemistry", "sltp"), -- Saltpeter/potassium nitrate (KNO3) | |
elem.allocate("alchemistry", "aqfr"), -- Aqua fortis/nitric acid (HNO3) | |
elem.allocate("alchemistry", "aqfv"), -- Vapour | |
elem.allocate("alchemistry", "tnin"), -- Gallic & gallotannic acids | |
elem.allocate("alchemistry", "ink"), -- Iron gall ink | |
elem.allocate("alchemistry", "hide"), -- Animal hide | |
elem.allocate("alchemistry", "prch"), -- Parchment | |
elem.allocate("alchemistry", "sulf"), -- Sulphur | |
elem.allocate("alchemistry", "slfv"), -- Vapour | |
elem.allocate("alchemistry", "polt"), -- Herb + sulphur poultice | |
elem.allocate("alchemistry", "silv"), -- Silver | |
elem.allocate("alchemistry", "mias"), -- Miasma/pathogens | |
elem.allocate("alchemistry", "hrsv"), -- Horn silver/silver chloride | |
elem.allocate("alchemistry", "cnbr") -- Cinnabar/mercury sulfide (HgS) | |
local ironLike, waterLike, wet, stickman, virus, miasmaKiller = {}, {}, {}, {}, {}, {} | |
set(ironLike, elem.DEFAULT_PT_IRON, elem.DEFAULT_PT_METL, elem.DEFAULT_PT_BMTL, elem.DEFAULT_PT_BRMT) | |
set(waterLike, elem.DEFAULT_PT_WATR, elem.DEFAULT_PT_SLTW, elem.DEFAULT_PT_DSTW, elem.DEFAULT_PT_BUBW) | |
set(wet, elem.DEFAULT_PT_WATR, elem.DEFAULT_PT_SLTW, elem.DEFAULT_PT_DSTW, elem.DEFAULT_PT_BUBW, INK) | |
set(stickman, elem.DEFAULT_PT_STKM, elem.DEFAULT_PT_STK2, elem.DEFAULT_PT_FIGH) | |
set(virus, elem.DEFAULT_PT_VIRS, elem.DEFAULT_PT_VRSS, elem.DEFAULT_PT_VRSV) | |
set(miasmaKiller, elem.DEFAULT_PT_PLNT, SULF, POLT, SILV, HRSV) | |
local function precipitate(self, x, y, s, nt) | |
local ctype = sim.partProperty(self, sim.FIELD_CTYPE) | |
if ctype == 0 then return end | |
if random(1, 5) ~= 1 then return end | |
for dx = -1, 1 do | |
for dy = -1, 1 do | |
if not sim.pmap(x + dx, y + dy) then | |
sim.partCreate(-3, x + dx, y + dy, ctype) | |
sim.partProperty(self, sim.FIELD_CTYPE, 0) | |
return | |
end | |
end | |
end | |
end | |
elem.element(VTRL, elem.element(elem.DEFAULT_PT_SALT)) | |
elem.property(VTRL, "Name", "VTRL") | |
elem.property(VTRL, "MenuSection", elem.SC_POWDERS) | |
elem.property(VTRL, "Description", "Iron vitriol. Roast with water to obtain oil of vitriol.") | |
elem.property(VTRL, "Color", 0x00FFAA) | |
elem.property(VTRL, "Hardness", 0) | |
elem.property(VTRL, "Meltable", 0) | |
elem.property(VTRL, "HighTemperature", 573.15) | |
elem.property(VTRL, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_TEMP) > 373.15 and 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 sim.partExists(part) then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
if waterLike[type] or type == elem.DEFAULT_PT_WTRV then | |
sim.partProperty(self, sim.FIELD_TYPE, elem.DEFAULT_PT_BRMT) | |
sim.partProperty(part, sim.FIELD_TYPE, OVLV) | |
return | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.element(OIVL, elem.element(elem.DEFAULT_PT_ACID)) | |
elem.property(OIVL, "Name", "OIVL") | |
elem.property(OIVL, "MenuSection", elem.SC_LIQUIDS) | |
elem.property(OIVL, "Description", "Oil of vitriol. Roast with salt and saltpeter to produce other harsh liquors.") | |
elem.property(OIVL, "Color", 0xFFEE00) | |
elem.property(OIVL, "Hardness", 0) | |
elem.property(OIVL, "Flammable", 0) | |
elem.property(OIVL, "Weight", 45) | |
elem.property(OIVL, "HighTemperature", 337) | |
elem.property(OIVL, "HighTemperatureTransition", OVLV) | |
elem.property(OIVL, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_CTYPE) == 0 and random(1, 6) == 1 then | |
for dx = -2, 2 do | |
for dy = -2, 2 do | |
local part = sim.pmap(x + dx, y + dy) | |
if part and sim.partExists(part) then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
local hardness = elem.property(type, "Hardness") | |
if sim.partProperty(self, sim.FIELD_TEMP) > 320 then | |
if type == elem.DEFAULT_PT_SALT then | |
sim.partKill(part) | |
sim.partProperty(self, sim.FIELD_TYPE, SPRS) | |
return | |
end | |
if type == SLTP then | |
sim.partKill(part) | |
sim.partProperty(self, sim.FIELD_TYPE, AQFR) | |
return | |
end | |
if ironLike[type] then | |
sim.partKill(part) | |
sim.partProperty(self, sim.FIELD_TYPE, VTRL) | |
return | |
end | |
end | |
if not waterLike[type] and random(1, 300) <= hardness then | |
sim.partProperty(self, sim.FIELD_CTYPE, type) | |
sim.partKill(part) | |
end | |
end | |
end | |
end | |
end | |
if random(1, 5000) ~= 1 then return end | |
sim.partProperty(self, sim.FIELD_TYPE, OVLV) | |
end) | |
elem.element(OVLV, elem.element(elem.DEFAULT_PT_SMKE)) | |
elem.property(OVLV, "Name", "OVLV") | |
elem.property(OVLV, "MenuSection", elem.SC_GASES) | |
elem.property(OVLV, "Description", "Vapour emanating from oil of vitriol.") | |
elem.property(OVLV, "Color", 0xFFEE00) | |
elem.property(OVLV, "Hardness", 0) | |
elem.property(OVLV, "Flammable", 0) | |
elem.property(OVLV, "LowTemperature", 300) | |
elem.property(OVLV, "LowTemperatureTransition", OIVL) | |
elem.property(OVLV, "Update", precipitate) | |
elem.element(SPRS, elem.element(elem.DEFAULT_PT_ACID)) | |
elem.property(SPRS, "Name", "SPRS") | |
elem.property(SPRS, "MenuSection", elem.SC_LIQUIDS) | |
elem.property(SPRS, "Description", "Spirit of salt. Highly corrosive liquor. Corrodes weakened gold.") | |
elem.property(SPRS, "Color", 0xFFEEDD) | |
elem.property(SPRS, "Hardness", 0) | |
elem.property(SPRS, "Flammable", 0) | |
elem.property(SPRS, "Weight", 35) | |
elem.property(SPRS, "HighTemperature", 321) | |
elem.property(SPRS, "HighTemperatureTransition", SPRV) | |
elem.property(SPRS, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_CTYPE) ~= 0 then 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 sim.partExists(part) then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
local hardness = elem.property(type, "Hardness") | |
if type == elem.DEFAULT_PT_GOLD and sim.partProperty(part, sim.FIELD_CTYPE) == elem.DEFAULT_PT_PROT or random(1, 100) <= hardness then | |
sim.partProperty(self, sim.FIELD_CTYPE, sim.partProperty(part, sim.FIELD_TYPE)) | |
sim.partKill(part) | |
return | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.element(SPRV, elem.element(elem.DEFAULT_PT_SMKE)) | |
elem.property(SPRV, "Name", "SPRV") | |
elem.property(SPRV, "MenuSection", elem.SC_GASES) | |
elem.property(SPRV, "Description", "Vapour emanating from spirit of salt. Requires WATR to condense.") | |
elem.property(SPRV, "Color", 0xFFEEDD) | |
elem.property(SPRV, "Hardness", 0) | |
elem.property(SPRV, "Flammable", 0) | |
elem.property(SPRV, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_TEMP) <= 300 and 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 sim.partExists(part) then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
local hardness = elem.property(type, "Hardness") | |
if waterLike[part] then | |
sim.partKill(self) | |
sim.partProperty(part, sim.FIELD_TYPE, SPRS) | |
return | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.property(SPRV, "Update", precipitate) | |
elem.element(SLTP, elem.element(elem.DEFAULT_PT_SALT)) | |
elem.property(SLTP, "Name", "SLTP") | |
elem.property(SLTP, "MenuSection", elem.SC_POWDERS) | |
elem.property(SLTP, "Description", "Saltpeter. Fertilizer. Mixes with oil of vitriol under heat.") | |
elem.property(SLTP, "Color", 0xFFFFBB) | |
elem.property(SLTP, "Flammable", 1) | |
elem.property(SLTP, "Update", function (self, x, y, s, nt) | |
if random(1, 5) == 1 then | |
for dx = -1, 1 do | |
for dy = -1, 1 do | |
if random(1, 5) == 1 then | |
local part = sim.pmap(x + dx, y + dy) | |
if part and sim.partExists(part) then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
if type == elem.DEFAULT_PT_PLNT then | |
sim.partProperty(self, sim.FIELD_TYPE, type) | |
return | |
end | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.element(AQFR, elem.element(elem.DEFAULT_PT_ACID)) | |
elem.property(AQFR, "Name", "AQFR") | |
elem.property(AQFR, "MenuSection", elem.SC_LIQUIDS) | |
elem.property(AQFR, "Description", "Aqua fortis. Corrosive liquor derived from saltpeter. Weakens gold. Can be used to transmute metals.") | |
elem.property(AQFR, "Color", 0xEE3322) | |
elem.property(AQFR, "Hardness", 0) | |
elem.property(AQFR, "Flammable", 0) | |
elem.property(AQFR, "Weight", 40) | |
elem.property(AQFR, "HighTemperature", 356) | |
elem.property(AQFR, "HighTemperatureTransition", AQFV) | |
elem.property(AQFR, "Update", function (self, x, y, s, nt) | |
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 sim.partExists(part) then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
local hardness = elem.property(type, "Hardness") | |
if type == elem.DEFAULT_PT_GOLD then | |
sim.partProperty(part, sim.FIELD_CTYPE, elem.DEFAULT_PT_PROT) | |
elseif type == SULF and sim.partProperty(self, sim.FIELD_CTYPE) == SILV then | |
sim.partProperty(self, sim.FIELD_CTYPE, elem.DEFAULT_PT_GOLD) | |
sim.partKill(part) | |
return | |
elseif type == elem.DEFAULT_PT_MERC and sim.partProperty(self, sim.FIELD_CTYPE) == elem.DEFAULT_PT_IRON then | |
sim.partProperty(self, sim.FIELD_CTYPE, SILV) | |
sim.partKill(part) | |
return | |
elseif sim.partProperty(self, sim.FIELD_CTYPE) == 0 and random(1, 300) <= hardness then | |
sim.partProperty(self, sim.FIELD_CTYPE, type) | |
sim.partKill(part) | |
end | |
end | |
end | |
end | |
end | |
if sim.partProperty(self, sim.FIELD_TEMP) < 340 then return end | |
if random(1, 5000) ~= 1 then return end | |
sim.partProperty(self, sim.FIELD_TYPE, AQFV) | |
end) | |
elem.element(AQFV, elem.element(elem.DEFAULT_PT_SMKE)) | |
elem.property(AQFV, "Name", "AQFV") | |
elem.property(AQFV, "MenuSection", elem.SC_GASES) | |
elem.property(AQFV, "Description", "Vapour emanating from aqua fortis.") | |
elem.property(AQFV, "Color", 0xEE3322) | |
elem.property(AQFV, "Hardness", 0) | |
elem.property(AQFV, "Flammable", 0) | |
elem.property(AQFV, "LowTemperature", 340) | |
elem.property(AQFV, "LowTemperatureTransition", AQFR) | |
elem.property(AQFV, "Update", precipitate) | |
elem.element(TNIN, elem.element(elem.DEFAULT_PT_DUST)) | |
elem.property(TNIN, "Name", "TNIN") | |
elem.property(TNIN, "MenuSection", elem.SC_POWDERS) | |
elem.property(TNIN, "Description", "Tannin. Used in the production of ink.") | |
elem.property(TNIN, "Color", 0xBB7733) | |
elem.property(TNIN, "Hardness", 40) | |
elem.property(TNIN, "Flammable", 20) | |
elem.property(TNIN, "Weight", 20) | |
local transitions = {elem.DEFAULT_PT_CO2, elem.DEFAULT_PT_HYGN} | |
elem.property(TNIN, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_TEMP) >= 473.15 then | |
sim.partProperty(self, sim.FIELD_TYPE, transitions[random(1, #transitions)]) | |
return | |
end | |
local vitriol, water | |
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 sim.partExists(part) then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
local hardness = elem.property(type, "Hardness") | |
if type == VTRL then | |
vitriol = part | |
elseif waterLike[type] then | |
water = part | |
end | |
if vitriol and water then | |
sim.partProperty(self, sim.FIELD_TYPE, INK) | |
sim.partKill(vitriol) | |
sim.partKill(water) | |
return | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.element(INK, elem.element(elem.DEFAULT_PT_WATR)) | |
elem.property(INK, "Name", "INK") | |
elem.property(INK, "MenuSection", elem.SC_LIQUIDS) | |
elem.property(INK, "Description", "Ink. Flammable. Seeps into and stains parchment.") | |
elem.property(INK, "Color", 0x4400AA) | |
elem.property(INK, "Hardness", 50) | |
elem.property(INK, "Flammable", 20) | |
elem.property(INK, "Weight", 50) | |
elem.property(INK, "HighTemperature", 473.15) | |
elem.property(INK, "HighTemperatureTransition", OVLV) | |
elem.property(INK, "Update", function (self, x, y, s, nt) | |
if random(1, 2) == 1 then | |
local dx, dy = 0, 1 | |
local part = sim.pmap(x + dx, y + dy) | |
if part and sim.partExists(part) and sim.partProperty(part, sim.FIELD_TYPE) == PRCH then | |
sim.decoBrush(x + dx, y + dy, 0, 0, 0x22, 0x00, 0x77, 0xFF, 0, 0) | |
sim.partKill(self) | |
end | |
end | |
end) | |
elem.element(HIDE, elem.element(elem.DEFAULT_PT_WOOD)) | |
elem.property(HIDE, "Name", "HIDE") | |
elem.property(HIDE, "MenuSection", elem.SC_LIQUIDS) | |
elem.property(HIDE, "Description", "Animal hide. Decays into MIAS, dries into parchment under pressure.") | |
elem.property(HIDE, "Color", 0xFFAA77) | |
elem.property(HIDE, "Properties", elem.property(HIDE, "Properties")) | |
elem.property(HIDE, "Create", function (self, x, y, type, v) | |
sim.partProperty(self, sim.FIELD_LIFE, random(100, 150)) | |
end) | |
elem.property(HIDE, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_LIFE) <= 0 then | |
sim.partProperty(self, sim.FIELD_TYPE, MIAS) | |
return | |
end | |
if sim.partProperty(self, sim.FIELD_TMP2) > 0 then | |
if random(1, 500) == 1 then | |
sim.partProperty(self, sim.FIELD_TMP2, 0) | |
if sim.pressure(x / sim.CELL, y / sim.CELL) > 0.5 then | |
sim.partProperty(self, sim.FIELD_TYPE, PRCH) | |
end | |
end | |
elseif 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 then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
if part and sim.partExists(part) and wet[type] then | |
sim.partProperty(self, sim.FIELD_TMP2, 1) | |
sim.partKill(part) | |
end | |
end | |
end | |
end | |
end | |
if nt > 2 and random(1, 20) == 1 then | |
sim.partProperty(self, sim.FIELD_LIFE, sim.partProperty(self, sim.FIELD_LIFE) - 1) | |
end | |
end) | |
elem.property(HIDE, "Graphics", function (self, r, g, b) | |
if sim.partProperty(self, sim.FIELD_TMP2) > 0 then r, g, b = r * 0.65, g * 0.65, b * 0.75 end | |
if sim.partProperty(self, sim.FIELD_LIFE) <= 50 then r, g, b = r * 0.75, g * 1, b * 0.85 end | |
return 0, ren.PMODE_FLAT, 255, r, g, b, 255, r, g, b | |
end) | |
elem.element(PRCH, elem.element(elem.DEFAULT_PT_WOOD)) | |
elem.property(PRCH, "Name", "PRCH") | |
elem.property(PRCH, "MenuSection", elem.SC_LIQUIDS) | |
elem.property(PRCH, "Description", "Parchment. Can be stained by ink.") | |
elem.property(PRCH, "Color", 0xEEDDCC) | |
sim.can_move(INK, PRCH, 2) | |
elem.element(SULF, elem.element(elem.DEFAULT_PT_SAND)) | |
elem.property(SULF, "Name", "SULF") | |
elem.property(SULF, "MenuSection", elem.SC_POWDERS) | |
elem.property(SULF, "Description", "Sulphur. The very essence of hot and dry, derives 'vitriolic' substances.") | |
elem.property(SULF, "Color", 0xFFCC00) | |
elem.property(SULF, "Hardness", 50) | |
elem.property(SULF, "Flammable", 20) | |
elem.property(SULF, "HighTemperature", 388) | |
elem.property(SULF, "Update", function (self, x, y, s, nt) | |
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 then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
if part and sim.partExists(part) then | |
if type == SLTP then | |
sim.partProperty(self, sim.FIELD_TYPE, elem.DEFAULT_PT_GUN) | |
sim.partKill(part) | |
return | |
elseif type == elem.DEFAULT_PT_PLNT then | |
sim.partProperty(self, sim.FIELD_TYPE, POLT) | |
sim.partProperty(self, sim.FIELD_TMP2, random(0, 90)) | |
sim.partKill(part) | |
return | |
elseif type == elem.DEFAULT_PT_MERC then | |
sim.partProperty(self, sim.FIELD_TYPE, CNBR) | |
sim.partProperty(part, sim.FIELD_TYPE, CNBR) | |
return | |
end | |
end | |
end | |
end | |
end | |
end | |
if sim.partProperty(self, sim.FIELD_TEMP) > 280 and random(1, 20000) == 1 then | |
sim.partProperty(self, sim.FIELD_TYPE, SLFV) | |
end | |
end) | |
elem.element(SLFV, elem.element(elem.DEFAULT_PT_SMKE)) | |
elem.property(SLFV, "Name", "SLFV") | |
elem.property(SLFV, "MenuSection", elem.SC_GASES) | |
elem.property(SLFV, "Description", "Sulphuric vapours.") | |
elem.property(SLFV, "Color", 0xFFCC00) | |
elem.property(SLFV, "Hardness", 50) | |
elem.property(SLFV, "Flammable", 20) | |
elem.property(SLFV, "LowTemperature", 280) | |
elem.property(SLFV, "LowTemperatureTransition", SULF) | |
elem.element(POLT, elem.element(elem.DEFAULT_PT_WOOD)) | |
elem.property(POLT, "Name", "POLT") | |
elem.property(POLT, "MenuSection", elem.SC_SOLIDS) | |
elem.property(POLT, "Description", "Poultice made from herbs and sulphur. Fights VIRS and heals STKM.") | |
elem.property(POLT, "Color", 0x88AA00) | |
elem.property(POLT, "Hardness", 50) | |
elem.property(POLT, "Flammable", 20) | |
elem.property(POLT, "Create", function (self, x, y, type, v) | |
sim.partProperty(self, sim.FIELD_TMP2, random(0, 90)) | |
end) | |
elem.property(POLT, "Update", function (self, x, y, s, nt) | |
if random(1, 5) == 1 then | |
for dx = -1, 1 do | |
for dy = -1, 1 do | |
local part = sim.pmap(x + dx, y + dy) | |
if part then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
if stickman[type] then | |
sim.partProperty(part, sim.FIELD_LIFE, min(sim.partProperty(part, sim.FIELD_LIFE) + 1, 100)) | |
elseif virus[type] then | |
sim.partKill(part) | |
sim.partKill(self) | |
return | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.property(POLT, "Graphics", function (self, r, g, b) | |
local shade = sim.partProperty(self, sim.FIELD_TMP2) - 45 | |
r, g = r + shade, g + shade | |
return 0, ren.PMODE_FLAT, 255, r, g, b, 255, r, g, b | |
end) | |
elem.element(SILV, elem.element(elem.DEFAULT_PT_GOLD)) | |
elem.property(SILV, "Name", "SILV") | |
elem.property(SILV, "MenuSection", elem.SC_SOLIDS) | |
elem.property(SILV, "Description", "Silver, soft metal. Resists corrosion somewhat. Transmutable.") | |
elem.property(SILV, "Color", 0xBBCCDD) | |
elem.property(SILV, "Hardness", 20) | |
elem.property(SILV, "PhotonReflectWavelengths", 0x03FFFFFF) | |
elem.property(SILV, "HighTemperature", 1234) | |
local xChecks = {-6, 6, 0, 0} | |
local yChecks = {0, 0, -6, 6} | |
elem.property(SILV, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_LIFE) == 0 then | |
for i = 1, 4 do | |
local dx, dy = xChecks[i], yChecks[i] | |
if x + dx >= 0 and x + dx < sim.XRES and y + dy >= 0 and y + dy < sim.YRES then | |
local part = sim.pmap(x + dx, y + dy) | |
if part and sim.partProperty(part, sim.FIELD_TYPE) == elem.DEFAULT_PT_SPRK and sim.partProperty(part, sim.FIELD_LIFE) < 4 then | |
sim.partProperty(self, sim.FIELD_TYPE, elem.DEFAULT_PT_SPRK) | |
sim.partProperty(self, sim.FIELD_CTYPE, SILV) | |
sim.partProperty(self, sim.FIELD_LIFE, 4) | |
return | |
end | |
end | |
end | |
end | |
if sim.partProperty(self, sim.FIELD_TEMP) > 373.15 and 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 then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
if type == elem.DEFAULT_PT_SALT or type == elem.DEFAULT_PT_OIL then | |
sim.partProperty(self, sim.FIELD_TYPE, HRSV) | |
return | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.element(HRSV, elem.element(elem.DEFAULT_PT_SAND)) | |
elem.property(HRSV, "Name", "HRSV") | |
elem.property(HRSV, "MenuSection", elem.SC_POWDERS) | |
elem.property(HRSV, "Description", "Horn silver. Derived from SILV, destroys MERC on contact.") | |
elem.property(HRSV, "Color", 0xDDE0EE) | |
elem.property(HRSV, "Hardness", 50) | |
elem.property(HRSV, "HighTemperature", 1234) | |
elem.property(HRSV, "HighTemperatureTransition", SILV) | |
elem.property(HRSV, "Properties", elem.property(HRSV, "Properties") + elem.PROP_LIFE_DEC) | |
elem.property(HRSV, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_LIFE) == 0 then | |
for i = 1, 4 do | |
local dx, dy = xChecks[i], yChecks[i] | |
if x + dx >= 0 and x + dx < sim.XRES and y + dy >= 0 and y + dy < sim.YRES then | |
local part = sim.pmap(x + dx, y + dy) | |
if part and sim.partProperty(part, sim.FIELD_TYPE) == elem.DEFAULT_PT_SPRK and sim.partProperty(part, sim.FIELD_LIFE) < 4 then | |
sim.partProperty(self, sim.FIELD_TYPE, elem.DEFAULT_PT_SPRK) | |
sim.partProperty(self, sim.FIELD_CTYPE, HRSV) | |
sim.partProperty(self, sim.FIELD_LIFE, 4) | |
return | |
end | |
end | |
end | |
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 then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
if type == elem.DEFAULT_PT_MERC then | |
sim.partKill(part) | |
return | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.property(HRSV, "Graphics", function (self, r, g, b) | |
local shade = max(100 - sim.partProperty(self, sim.FIELD_TMP), 15) | |
r, g, b = r * shade / 100, g * shade / 100, b * shade / 100 | |
return 0, ren.PMODE_FLAT, 255, r, g, b, 255, r, g, b | |
end) | |
elem.element(MIAS, elem.element(elem.DEFAULT_PT_OXYG)) | |
elem.property(MIAS, "Name", "MIAS") | |
elem.property(MIAS, "MenuSection", elem.SC_GASES) | |
elem.property(MIAS, "Description", "Miasma. Saps health from STKM, killed by heat and a few elements.") | |
elem.property(MIAS, "Color", 0x88AA44) | |
elem.property(MIAS, "Hardness", 20) | |
elem.property(MIAS, "Flammable", 0) | |
elem.property(MIAS, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_TEMP) >= 373.15 then | |
sim.partKill(self) | |
return | |
end | |
if random(1, 5) == 1 then | |
for dx = -1, 1 do | |
for dy = -1, 1 do | |
local part = sim.pmap(x + dx, y + dy) | |
if part then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
if stickman[type] then | |
sim.partProperty(part, sim.FIELD_LIFE, min(sim.partProperty(part, sim.FIELD_LIFE) - 1, 100)) | |
end | |
if miasmaKiller[type] then | |
sim.partKill(self) | |
return | |
end | |
end | |
end | |
end | |
end | |
end) | |
elem.element(CNBR, elem.element(elem.DEFAULT_PT_SALT)) | |
elem.property(CNBR, "Name", "CNBR") | |
elem.property(CNBR, "MenuSection", elem.SC_POWDERS) | |
elem.property(CNBR, "Description", "Cinnabar. Toxic, sulphuric ore of mercury.") | |
elem.property(CNBR, "Color", 0xDD2200) | |
elem.property(CNBR, "Hardness", 20) | |
elem.property(CNBR, "Weight", 99) | |
elem.property(CNBR, "Update", function (self, x, y, s, nt) | |
if sim.partProperty(self, sim.FIELD_TEMP) >= 373.15 then | |
sim.partProperty(self, sim.FIELD_TYPE, random(0, 1) == 0 and elem.DEFAULT_PT_MERC or SLFV) | |
return | |
end | |
if random(1, 5) == 1 then | |
for dx = -1, 1 do | |
for dy = -1, 1 do | |
local part = sim.pmap(x + dx, y + dy) | |
if part then | |
local type = sim.partProperty(part, sim.FIELD_TYPE) | |
if stickman[type] then | |
sim.partProperty(part, sim.FIELD_LIFE, min(sim.partProperty(part, sim.FIELD_LIFE) - 1, 100)) | |
end | |
end | |
end | |
end | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment