View difference between Paste ID: tt0pFMuA and f9DGDaT3
SHOW: | | - or go back to the newest paste.
1
file="bild"
2-
r=peripheral.wrap("right")
2+
p=peripheral.wrap("front")
3-
r.link()
3+
4
chars={}
5
slot[" "]=12
6
slot["0"]=1
7
slot["1"]=2
8
slot["2"]=3
9
slot["3"]=4
10
slot["4"]=5
11
slot["5"]=6
12
slot["6"]=7
13
slot["7"]=8
14
slot["8"]=9
15
slot["9"]=10
16
slot["a"]=11
17
slot["b"]=12
18
slot["c"]=13
19
slot["d"]=14
20
slot["e"]=15
21
slot["f"]=16
22
currentColor={"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}
23
function getCharCount(str,char)
24
charnum=0
25
for i=1, #str do
26
if string.sub(str,i,i)==char then
27
charnum=charnum+1
28
end
29
end
30
return(charnum)
31
end
32
33
function fileToTable(file)
34
if fs.exists(file)~=true then
35
print("file"..file.." not found")
36
return(false)
37
end
38
fp=fs.open(file,"r")
39
line={}
40
i=1
41
line[i]=fp.readLine()
42
if line[i]==nil then return(false) end
43
while line[i]~=nil do
44
i=i+1
45
line[i]=fp.readLine()
46
end
47
return(line)
48
end
49
50
img=fileToTable(file)
51
52
i=1
53
i2=1
54
i3=1
55
while img[i]~=nil do
56
for i2=1, #img[i] do
57
chars[i3]=string.sub(img[1],i2,i2)
58
i3=i3+1
59
end
60
i=i+1
61
end
62
63
onechar=""
64
for i=1, #img do
65
onechar=onechar..img[i]
66
end
67
term.clear()
68
term.setCursorPos(1,1)
69
term.write("Slot1 weiß: "..tostring(getCharCount(onechar,"0")))term.setCursorPos(1,2)
70
term.write("Slot2 orange: "..tostring(getCharCount(onechar,"1")))term.setCursorPos(1,3)
71
term.write("Slot3 magenta: "..tostring(getCharCount(onechar,"2")))term.setCursorPos(1,4)
72
term.write("Slot4 hellblau: "..tostring(getCharCount(onechar,"3")))term.setCursorPos(1,5)
73
term.write("Slot5 gelb: "..tostring(getCharCount(onechar,"4")))term.setCursorPos(1,6)
74
term.write("Slot6 hellgrün: "..tostring(getCharCount(onechar,"5")))term.setCursorPos(1,7)
75
term.write("Slot7 pink: "..tostring(getCharCount(onechar,"6")))term.setCursorPos(1,8)
76
term.write("Slot8 grau: "..tostring(getCharCount(onechar,"7")))term.setCursorPos(21,1)
77
term.write("Slot9 hellgrau: "..tostring(getCharCount(onechar,"8")))term.setCursorPos(21,2)
78
term.write("Slot10 cyan: "..tostring(getCharCount(onechar,"9")))term.setCursorPos(21,3)
79
term.write("Slot11 lila: "..tostring(getCharCount(onechar,"a")))term.setCursorPos(21,4)
80
term.write("Slot12 blau: "..tostring(getCharCount(onechar," ")+getCharCount(onechar,"b")))term.setCursorPos(21,5)
81
term.write("Slot13 braun: "..tostring(getCharCount(onechar,"c")))term.setCursorPos(21,6)
82
term.write("Slot14 grün: "..tostring(getCharCount(onechar,"d")))term.setCursorPos(21,7)
83
term.write("Slot15 rot: "..tostring(getCharCount(onechar,"e")))term.setCursorPos(21,8)
84
term.write("Slot16 schwarz: "..tostring(getCharCount(onechar,"f")))term.setCursorPos(1,9)
85
86
87
print("Höhe: "..tostring(#img))
88
print("Breite: "..tostring(#img[1]))
89
e,key=os.pullEvent("key")
90
while key~=28 do
91
e,key=os.pullEvent("key")
92
end
93
94
95-
for i=1, #chars do
95+
96-
turtle.select(slot[string.sub(onechar,i,i)])
96+
97-
if turtle.getItemCount(slot[string.sub(onechar,i,i)])>1 then
97+
for i=2, 16 do
98
turtle.select(i)
99-
else
99+
100-
if r.resupply(slot[string.sub(onechar,i,i)])==false then term.write("Bitte Material nachfüllen und Taste drücken") 
100+
p.newPage()
101
102
for yPos=1, #img do
103
for xPos=1, #img[1] do
104
105
if string.sub(img[yPos],xPos,xPos)==currentColor[i] then
106
p.setCursorPos(xPos,yPos)
107
p.write("#")
108
end
109
110
end
111
xPos=1
112
yPos=yPos+1
113
end
114
p.endPage()
115
turtle.select(1)
116
turtle.suckUp()
117
turtle.dropDown()
118
end