Advertisement
Asummonster

E2IMG

Jul 6th, 2019
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. @name E2IMG
  2. @inputs DigitalScreen:wirelink
  3. @outputs DS:wirelink File Res Byte Pixel Num
  4. @persist Pic:string FileList:array Can
  5. @trigger
  6. @trigger DigitalScreen
  7.  
  8. if(~DigitalScreen){ reset() }
  9.  
  10. if(!DigitalScreen){
  11. print("Please connect Wire Digital Screen using Wire!")
  12. }else{
  13. if(first()){
  14. function loadFile(Filename:string) {
  15. fileLoad(Filename)
  16. }
  17. DS = DigitalScreen
  18. runOnChat(1)
  19. runOnFile(1)
  20. fileList("e2img/")
  21. print("Loading imgs list...")
  22. }
  23. if (fileListClk()) {
  24. print("Imgs list loaded!")
  25. PrintStr=""
  26. foreach (Key, Value:string=fileReadList()) {
  27. FileList[Key, string]=Value
  28. PrintStr+=Key+" > "+Value+"\n"
  29. }
  30. print(PrintStr+"\nType !draw <file_index> to begin drawing!")
  31. }
  32. if (chatClk()) {
  33. Command=lastSaid():explode(" ")
  34. if (Command[1, string]=="!draw") {
  35. Num=Command[2, string]:toNumber()
  36. if (FileList[Num, string]) {
  37. loadFile("e2img/"+FileList[Num, string])
  38. Can=1
  39. }
  40. else {
  41. print("Chosen file is not exist!")
  42. }
  43. }
  44. elseif (Command[1, string]=="!reload") {
  45. reset()
  46. }
  47. }
  48. if (Can) {
  49. if(!File){
  50. if(fileClk()&&fileLoaded()){
  51. print("File successfully loaded!")
  52. Pic = fileRead()
  53. File = 1
  54. Res = toByte(Pic,1)
  55. Byte = 2
  56. if (Res == 0){
  57. Res = (toString(toByte(Pic,2))+toString(toByte(Pic,3))+toString(toByte(Pic,4))):toNumber()
  58. Byte = 5
  59. }
  60. Num = 50
  61. print("Resolution:",Res)
  62. DS[1048569]=3
  63. DS[1048572]=Res
  64. DS[1048573]=Res
  65. DS[1048575]=1
  66. Pixel = 0
  67. runOnTick(1)
  68. }
  69.  
  70. print("Status:",fileStatus())
  71. }else{
  72. for(I=1,Num){
  73. DS[Pixel]=rgb2digi(vec(toByte(Pic,Byte),toByte(Pic,Byte+1),toByte(Pic,Byte+2)),3)
  74. Pixel++
  75. Byte = Byte + 3
  76. }
  77. if(ops()>8000){
  78. Num = Num - 1
  79. }else{
  80. Num = Num + 1
  81. }
  82. if(Pixel>Res^2){ runOnTick(0) Can=0 print("Uploading completed. You can reload file list using !reload")}
  83. }
  84.  
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement