Sure pharap!
This is still very much in the 'wtf am i doing' stage.
Also are their any online/downloadable applications to check if it will complie/work? without having to put it into the game?
Lua is also my first coding languge outside html/css and so far im loving this commmunity!
Scare.
Well, if you're html/css, that certainly explains why you'd have a bit of an issue getting your head around things.
You see, html and css are declarative languages - they describe how to arrange things
languages like lua, visualbasic, c#, c++ are all imperative programming languages. - they perform processes.
Every language is useful and has a place, but some are very different to others.
I don't know of any online validators (I'm assuming you've used an html validator before?), and tbh, with or without IDEs (integrated development environments, fancy code editors/managers) programming is still mostly writing code, it's not very easy to escape from.
I have a few tips I could give you and I could run you through some basic concepts by message if you wish to do so, but for now I will just attempt to improve your program, here's an edit with comments marked by – (in html/css, I think you have something like // to make a line that won't be read by the program, not sure, it's been a while since I've done webdev. In lua, – does the same thing)
x = 0
y = 0
tf = true
print("place x value (how far ahead of turtle?)")
x = io.read() --note: read does work on its own, you do not need io
print ("Place y value (how far to the side?) ")
y = io.read()
value = 0
value = x * y
--read as variable = data to assign, not data to assign = variable.
--Also, ^ means powers of, * is multiplication, which is what you want for area of a rectangle
if value > 576 then
print("This is too big for the turtle.") --minor typo
total = 0
else
a = turtle.getItemCount(1)
b = turtle.getItemCount(2)
c = turtle.getItemCount(3)
d = turtle.getItemCount(4)
e = turtle.getItemCount(5)
f = turtle.getItemCount(6)
g = turtle.getItemCount(7)
h = turtle.getItemCount(8)
i = turtle.getItemCount(9)
total = a + b + c + d + e + f + g + h + i
-- variables are local, after end, the letters will no longer exit
--total will remain because it was declared beforehand
end
if value > total then
print("You dont have enough blocks")
else
tf = true
--tf had not been set, it makes most sense here, what is it supposed to do?
while y > 0 do
while x > 0 then
turtle.digDown()
turtle.placeDown()
turtle.forward()
z = z - 1
-- ideally a for loop would be better here, but I will just correct your while for now
end
if tf = true then
turtle.turnRight()
turtle.forward()
turtle.turnRight()
tf = false
else
turtle.turnLeft()
turtle.forward()
turle.turnLeft()
tf = true
end
y = y - 1
end
end
print("Task Complete!")
It's not brilliant, but I made a few alterations to your code to improve it. It's a bit hard to read/understand, but I can make out what you were thinking and you did well to manage the nested while loop. Nested loops are always handy for processing coords.
If you want me to run through a more fully optimised version with you or some of the basic commands, feel free to note me.
For now, however, I just leave you with this edited script. I can't see why it wouldn't run now, but feel free to bring it back if it doesn't run, there is a chance I've screwed up somewhere. After all, programming is one thing, reading someone else's code is a whole other story.