Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name E2IMG
- @inputs DigitalScreen:wirelink
- @outputs DS:wirelink File Res Byte Pixel Num
- @persist Pic:string FileList:array Can
- @trigger
- @trigger DigitalScreen
- if(~DigitalScreen){ reset() }
- if(!DigitalScreen){
- print("Please connect Wire Digital Screen using Wire!")
- }else{
- if(first()){
- function loadFile(Filename:string) {
- fileLoad(Filename)
- }
- DS = DigitalScreen
- runOnChat(1)
- runOnFile(1)
- fileList("e2img/")
- print("Loading imgs list...")
- }
- if (fileListClk()) {
- print("Imgs list loaded!")
- PrintStr=""
- foreach (Key, Value:string=fileReadList()) {
- FileList[Key, string]=Value
- PrintStr+=Key+" > "+Value+"\n"
- }
- print(PrintStr+"\nType !draw <file_index> to begin drawing!")
- }
- if (chatClk()) {
- Command=lastSaid():explode(" ")
- if (Command[1, string]=="!draw") {
- Num=Command[2, string]:toNumber()
- if (FileList[Num, string]) {
- loadFile("e2img/"+FileList[Num, string])
- Can=1
- }
- else {
- print("Chosen file is not exist!")
- }
- }
- elseif (Command[1, string]=="!reload") {
- reset()
- }
- }
- if (Can) {
- if(!File){
- if(fileClk()&&fileLoaded()){
- print("File successfully loaded!")
- Pic = fileRead()
- File = 1
- Res = toByte(Pic,1)
- Byte = 2
- if (Res == 0){
- Res = (toString(toByte(Pic,2))+toString(toByte(Pic,3))+toString(toByte(Pic,4))):toNumber()
- Byte = 5
- }
- Num = 50
- print("Resolution:",Res)
- DS[1048569]=3
- DS[1048572]=Res
- DS[1048573]=Res
- DS[1048575]=1
- Pixel = 0
- runOnTick(1)
- }
- print("Status:",fileStatus())
- }else{
- for(I=1,Num){
- DS[Pixel]=rgb2digi(vec(toByte(Pic,Byte),toByte(Pic,Byte+1),toByte(Pic,Byte+2)),3)
- Pixel++
- Byte = Byte + 3
- }
- if(ops()>8000){
- Num = Num - 1
- }else{
- Num = Num + 1
- }
- if(Pixel>Res^2){ runOnTick(0) Can=0 print("Uploading completed. You can reload file list using !reload")}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement