DW20 modpack. re:[S5;ep38]AutoBreeding Bees. Turtle lua - problem

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

C04L

New Member
Jul 29, 2019
47
0
0
Hello all, I have to write here because writing a question on DW's youtube page is nigh on impossible for DW to see it.

This is regarding the turtle programe to auto pickup and analyze then choose the best bees via a point system and then insert the selected bees into the Apiary.

I'm using the latest DW20-pack via latest ftb client.
I'm using the pastebin [Dubw1FxC analyze] this is the one he uploaded at the end of the episode.

I copied the layout he has done: chest/inventry turtle/analyzer/bee analyzer and the apiary.

I let the bees do their thing first and then type into the turtle autorun.

It grabs the bees and starts to analyze them then i get this....

Analyze:71: attemp to perform arithmetic __add on nil and nil
sleeping....
Analyze:41: attempt to index ? (a nil value)
sleeping....
[or]
sleeping for a minute while the bee scans
turtle:18: Slot number 0 out of range sleeping...

alalyze:41:/turtle:18: continues to loop thereafter forever

I dont understand why it works for some people and not others?!
Is DW using a different version compared to the latest version of his own pack?

Any help regarding the errors im getting would be tremendously appreaciated

Thanks..
 

C04L

New Member
Jul 29, 2019
47
0
0
does anyone have any lua experience? please if you do, explain in laymans terms what its saying it cant do please, at least then i know what the problem is.

thanks
 

TLOU15

New Member
Jul 29, 2019
21
0
0
I have no clue about Lua but what kind of bees are you running through the turtle? if the turtle has no assigned number for the type the bees are then it will have no way to add the genes together because it will have nothing to add... at least that is what I am getting from that nil error you posted. With extra bees and thaumic bees tossed in you may be getting different mutations then what it is set up for.
 

C04L

New Member
Jul 29, 2019
47
0
0
im relatively new to bees. just dabled.
im putting in basic meadows princess and forest drone.
when the apiary has done its thing i type autorun (so the whole automation starts).

to save time i will paste the lua
local currslot = 1
local princess = 0
local bestDrone = 0
local data=""
local countBees = 0
local beeTable = {}
local currScore = 0

s = peripheral.wrap("right")

function regTable()
beeTable["bees.species.industrious"] = 31
beeTable["bees.species.imperial"] = 30
beeTable["bees.species.unweary"] = 21
beeTable["bees.species.majestic"] = 20
beeTable["bees.species.diligent"] = 11
beeTable["bees.species.noble"] = 10
beeTable["bees.species.cultivated"] = 6
beeTable["bees.species.common"] = 5
beeTable["bees.species.forest"] = 1
beeTable["bees.species.meadows"] = 1
end

function getBees()
turtle.select(1)
for i = 1,6 do
if turtle.suck() then countBees = countBees + 1 end
end
end

function returnBees()
turtle.turnRight()
turtle.turnRight()
turtle.select(princess)
s.dropSneaky(1,1)
turtle.select(bestDrone)
s.dropSneaky(0,1)
end

function ditchCombs()
turtle.turnLeft()
m = peripheral.wrap("front")
for i = 1,8 do
turtle.suck()
while (not m.isBee()) and (turtle.getItemCount(i) > 0) do
turtle.select(i)
turtle.drop()
if not m.isBee() then
print("Gotta ditch the combs!")
turtle.suck()
turtle.dropDown()
turtle.select(countBees)
turtle.transferTo(i, 1)
countBees = countBees - 1
end
end
end
end

function scanBees()
turtle.turnLeft()
for i = 1, countBees do
turtle.select(i)
turtle.drop()
end
print("Sleeping for a minute while the bee scans")
sleep(26)
end

function determineBest(slot)
score = beeTable[data["speciesPrimary"]] + beeTable[data["speciesSecondary"]]
print("Current: "..currScore)
print("NewScore: "..score)
if(bestDrone == 0) then
bestDrone = slot
currScore = score
else
if (score > currScore) then
bestDrone = slot
currScore = score
end
end
end

function analyzeBees()
for i = 1, countBees do
turtle.select(i)
s.suckSneaky(0,1)
turtle.turnRight()
turtle.drop()
m = peripheral.wrap("front")
data = m.analyze()
if (data["type"] == "princess") then
princess = i
print("Princess = "..i)
else
determineBest(i)
end
print(data["speciesPrimary"]..":"..data["speciesSecondary"])
print("BestDrone = "..bestDrone)
turtle.suck()
turtle.turnLeft()
if i ~= countBees then sleep(26) end
end
end


function dropExcess()
for i = 1, 6 do
turtle.select(i)
turtle.dropDown()
end
end
------=============================

currslot = 1
princess = 0
bestDrone = 0
data=""

countBees = 0
beeTable = {}
currScore = 0

regTable()
getBees()
if (turtle.getItemCount(2) > 0) then
ditchCombs()
scanBees()
analyzeBees()
returnBees()
dropExcess()
end

the lua does have a typical layout (TABS for easy reading) but it doesn't show on this copy/paste
 

Mikeyhun

New Member
Jul 29, 2019
7
0
0
Hi there!
I had the same problem so i searched his thread at minecraftforums and someone corrected his code!
Here's the code: http://pastebin.com/qRWXqvJu (this isn't my work)
Sometimes i still have some issue with it like slot 0 out of reach and such but overall it works better
Hope it helps.
 
  • Like
Reactions: Zachary Slater

Zachary Slater

New Member
Jul 29, 2019
4
0
0
Thanks! There are some issues still but overall it's working a lot better. If anyone can produce a flawless code that would still be much appreciated :)
 

Mikeyhun

New Member
Jul 29, 2019
7
0
0
Well i know lua programming and will try to correct it after the holidays ends here. If you could paste your errors/notices here that would be great for me. The error "can't __add nil" or something is caused by unspecified bee types i think but will look into it when i have time.
 
  • Like
Reactions: Zachary Slater

Zachary Slater

New Member
Jul 29, 2019
4
0
0
Analyze:71: attemp to perform arithmetic __add on nil and nil
sleeping....
Analyze:41: attempt to index ? (a nil value)
sleeping....
sleeping for a minute while the bee scans
turtle:18: Slot number 0 out of range sleeping...
These are the three errors I've been getting at this point.
 

Viaki

New Member
Jul 29, 2019
3
0
0
I still have an error with the new version of the code
Here is the error : ''(programName):71: attemp to perform arithmetic __add on nil and nil ''
 

Viaki

New Member
Jul 29, 2019
3
0
0
Okay well after i posted my last message i looked into it and updated the code!
Here's the code http://pastebin.com/mQSh1shG
I tested it twice but there might be more bugs so report them here if you find one and i will correct it.

Hope this helps! :D

Fixed the code.
The identification of the species changed.
http://pastebin.com/FV4pBiDp
it is working just fine now.

Also, anyone know a way I could repeat the code over and over until a certain point ?
 

archangel374

New Member
Jul 29, 2019
1
0
0
im using the latest update of the program and have the following problem:
101: attempt to index ? (a boolean value).
please help i have no idea what is wrong
 

iarspider

New Member
Jul 29, 2019
65
0
0
Since I don't know which version is the latest, I'll try to give a generic explanation.
Line 101 of code has something like this:
Code:
someVariable.someField

or maybe
Code:
someVariable.someMethod()

This will be valid from LUA's point of view only if someVariable is a "table", while in your case someVariable is a boolean ("True" or "False").
Anyway, that code is highly unstable - I've seen it leave bees in Analyzer or drop "good" bees into "junk" check way too often.