Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function rbyte(x,y,z)
- r=0
- if tpt.get_property('type',x,y)==28 then
- if z==0 then
- r=tpt.get_property('life',x,y)%256
- elseif z==1 then
- r=math.floor(tpt.get_property('life',x,y)/256)
- elseif z==2 then
- r=tpt.get_property('vx',x,y)*16+127
- elseif z==3 then
- r=tpt.get_property('vy',x,y)*16+127
- elseif z==4 then
- r=tpt.get_property('temp',x,y)
- elseif z==5 then
- r=tpt.get_property('tmp',x,y)%256
- elseif z==6 then
- r=math.floor(tpt.get_property('tmp',x,y)/256)
- end
- end
- return r
- end
- function setpx(x,y,n,z)
- if z==0 then
- tpt.delete(x,y)
- tpt.create(x,y,'dmnd')
- tpt.set_property('life',n,x,y)
- elseif z==1 then
- tpt.set_property('life',256*n+tpt.get_property('life',x,y),x,y)
- elseif z==2 then
- tpt.set_property('vx',n/16-7.9375,x,y)
- elseif z==3 then
- tpt.set_property('vy',n/16-7.9375,x,y)
- elseif z==4 then
- tpt.set_property('temp',n,x,y)
- elseif z==5 then
- tpt.set_property('tmp',n,x,y)
- elseif z==6 then
- tpt.set_property('tmp',256*n+tpt.get_property('tmp',x,y),x,y)
- end
- end
- function upload(name)
- local f=io.open(name,'rb')
- if f == nil then
- tpt.log(name .. " does not exist.")
- else
- setpx(4,4,165,0)
- setpx(5,4,0,0)
- setpx(6,4,f:seek('end')%256,0)
- setpx(7,4,math.floor(f:seek('end')/256)%256,0)
- setpx(8,4,math.floor(f:seek('end')/65536)%256,0)
- setpx(9,4,math.floor(f:seek('end')/16777216)%256,0)
- for j=1,string.len(name) do
- setpx(9+j,4,string.byte(string.sub(name,j,j)),0)
- end
- f:seek("set",0)
- local n=0
- local bts=f:read(1)
- while not(bts==nil) do
- setpx(4+math.floor(n%4200/7),5+math.floor(n/4200),string.byte(bts),n%7)
- n=n+1
- bts=f:read(1)
- end
- f:close()
- end
- end
- function download()
- if rbyte(4,4,0) == 165 then
- local params=rbyte(5,4,0)
- local name=''
- local fsize=rbyte(6,4,0)+rbyte(7,4,0)*256+rbyte(8,4,0)*65536+rbyte(9,4,0)*16777216
- i=0
- while ((rbyte(10+i,4,0)>31)and(rbyte(10+i,4,0)<128))and(i<73) do
- name=name..string.char(rbyte(10+i,4,0))
- i=i+1
- end
- if name=='' then name='untitled.tpt' end
- f=io.open(name, 'wb')
- i=0
- for i=0,fsize-1 do
- f:write(string.char(rbyte(4+math.floor((i/7))%600,5+math.floor((i/7/600)),i%7)))
- end
- f:close()
- end
- end
- function filedetect()
- if rbyte(4,4,0) == 164 then setpx(4,4,165,0) end
- if rbyte(4,4,0) == 165 then
- tpt.drawrect(10, 187, 55, 12)
- tpt.drawrect(11, 188, 54, 11, 127, 127, 127)
- tpt.fillrect(10, 187, 55, 12, 192, 192, 192)
- tpt.drawtext(17, 190, "Download")
- i=0
- name=""
- while ((rbyte(10+i,4,0)>31)and(rbyte(10+i,4,0)<128))and(i<73) do
- name=name..string.char(rbyte(10+i,4,0))
- i=i+1
- end
- FileLength = rbyte(6,4,0)+rbyte(7,4,0)*256+rbyte(8,4,0)*65536+rbyte(9,4,0)*16777216
- FileSize = "B"
- if FileLength > 999 then FileLength = math.floor((FileLength / 1024) + 0.5) FileSize = "KB" end
- if FileLength > 999 then FileLength = math.floor((FileLength / 1024 * 10) + 0.5)/10 FileSize = "MB" end
- tpt.drawtext(67, 190, "-" .. tostring(FileLength) .. FileSize .. "-" .. name, 0, 127, 127, 255)
- end
- end
- function downmouse(x, y)
- if rbyte(4,4,0) == 165 and x > 9 and x < 56 and y > 187 and y < 200 then
- download()
- end
- end
- tpt.register_step(filedetect)
- tpt.register_mouseclick(downmouse)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement