←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

Good Ol Bios 337 Is Throwing A Untraceable...

uh20's Photo uh20 24 Nov 2013

i absolutely hate it when i get this:
bios:337: [string "airdrop"]:81: '=' expected

my first thoughts was i was passing bad arguments to the script, because text needs to be serialized and unserialized back out, but after testing with raw values, i still get the same error. i even noted getting a different error when giving it wrong values

the thing as a whole is supposed do emergency airdrops on a peripheral glasses user who specifies coords for the drop.
some values are only half in use.

line 81 is the first v=v+1 in startMission(), obviously nothing around there is broken/needing = signs

*plop*
x, y, mode = {...}
rednet.open("right")
--0 is south (3 is sunrise)
print("starting")
face = 0
startPos = {-120,224}
--startHeight is the height of the block its on
startHeight = 63
travelHeight = 128
function calculateTurn(direction)
--the wierd calculation magic and i ran out of ideas for value names
pi = direction - face
--determine two lefts or a 180
if math.abs(pi) == 2 then
  turtle.turnLeft()
  turtle.turnLeft()
  face = face+2
  --determine right turn
  elseif pi == -3 or pi==1 then
  turtle.turnRight()
  face = face+1
  --determine left turn
  elseif pi == -1 or pi==1 then
  turtle.turnLeft()
  face = face+3
end
if face > 3 then
face = face - 4
end
function HudNotice()
message = {}
message[1] = "note"
message[2] = ("beginning airdrop on: " .. x .. " " .. z)
rednet.send(0,textutils.serialize(message))
function greenlight()
fuelInBlocks = turtle.getFuelLevel() + (96*turtle.getItemCount(1))
if (fuelInBlocks - totalDistance)<0 then
  error = {}
  error[1] = "urgent"
  error[2] = "Airdrop Delayed! Out of Fuel"
  rednet.send(0,textutils.serialize(error))
  os.reboot()
end
--check items?
--and we are good to go
end
function determinePath()
--find some directions
if startPos[1]>x then
  firstturn = 3
  elseif startPos[1]>x then
  firstturn = 1
  elseif startPos[1]==x then
  firstturn = face
end
if startPos[2]>z then
  secondturn = 0
  elseif startPos[2]<z then
  secondturn = 2
  elseif startPos[2]==z then
  secondturn = face
end
--distance is in absolute value
distanceX = math.abs(math.abs(x)-math.abs(startPos[1]))
distanceZ = math.abs(math.abs(z)-math.abs(startPos[2]))
totalDistance = distanceX + distanceZ
end
--embedding funtions start here
function startMission()
HudNotice()
determinePath()
greenlight()
--lets head up
distance = 128-startHeight
v = 0
while v<distance do
  turtle.up
  v=v+1
end
--first turn
calculateTurn(firstturn)
--go along x
v = 0
while v<distanceX do
  turtle.forward()
  v = v+1
end
--second turn
calculateTurn(secondturn)
--go along z
v = 0
while v<distanceZ do
  turtle.forward()
  v = v+1
end
--go down
height = 128
while turtle.detectDown == false do
  turtle.down()
  height = height-1
end
--drop some stuff
v = 2
while v<17 do
  turtle.select(v)
  turtle.drop()
end
--wait if told to wait
if mode ~= "leave" then
  print("press enter to let me fly home :D/>/>/>")
  read("*")
end
--go back the freaking up
distance = 128 - height
v=0
while v<distance do
  turtle.up()
  v=v+1
end
--go along z axis
turtle.turnLeft()
turtle.turnLeft()
face = face+2
if face>3 then
  face = face-4
end
v=0
while v<distanceZ do
  turtle.forward()
  v=v+1
end
--turn to x axis
turn = firstturn+2
if turn>3 then
  turn = turn-4
end
caclulateTurn(turn)
--go along x axis
v=0
while v<distanceX do
  turtle.forward()
  v=v+1
end
--go down
distance = 128 - startHeight
v=0
while v<distance and turtle.detectDown()==false do
  turtle.down()
  v=v+1
end
--turn and finish
calculateDistance(0)
end
startMission()

Edited by uh20, 24 November 2013 - 03:10 AM.
Quote

Lyqyd's Photo Lyqyd 24 Nov 2013

Did you read the Common Errors section of the Read This Post Before Asking Questions sticky? The answer to this error is covered in that section.
Quote