Posted 19 April 2014 - 09:28 AM
                Greetings
I am new to LUA and rather inexperienced at programming in general. But since I did not find a suitable crafting program for my crafing turtle I had to try and make one myself.
Here is the code:
For some reason I do not understand I get the message: bios:337:[string "f"]:11:'do' expected, where f is the name of the program as downloaded. Pastebin link here: http://pastebin.com/g0mKGuz8
Where do I fault in the programming? i am sry the comments are in swedish, but since the code itself is breaf and hopefully self explanatory, I hope it is ok.
Best regards
Roland
                
            I am new to LUA and rather inexperienced at programming in general. But since I did not find a suitable crafting program for my crafing turtle I had to try and make one myself.
Here is the code:
   
slotTable = {1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 2} --Tabell för vilka slots som skall ha innehåll och inte. Slutar när den kommer till slot 12 och får siffran 2
function fill()
local i = 1
    while slottable[i] ~= 2 do        
        if turtle.suckDown() == True then --så länge det finns material i kistan
                for i = 1, slotTable[i] = 2, 1 do -- Så länge som variabeln slotTable[tabellposition] skiljer sig från sluta så görs detta. Efter varje gång läggs ett till på i
                    if slotTable = 1 then --Om slotTable är 1
                        turtle.getSelectedSlot(i) --get slot
                            while turtle.getItemCount <64 do --så länge det är mindre än 64 st i sloten
                            turtle.suckDown --hämta material från kistan
                            end    --slut på for-satsen
                    else
                    i = i + 1 --Om slotTable skiljer sig från 1, lägg till ett på i
                    end
                end
        else
        print ("Material saknas!!")
        slottable =2
        end
function make()
    --kolla om det finns material i alla slots där det skall vara material
    for i = 1, slotTable = 2, i = i + 1 do
        if slotTable[i] = 1 then
            turtle.select(i)
                if turtle.getItemCount ~= 64 do --om itemCount skiljer sig från 64
                fill()
                end
        else
        i = i + 1
        end
    end
            
    
    while turtle.dropUp = true do --om det finns plats i kistan
        turtle.select(16) --välj slot 16
                
            if turtle.getItemCount(16) == 0 then --Om det inte finns något i sloten
                turtle.craft() --tillverka sakerna
                turtle.dropUp() --lägg sakerna i kistan
                print ("Tillverkade en stack")
            else
                if turtle.dropUp ~= false then --så läge som det går att lägga saker i kistan
                    turtle.dropUp() --om det fanns saker i slot 16 och det finns plats i kistan, töm sakerna till den
                    turtle.craft() --tillverka sakerna
                    turtle.dropUp() --lägg sakerna i kistan
                    print ("Tillverkade en stack")
                else
        
                print ("Målkista är full!!!!")
                
                end --slut på if-satsen
            end    --slut på if-satsen
            
                    
            
    end    --slut på while-satsen
        
    print ("Målkistan är full!")        
end --slut på funktionen
function wait()
    
    local x = 1
    while turtle.suckDown == false do
        print ("Väntar på material....." x )
    x = x + 1
    end
end
--Huvudprogrammet, typ
a = read() --ta in text från commandoraden
while a ~= "stop" do --så länge ingen skriver stop
    if turtle.dropUp == true && turtle.suckDown == true do
    fill()    
    make()
    
    else
    wait()
end
For some reason I do not understand I get the message: bios:337:[string "f"]:11:'do' expected, where f is the name of the program as downloaded. Pastebin link here: http://pastebin.com/g0mKGuz8
Where do I fault in the programming? i am sry the comments are in swedish, but since the code itself is breaf and hopefully self explanatory, I hope it is ok.
Best regards
Roland
 
         
                 
                