Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --By xXxMoNkEyMaNxXx (Whitemambaa)
- local arg={
- monitor=term,
- speed=8,
- length=1.2,
- }
- local argtypes={
- monitor="peripheral",
- speed="number",
- length="number",
- }
- for parameter,value in table.concat({...}," "):gmatch'%-([%w_]+) ([^ ]+)' do
- local argtype=argtypes[parameter]
- if argtype=="string" then
- arg[parameter]=tostring(value) or arg[parameter]
- elseif argtype=="number" then
- arg[parameter]=tonumber(value) or arg[parameter]
- elseif argtype=="boolean" then
- arg[parameter]=value=="true" or arg[parameter]
- elseif argtype=="peripheral" then
- arg[parameter]=peripheral.wrap(value) or arg[parameter]
- end
- end
- local next=next
- local time=os.time
- local tick=os.clock
- local sqrt=math.sqrt
- local ceil=math.ceil
- local floor=math.floor
- local match=string.match
- local remove=table.remove
- local pull=os.pullEvent
- local setAlarm=os.setAlarm
- local paint=arg.monitor.write
- local setPos=arg.monitor.setCursorPos
- local setBGC=arg.monitor.setBackgroundColour
- local palette={colours.black,colours.grey,colours.lightGrey,colours.white}
- local size={arg.monitor.getSize()}
- local gridsize={1.1,0.7}
- local maxAge=(sqrt(size[1]*size[1]+size[2]*size[2])+arg.length)/arg.speed
- local splashes={}
- local function draw(t)
- local radii={}
- for i=1,#splashes do
- radii[i]=(t-splashes[i].t)*arg.speed
- end
- for x=1,size[1] do
- for y=1,size[2] do
- local prod=1
- for i=1,#splashes do
- local s=splashes[i]
- local dx,dy=(s[1]-x)/gridsize[1],(s[2]-y)/gridsize[2]
- local d=(radii[i]-sqrt(dx*dx+dy*dy))/arg.length
- local dsq=d*d
- if dsq<1 then
- prod=prod*(1-sqrt(1-dsq))
- end
- end
- setPos(x,y)
- if prod<1 then
- setBGC(palette[ceil(#palette*(1-prod))])
- else
- setBGC(32768)
- end
- paint' '
- end
- end
- end
- do
- arg.monitor.clear()
- local message="Click Anywhere!"
- setPos(floor((size[1]-#message)/2),floor(size[2]/2-0.5))
- paint(message)
- end
- local enabled=true
- while enabled do
- local event={pull()}
- local now=tick()
- for i=#splashes,1,-1 do
- if now-splashes[i].t>=maxAge then
- remove(splashes,i)
- end
- end
- if event[1]=="mouse_click" or event[1]=="monitor_touch" then
- if #splashes==0 then
- setAlarm((time()+0.001)%24)
- end
- splashes[#splashes+1]={event[3],event[4],t=now}
- end
- if #splashes>0 then
- draw(now)
- if event[1]=="alarm" then
- setAlarm((time()+0.001)%24)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment