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

[LUA] [ERROR] Making a program inside of a program that contains varubles.

Started by Geforce Fan, 01 December 2012 - 10:19 AM
Geforce Fan #1
Posted 01 December 2012 - 11:19 AM
I'm trying to make a save format that is a program itself, but get attempt to consentrate nil and string. It is in a function using the varubles that the function has (ex. function ex(var1, var2, var3)) and it writes in with fs.writeLine all on one line. How do I fix this?


CODE:
--DEVOLPING MODES--
devmode = true
--devmode will skip people talking.
savedev = true
--savedev will auto-save as what you enter opon start.
--DEVMODE CHECKS--
if savedev == true then
print("score level itemnum items name") ;
stuff = read()
failsodoafter = true
end
--FUNCTIONS(yes some of them are inside the code...)




--[[SAVING THE GAME]]--
function save( sscore, slevel, sitemnum, sitems, sname)
--sname is hanging off
--if fs.exists(""..sname.."") == true then
if devmode == false then

return fin
else
saveit = fs.open("testsave", "a")
saveitvar = { "loadingsave = true  score = "..sscore.." level = "..slevel.." itemnum = "..sitemnum.."" }
saveit.writeLine(saveitvar) 
saveit.close()
return fin
end
end

if failsodoafter == true then
save(stuff)
end






Cranium #2
Posted 01 December 2012 - 11:20 AM
It's because you assume that Chuck Norris will play nice with the other variables. In reality, he killed them all.
Geforce Fan #3
Posted 01 December 2012 - 11:21 AM
-.- real help please, that was an example.
PixelToast #4
Posted 01 December 2012 - 11:33 AM
-.- real code please, that was a joke.
Geforce Fan #5
Posted 01 December 2012 - 11:47 AM
I posted the code now. Not the full code, just what's being executed. I am currently just testing this, I do the inputs on the read() thing myself with 1, 1, 1, etc.
PixelToast #6
Posted 01 December 2012 - 11:57 AM
if failsodoafter == true then
save(stuff)
end

needs more args