This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
awesomness1290's profile picture

turtle slots help

Started by awesomness1290, 03 November 2016 - 10:17 PM
awesomness1290 #1
Posted 03 November 2016 - 11:17 PM
I made this to change slots in a turtle:

turtle.select(turtle.getSeletedSlot() + 1)

This changes the slot by 1. The problem is the code doesn't work at slot 16 (there is no slot 17)
I added some stuff and now it doesn't work. Here's the code that doesn't work.

turtle.select(turtle.getSelectedSlot() + 1 if turtle.getSelectedSlot() = 16 then turtle.select(1))

I can't figure out why it doesn't work. I need help please.
KingofGamesYami #2
Posted 03 November 2016 - 11:24 PM
You're using the assignment operator (=) instead of the comparison operator (==). However, the best way would be to use modulus.


turtle.select( turtle.getSelectedSlot() % 16 + 1 )

Modulus is essentially "Remainder when I divide by this number". For example, 8 % 3 would be 2, since 8 / 3 = 6 REMAINDER 2.