11 posts
Posted 30 December 2012 - 07:22 AM
ok i tried to wright a simple code in computercraft… but i get errors… i have never programmed in lua but i have basic experience in c#i also had no idea how to copy the file so this is all hand written
turtle.select(2)
length1 = turtle.getItemCount(2) / 2
length2 = turtle.getItemCount(2) / 2
while length1 ~= 0 and turtle.getFuelLevel() ~= 0 do
turtle.placeDown()
turtle.forward()
length1= length1--
end
turtle.turnRight()
turtle.forward()
while length2 ~= 0 and turtle.getFuelLevel() ~= 0 do
turtle.placeDown()
turtle.forward()
length2 = length2--
end
thats it there is prob more than one error but at the mo it saysbios:338: [string "BuildBridge"]:18: '=' expected that's where i have the length2 = length2–i have also tried length2 = - 1just in case it was the – but still the same error any helpthanks
Edited by
1688 posts
Location
'MURICA
Posted 30 December 2012 - 07:55 AM
There's no – operator in lua. Just use normal subtraction.
length1 = length1 - 1
2088 posts
Location
South Africa
Posted 30 December 2012 - 07:59 AM
To copy the text in the program, open it, select the code, and copy then paste here in [code]Code[/code] tags.
And why are you making length1 = length1 ? Or were you trying to take 1 away from length1 and length2?
11 posts
Posted 30 December 2012 - 08:26 AM
To copy the text in the program, open it, select the code, and copy then paste here in [code]Code[/code] tags.
And why are you making length1 = length1 ? Or were you trying to take 1 away from length1 and length2?
how do you select the code., since you have no mouse control
still get an error even with - 1
i want length1 = length 1 - 1
because i want it to continue forward till it hits 0 then turn and come back making a bridge half the length of the stone you put in but 2 thick
1688 posts
Location
'MURICA
Posted 30 December 2012 - 08:28 AM
He means the actual file where the code is stored. The directory for programs is .minecraft/saves/[your world]/computer/[the computer id]
The computer's ID can be found by typing "id" in the console.
2088 posts
Location
South Africa
Posted 30 December 2012 - 08:33 AM
To copy the text in the program, open it, select the code, and copy then paste here in [code]Code[/code] tags.
And why are you making length1 = length1 ? Or were you trying to take 1 away from length1 and length2?
how do you select the code., since you have no mouse control
still get an error even with - 1
i want length1 = length 1 - 1
because i want it to continue forward till it hits 0 then turn and come back making a bridge half the length of the stone you put in but 2 thick
Oh sorry, forgot about the edit program. Okay then, if you have http api enabled then type, pastebin put file and give us the code that appears (they can be like A53EbdP). If it isn't enabled, find the mods folder in your minecraft folder and open ComputerCraft.cfg and look for "enablehttp" and set it to true. Or do what Kingdaro said. If you're a server, then ask the admin to enable the http api
Change it to be like this:
length1 = length1 - 1
length2 = length2 - 1
11 posts
Posted 30 December 2012 - 10:01 AM
[code]
turtle.select(2)
length1 = turtle.getItemCount(2) / 2
length2 = turtle.getItemCount(2) / 2
while length1 ~= 0 and turtle.getFuelLevel() ~= 0 do
turtle.placeDown()
turtle.forward()
length1 = length1 - 1
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
while length2 ~= 0 and turtle.getFuelLevel() ~= 0 do
turtle.placeDown()
turtle.forward
length2 = length2 - 1
end
[/code]
2088 posts
Location
South Africa
Posted 30 December 2012 - 10:18 AM
Yeah, that should work, but it will only place blocks beneath it if it is empty!
11 posts
Posted 30 December 2012 - 10:42 AM
Yeah, that should work, but it will only place blocks beneath it if it is empty!
no i get bios:338: [string "BuildBridge"]:18; '=' expected
1688 posts
Location
'MURICA
Posted 30 December 2012 - 11:09 AM
turtle.forward
This needs to have parentheses after it. Near the end of the code.
11 posts
Posted 30 December 2012 - 11:24 AM
turtle.forward
This needs to have parentheses after it. Near the end of the code.
lol i spent forever trying to get this to work and it just turns out i forgot ()
0-0
well thanks everyone
11 posts
Posted 30 December 2012 - 11:32 AM
1 more thing how do i export a program to the floppy disk
1688 posts
Location
'MURICA
Posted 30 December 2012 - 12:04 PM
The directory for the disk is "disk/", so if your program name was "foo", you would type this in the command prompt:
copy foo disk/foo
11 posts
Posted 30 December 2012 - 12:15 PM
im making things up as i go… lets say i want a sub/ function… something like
sub CheckFuel
if FuelLevel > 50 then
print "Refueling"()
turtle.refuel(3)
end if
end sub
how would i wright that in lua
1688 posts
Location
'MURICA
Posted 30 December 2012 - 12:29 PM
Assuming the 3 in the turtle.refuel is the third slot:
function CheckFuel()
local FuelLevel = turtle.getFuelLevel()
if FuelLevel < 50 then
print "Refueling"
turtle.select(3)
turtle.refuel(1)
end
end
11 posts
Posted 30 December 2012 - 02:49 PM
how would you upload from the floppy after?
1688 posts
Location
'MURICA
Posted 30 December 2012 - 02:56 PM
The other way around.
copy disk/foo foo
11 posts
Posted 30 December 2012 - 03:26 PM
<p>gosh darn it i destroyed my little elf and i wrote the code again…. but now i get the error bios:338: [string &quot;buildBridge&quot;]:16:
11 posts
Posted 30 December 2012 - 03:27 PM
function CheckFuel()
local FuelLevel = turtle.GetFuelLevel()
if FuelLevel < 50 then
print("Refueling")
turtle.select(1)
turtle.refuel(1)
turtle.select(2)
end
end
length1 = turtle.getItemCount(2)/2
length2 = turtle.getItemCount(2)/2
CheckFuel
while length1 ~= 0 do
turtle.placeDown()
turtle.forward()
length1 = length1 - 1
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.forward()
CheckFuel
while length2 ~= 0 do
turtle.placeDown()
turtle.forward()
length2 = lenght2 - 1
end
turtle.turnRight()
turtle.forward()
turtle.turntRight()
turtle.forward()
11 posts
Posted 30 December 2012 - 03:34 PM
nvm i found it… it was the checkfuel i never put ()