My cousin and I have been experimenting with his new Photon chip, and we decided to be creative and use ComputerCraft (the Minecraft mod) and some Lua code to drive the car he made. Unfortunately, every time we give an input, it indexes a nil value; we're not sure if it is because the http.post code is wrong or something we don't know about... Any ideas?
URL = "https://api.particle.io/v1/devices/456456456456/updateMotors("
token = "access_token=123456789"
robotState = 0
while true do
os.pullEvent("redstone")
if((redstone.getInput("bottom") == true) and (robotState ~= 0)) then
robotState = 0
returnData = http.post(URL .. "\"0\"" .. ")", token)
returnData.close()
.....
end
end
(the rest of the code looks identical to that hence the ellipsis)
We're trying to pass the string to a Photon function that will drive the motors, but every time we create a redstone signal it says "Drive:11: attempt to index ? (a nil value)" - but only when the Photon is connected.