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

My code keeps returning a number.. please help

Started by WolfDood, 10 November 2016 - 03:59 AM
WolfDood #1
Posted 10 November 2016 - 04:59 AM
So I was writing some code and I came across an error:

It simply returns a number in red font, don't ask which number its random each time

Here is the code:

local w, h = term.getSize()
local logged_in_wolfplus = nil
local title = "Wolf + 1.0"
local followers_title = "Followers: "
local posts_title = "Posts: "
local function drawDivider(xPos, yPos, divider)
term.setCursorPos(xPos, yPos)
divLine = w - xPos
for i = 1, divLine do
  write(divider)
end
end
local function drawProfile()
drawDivider(1, 1, "-")
term.setCursorPos(1, 2)
-- work on it
end
local function changePassword(path, newPword)
passPath = fs.open(path, "w")
passPath.write("pass = '"..newPword.."'")
passPath.close()
end
local function changeStatus(path, newStatus)
statusPath = fs.open(path, "w")
statusPath.write("status = '"..newStatus.."'")
statusPath.close()
end
local function changeFollowers(path, followers_amount)
cfollowerPath = fs.open(path, "w")
cfollowerPath.write("followers = '"..pword.."'")
cfollowerPath.close()
end
local function addFollowers(path, amount)
followerPath = fs.open(path, "w")
shell.run(path)
new_follower_amount = followers + amount
followerPath.write("followers = '"..new_follower_amount.."'")
end
changeFollowers("ex1", 100)

Hopefully someone can fix this.
Dog #2
Posted 10 November 2016 - 06:06 AM
In your changeFollowers function you define path and followers_amount but you try to reference path and pword. Try changing your write line to this…

cfollowerPath.write("followers = '" .. followers_amount .. "'"
WolfDood #3
Posted 10 November 2016 - 07:06 AM
In your changeFollowers function you define path and followers_amount but you try to reference path and pword. Try changing your write line to this…

cfollowerPath.write("followers = '" .. followers_amount .. "'"

Thank you