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

suck lava

Started by siv, 28 December 2016 - 01:16 PM
siv #1
Posted 28 December 2016 - 02:16 PM
hi iam new in cc and my englisch is realy bad

i want to lern my turtle suck lava and add it to an excavating program

function=LSAUG()

turtle.dedect(Lava)
turtle.suck()
refuel()
getfuelstatus()
end




is this right ?
KingofGamesYami #2
Posted 28 December 2016 - 02:37 PM
Turtles cannot suck lava. The turtle.suck() function is for intaking dropped items or items from chests.

What turtles can do with lava is pick it up in a bucket (using turtle.place), then refuel from that.


local bucket_slot = 1
local function lsaug()
  local oldslot = turtle.select( bucket_slot )
  turtle.place()
  turtle.refuel()
  turtle.select( oldslot )
end
siv #3
Posted 28 December 2016 - 02:49 PM
ok thank you for the fast help :)/>

but can u tell me what the "local" thing is ?
KingofGamesYami #4
Posted 28 December 2016 - 03:19 PM
local variables are better practice than globals. The performance difference for most cases is negligible, but it is good to avoid cluttering _G.
siv #5
Posted 28 December 2016 - 03:29 PM
local means only at this point do things ?
KingofGamesYami #6
Posted 28 December 2016 - 03:54 PM
The differences between

local a = 1

and

a = 1

are as follows:

* The local variable will be accessed faster
* The local variable cannot be accessed by other programs
* The local variable does not clutter the global table (_G)
* The local variable cannot be accessed via _G
* The local variable cannot be accessed outside its scope (If you place it inside a conditional statement or loop, it won't work outside of that)

The similarities include:
* Exact same value
* Exact same syntax to access
* Exact same syntax to change

While local variables are not necessary for the vast majority of applications, they are good practice.
siv #7
Posted 28 December 2016 - 04:09 PM
Wow You are super :D/>
Thx now i understand
Edited on 28 December 2016 - 04:09 PM
KingofGamesYami #8
Posted 28 December 2016 - 04:50 PM
Thanks!

While this is a primarily english speaking forum, you only have to provide an english translation. If you also include your primary language (appears to be German / Deutsch), there may be members who speak that language who can provide explanations or translations in that language.

My primary language is English, but I know some German.