so my script has multiple keys you cold press to change different things such as ctype, tmp etc. but after adding(into the script not in-game) my third key the whole script stops working how can I fix this problem.
Also I would like to make one of my elements to always have the ctype of acmn , how can I do that.
Ok but the script is not done but its about nano-tech it uses some elements from the exotic chemistry but modfied+ this is my third day with lua(yes I am a beginner) here it is:
*Note: defense form rises and attack form sinks
local element1 = elements.allocate("MOD", "MOLD")
elements.element(elements.MOD_PT_MOLD, elements.element(elements.DEFAULT_PT_CAUS))
elements.property(elements.MOD_PT_MOLD, "Name", "Mold")
elements.property(elements.MOD_PT_MOLD, "Description", "Matter Eating Space Mold")
elements.property(elements.MOD_PT_MOLD, "Colour", 0xA1AAA1)
elements.property(elements.MOD_PT_MOLD, "MenuSection", 10)
elements.property(elements.MOD_PT_MOLD, "Gravity", 0.0)
elements.property(elements.MOD_PT_MOLD, "Loss", 0.0)
elements.property(elements.MOD_PT_MOLD, "AirLoss", 0.0)
elements.property(elements.MOD_PT_MOLD, "AirDrag", 0.0)
elements.property(elements.MOD_PT_MOLD, "Advection", 0.0)
elements.property(elements.MOD_PT_MOLD, "Weight", 0.1)
elements.property(elements.MOD_PT_MOLD, "Flammable", 0)
elements.property(elements.MOD_PT_MOLD, "Diffusion", 0.1)
elements.property(elements.MOD_PT_MOLD, "Properties", PROP_LIFE_DEC)
elements.property(elements.MOD_PT_MOLD, "Properties", PROP_LIFE_KILL_DEC)
function mold_tick(i, x, y, s, n)
local rand = math.random(1, 200)
if rand == 1 then
tpt.set_property("type", elements.MOD_PT_MOLD, x+1, y+1)
tpt.set_property("type", elements.MOD_PT_MOLD, x-1, y+1)
tpt.set_property("type", elements.MOD_PT_MOLD, x, y+1)
tpt.set_property("type", elements.MOD_PT_MOLD, x+1, y-1)
tpt.set_property("type", elements.MOD_PT_MOLD, x-1, y-1)
tpt.set_property("type", elements.MOD_PT_MOLD, x, y-1)
tpt.set_property("type", elements.MOD_PT_MOLD, x+1, y)
tpt.set_property("type", elements.MOD_PT_MOLD, x-1, y)
local rand2 = math.random(1, 100)
if rand2 == 1 then
tpt.set_property("tmp", 1, x+1, y+1)
tpt.set_property("tmp", 1, x-1, y+1)
tpt.set_property("tmp", 1, x, y+1)
tpt.set_property("tmp", 1, x+1, y-1)
tpt.set_property("tmp", 1, x-1, y-1)
tpt.set_property("tmp", 1, x, y-1)
tpt.set_property("tmp", 1, x+1, y)
tpt.set_property("tmp", 1, x-1, y)
tpt.set_property("vx", 1, x+1, y+1)
tpt.set_property("vx", -1, x-1, y+1)
tpt.set_property("vx", 0, x, y+1)
tpt.set_property("vx", 1, x+1, y-1)
tpt.set_property("vx", -1, x-1, y-1)
tpt.set_property("vx", 0, x, y-1)
tpt.set_property("vx", 1, x+1, y)
tpt.set_property("vx", -1, x-1, y)
tpt.set_property("vy", 1, x+1, y+1)
tpt.set_property("vy", 1, x-1, y+1)
tpt.set_property("vy", 1, x, y+1)
tpt.set_property("vy", -1, x+1, y-1)
tpt.set_property("vy", -1, x-1, y-1)
tpt.set_property("vy", -1, x, y-1)
tpt.set_property("vy", 0, x+1, y)
tpt.set_property("vy", 0, x-1, y)
elseif rand2 > 5 then
tpt.set_property("type", elements.MOD_PT_MOLD, math.random(1, 10), math.random(1, 20))
end
if tpt.get_property("tmp", x, y) == 0 then
tpt.set_property("type", 0, x, y)
else
local rand = math.random(1, 1)
if rand == 1 then
tpt.set_property("type", 0, x, y)
end
end
end
end
tpt.element_func(mold_tick, elements.MOD_PT_MOLD)
tpt.el.metl.name = "SSTL"
tpt.el.metl.description = " Made from Modified mechinzed coal and iron.Stainless Steel, uncorrosive and conductive."
tpt.el.metl.hardness = -1
tpt.el.metl.menusection = 9
tpt.el.metl.color=0xA1AAA1
tpt.el.metl.weight = 102.0
local element1 = elements.allocate("FEYNMAN", "BPDR")
elements.element(elements.FEYNMAN_PT_BPDR, elements.element(elements.DEFAULT_PT_BCOL))
elements.property(elements.FEYNMAN_PT_BPDR, "Name", "BPDR")
elements.property(elements.FEYNMAN_PT_BPDR, "Description", "Black Powder. Very explosive.")
elements.property(elements.FEYNMAN_PT_BPDR, "Colour", 0x353535)
elements.property(elements.FEYNMAN_PT_BPDR, "MenuSection", 5)
elements.property(elements.FEYNMAN_PT_BPDR, "Gravity", .5)
elements.property(elements.FEYNMAN_PT_BPDR, "Flammable", 10000)
elements.property(elements.FEYNMAN_PT_BPDR, "Explosive", 1)
elements.property(elements.FEYNMAN_PT_BPDR, "Loss", 1)
elements.property(elements.FEYNMAN_PT_BPDR, "AirLoss", .5)
elements.property(elements.FEYNMAN_PT_BPDR, "AirDrag", .01)
elements.property(elements.FEYNMAN_PT_BPDR, "Advection", .01)
elements.property(elements.FEYNMAN_PT_BPDR, "Weight", 0)
elements.property(elements.FEYNMAN_PT_BPDR, "Diffusion", 0)
local element1 = elements.allocate("FEYNMAN", "REXP")
elements.element(elements.FEYNMAN_PT_REXP, elements.element(elements.DEFAULT_PT_BCOL))
elements.property(elements.FEYNMAN_PT_REXP, "Name", "REXP")
elements.property(elements.FEYNMAN_PT_REXP, "Description", "More realistic explosive. It explodes by burning rather than exploding and with lots of heat.")
elements.property(elements.FEYNMAN_PT_REXP, "Colour", 0xFF5000)
elements.property(elements.FEYNMAN_PT_REXP, "MenuSection", 5)
elements.property(elements.FEYNMAN_PT_REXP, "Gravity", 0)
elements.property(elements.FEYNMAN_PT_REXP, "Flammable", 10000)
elements.property(elements.FEYNMAN_PT_REXP, "Explosive", 1)
elements.property(elements.FEYNMAN_PT_REXP, "Loss", 0)
elements.property(elements.FEYNMAN_PT_REXP, "AirLoss", 0)
elements.property(elements.FEYNMAN_PT_REXP, "AirDrag", .0)
elements.property(elements.FEYNMAN_PT_REXP, "Advection", 0)
elements.property(elements.FEYNMAN_PT_REXP, "Diffusion", 0)
tpt.el.dust.name = 'Ndst'
tpt.el.dust.description="Nanite dust, full of malfuncioning nanites. they generate massive internal gravitational field making this extremely heavy. very reactive with solids, very good stkm propellant "
tpt.el.dust.diffusion =1000
tpt.el.dust.gravity = 1000
tpt.el.dust.flammable = 0
tpt.el.dust.color = 0xFFDBDBE1
tpt.el.dust.weight = 1000
tpt.el.coal.name = 'Mmcl'
tpt.el.coal.description= "Modified mechanized coal, dangerous if pressurized too quickly."
tpt.el.brel.name = 'ACmn'
tpt.el.brel.menusection = 8
tpt.el.brel.heat=9000
tpt.el.brel.advection = 0.3
tpt.el.brel.hardness = -1
tpt.el.brel.loss = 0.7
tpt.el.brel.airdrag = 0.0
tpt.el.brel.description= "Attack mode Carbonfiber Nanites, very conductive and active.Press C to deactivate, Press X to activate."
tpt.el.brel.color = 0xA1AAA1
tpt.el.brel.weight = 10
tpt.el.brel.gravity = 1
tpt.el.brel.hotair = 0.0
tpt.el.brel.diffusion = 5
tpt.el.brel.color = 0xB7B7A9
tpt.eltransition.brel.tempHighValue = 9720
tpt.eltransition.brel.tempHighType = tpt.element('dmnd')
local element1 = elements.allocate("Dcn", "DCMN")
elements.element(elements.DCN_PT_DCMN, elements.element(elements.DEFAULT_PT_BREL))
elements.property(elements.DCN_PT_DCMN, "Name", "DCMN")
elements.property(elements.DCN_PT_DCMN, "Description", "Carbonfiber Nanites, very conductive and active.Press C to deactivate mode, Press X to activate.")
elements.property(elements.DCN_PT_DCMN, "Colour", 0xB7B7A9)
elements.property(elements.DCN_PT_DCMN, "MenuSection", 8)
elements.property(elements.DCN_PT_DCMN, "Gravity", -1)
elements.property(elements.DCN_PT_DCMN, "Loss", 0.7)
elements.property(elements.DCN_PT_DCMN, "AirDrag", 0.0)
elements.property(elements.DCN_PT_DCMN, "Advection", 0.3)
elements.property(elements.DCN_PT_DCMN, "Weight", 10)
elements.property(elements.DCN_PT_DCMN, "Diffusion", 5)
local elTemporaryValue = tpt.eltransition.coal.presHighValue
local elTemporaryType = tpt.eltransition.coal.presHighType
tpt.eltransition.coal.presLowValue = -200
tpt.eltransition.coal.presLowType = tpt.element("acmn")
tpt.eltransition.coal.presHighValue = 75
tpt.eltransition.coal.presHighType = tpt.element("bcol")
tpt.eltransition.bcol.presHighValue = 115
tpt.eltransition.bcol.presHighType = tpt.element("acmn")
local elTemporaryValue = tpt.eltransition.metl.presHighValue
local elTemporaryType = tpt.eltransition.metl.presHighType
tpt.eltransition.metl.presHighValue = 65
tpt.eltransition.metl.presHighType = tpt.element("acmn")
local elTemporaryValue = tpt.eltransition.dust.presHighValue
local elTemporaryType = tpt.eltransition.dust.presHighType
tpt.eltransition.dust.presHighValue = 25
tpt.eltransition.dust.presHighType = tpt.element("acmn")
local elTemporaryValue = tpt.eltransition.brel.presHighValue
local elTemporaryType = tpt.eltransition.brel.presHighType
tpt.eltransition.brel.presHighValue = 150
tpt.eltransition.brel.presHighType = tpt.element("dmnd")
function cool(key,blank,blank,event)
if string.upper(key) == "C" and event == 1 then
tpt.set_property("type","hygn","uran")
tpt.set_property("type","sstl","dcmn")
tpt.set_property("type","mold","acmn")
end
end
tpt.register_keypress(cool)
function heat(key,blank,blank,event)
if string.upper(key) == "X" and event == 1 then
tpt.set_property("type","dcmn","mold")
tpt.set_property("type","hygn","neut")
tpt.set_property("type","acmn","sstl")
tpt.set_property("type","acmn","lava")
end
end
tpt.register_keypress(heat)
function solidify(key,blank,blank,event)
if string.upper(key) == "v" and event == 1 then
tpt.set_property("type","acmn","dcmn")
end
end
tpt.register_keypress(solidify)
function nano(key,blank,blank,event)
if string.upper(key) == "o" and event == 1 then
tpt.set_property("type","acmn","dcmn")
end
end
tpt.register_keypress(nano)
has anyone considered helping me?
@ramoman (View Post)
Number one basically means that you don't need to string.upper() every time, just use a lower case letter, like this:
if key == 'v' and event == 1 then -- ...
fantastic Idea ramoman! +1