Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --drill for digging
- --don't use more than one particle at a time
- local drill = elem.allocate("BAUER", "DRLL")
- elem.element(elem.BAUER_PT_DRLL, elem.element(elem.DEFAULT_PT_PHOT))
- elem.property(elem.BAUER_PT_DRLL, "Name", "DRLL")
- elem.property(elem.BAUER_PT_DRLL, "MenuVisible", 1)
- elem.property(elem.BAUER_PT_DRLL, "Colour", 0x524734)
- elem.property(elem.BAUER_PT_DRLL, "MenuSection", elem.SC_SPECIAL)
- elem.property(elem.BAUER_PT_DRLL, "Description", "Drills through things, only use one at a time")
- elem.property(elem.BAUER_PT_DRLL, "Temperature", 273.15)
- local drillup = false
- local drilldown = false
- local drillright = false
- local drillleft = false
- local active = true
- local vnum = 1
- local pdir = ""
- local hud = 1
- function control(key,dkey,_,event)
- if dkey == 273 then --up arrow
- drillup = true
- drilldown = false
- drillright = false
- drillleft = false
- active = true
- end
- if dkey == 274 then --down arrow
- drillup = false
- drilldown = true
- drillright = false
- drillleft = false
- active = true
- end
- if dkey == 276 then --right arrow
- drillup = false
- drilldown = false
- drillright = true
- drillleft = false
- active = true
- end
- if dkey == 275 then --left arrow
- drillup = false
- drilldown = false
- drillright = false
- drillleft = true
- active = true
- end
- if event==1 then
- if key == "j" then
- vnum=vnum+0.1
- end
- if key == "m" then
- vnum=vnum-0.1
- end
- if key == "h" and hud==1 then
- tpt.unregister_step(status)
- hud=0
- else
- if key == "h" and hud==0 then
- tpt.register_step(status)
- hud=1
- end
- end
- end
- end
- function contr(i,x,y,s,n)
- for r in sim.neighbors(x,y,2,2) do
- if sim.partProperty(r, "type") ~= nil and sim.partProperty(r, "type") ~= elem.BAUER_PT_DRLL then
- sim.partChangeType(r, elem.DEFAULT_PT_BRCK)
- end
- end
- --this first part turns surrounding particles into brick so the tunnel doesn't collapse
- if active==true then
- if drillup==true then
- local du = sim.partID(x, y - 1)
- if du == nil then
- tpt.create(x, y - 1, 'drll')
- sim.partKill(i)
- elseif du ~= nil then
- sim.partProperty(du, "type", "drll")
- --sim.partKill(i)
- end
- pdir = "up"
- active = false
- end
- if drilldown==true then
- local dd = sim.partID(x, y + 1)
- if dd == nil then
- tpt.create(x, y + 1, 'drll')
- sim.partKill(i)
- elseif dd ~= nil then
- sim.partProperty(dd, "type", "drll")
- --sim.partKill(i)
- end
- pdir = "down"
- active = false
- end
- if drillright==true then
- local dr = sim.partID(x - 1, y)
- if dr == nil then
- tpt.create(x - 1, y, 'drll')
- sim.partKill(i)
- elseif dr ~= nil then
- sim.partProperty(dr, "type", "drll")
- --sim.partKill(i)
- end
- pdir = "left"
- active = false
- end
- if drillleft==true then
- local dl = sim.partID(x + 1, y)
- if dl == nil then
- tpt.create(x + 1, y, 'drll')
- sim.partKill(i)
- elseif dl ~= nil then
- sim.partProperty(dl, "type", "drll")
- --sim.partKill(i)
- end
- pdir = "right"
- active = false
- end
- end
- end
- --kills surrounding particles and replaces with itself
- tpt.element_func(contr,elem.BAUER_PT_DRLL)
- tpt.register_keypress(control)
- --Key control function y MrSalit0s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement