Ich möchte bitte diesen Text-Code umwandeln :
li
li
li
li
in 4x
robot.turnLeft()
es wird aber nur 3x ausgedruckt.
Woran liegt das bitte?
Danke.
Gruss
Code: Alles auswählen
; se1 = kolben
; se2 = klebekolben
; se3 = slimeblock
; se4 = redstoneblock
Global name_in.s,act.s,act1.s,files.s,text.s
Declare texte()
Enumeration
#window_1
#expl_1
#textg_1
#button_1
#String_1
EndEnumeration
OpenWindow(#window_1, 1300, 5, 280, 320, "text-roboter", #PB_Window_SystemMenu)
TextGadget(#textg_1,10,5,250,20, "Text")
ExplorerListGadget(#expl_1, 10, 25, 260, 220, "d:\minecraft\pebi-rob\*.txt")
SetGadgetAttribute(#expl_1,#PB_Explorer_DisplayMode,#PB_Explorer_List)
StringGadget(#String_1, 10,255, 100, 20, "")
ButtonGadget(#button_1, 10,285, 80, 25, "text-robot")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget() = #expl_1 And EventType() = #PB_EventType_DragStart
Files = ""
For i = 0 To CountGadgetItems(#expl_1)-1
If GetGadgetItemState(#expl_1, i) & #PB_Explorer_Selected
Files + GetGadgetText(#expl_1) + GetGadgetItemText(#expl_1, i) + Chr(10)
EndIf
Next i
DragFiles(Files)
EndIf
If EventGadget() = #expl_1 And EventType() = #PB_EventType_LeftClick
Files = ""
For i = 0 To CountGadgetItems(#expl_1)-1
If GetGadgetItemState(#expl_1, i) & #PB_Explorer_Selected
Files + GetGadgetText(#expl_1) + GetGadgetItemText(#expl_1, i) + Chr(10)
EndIf
Next i
zahl= GetGadgetState(#expl_1)
act=GetGadgetItemText(#expl_1, zahl)
act1=Left(act,Len(act)-4)
SetGadgetText(#String_1, act1)
name_in=act1
EndIf
If EventGadget = #Button_1
texte()
EndIf
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_1
CloseWindow(#Window_1)
Break
EndIf
EndSelect
ReleaseDC_(WindowID(0), *DC)
ForEver
Procedure texte()
If ReadFile(0, "d:\minecraft\pebi-rob\"+name_in+".txt")
CreateFile(1,"d:\minecraft\pebi-rob\"+name_in+"ro"+".txt")
WriteStringN(1,"local component = require("+Chr('"')+"component"+Chr('"')+")")
WriteStringN(1,"local sides = require("+Chr('"')+"sides"+Chr('"')+")")
WriteStringN(1,"local robot = require("+Chr('"')+"robot"+Chr('"')+")")
WriteStringN(1,"")
WriteStringN(1,"os.sleep(2)")
While Eof(0) = 0
text = ReadString(0)
If text="ho"
WriteStringN(1,"robot.up()")
text=""
EndIf
If text="ru"
WriteStringN(1,"robot.down()")
text=""
EndIf
If text="li"
WriteStringN(1,"robot.turnLeft()")
text=""
EndIf
If text="re"
WriteStringN(1,"robot.turnRight()")
text=""
EndIf
If text="vw"
WriteStringN(1,"robot.forward()")
text=""
EndIf
If text="zu"
WriteStringN(1,"robot.back()")
text=""
EndIf
If text="se1"
WriteStringN(1,"robot.select(1)")
WriteStringN(1,"robot.place()")
text=""
EndIf
If text="se2"
WriteStringN(1,"robot.select(2)")
WriteStringN(1,"robot.place()")
text=""
EndIf
If text="se3"
WriteStringN(1,"robot.select(3)")
WriteStringN(1,"robot.place()")
EndIf
If text="se4"
WriteStringN(1,"robot.select(4)")
WriteStringN(1,"robot.place()")
text=""
EndIf
Wend
CloseFile(0)
CloseFile(1)
EndIf
EndProcedure