Now as I am fully done(hopelyfully D:) I need to get one thing fixed, and it is not about the return, it is the MissionsDone var that is unstable x.x
EDIT: I did it!
It's so retarded that I needed to do it to a numbe... DEEERP... r, I needed to add a... Derp?... tonumber() function to convert it from a... derp -.-... string to number :/
This has been troubling me for aslong as I've been doing this code(apr. one day o.O)
Now I need maps, alot of em' guys/girls!
I'll make a guide soon, just gotta test if all the functions work properly

EDIT 2:
Arghhh, need help with the loadmap function, it won't work :/
function LoadMap(ID)
if io.open(BasicSaveFolder .. "\\Adventure\\Maps\\" .. MapNames[ID] .. ".map", "r") then
assert(io.input(io.open(BasicSaveFolder .. "\\Adventure\\Maps\\" .. MapNames[ID] .. ".map", "r")))
local activation = nil
local activationlast = 0
local gettingvalue = false
local customvalue = {}
local latestid = nil
for line in io.lines() do
if activation ~= nil then
if activation == "Open" then
OpeningText = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "Win" then
WinMessage = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "Lost" then
LostMessage = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "WinType" then
Win = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "AI" then
AIType = line
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "Time" then
MapTime = tonumber(line)
activationlast = activationlast - 1
if activationlast == 0 then
activation = nil
end
elseif activation == "createroid" then
if activationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local x = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local x = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local y = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local y = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
end
if activationlast == 0 then
AddAsteroid(x,y)
activation = nil
end
elseif activation == "createroidatt" then
if activationlast == 5 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local x = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local x = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 4 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local y = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local y = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 3 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local e = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local e = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local st = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local st = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local sp = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local sp = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
end
if activationlast == 0 then
AddAsteroidWithAttribs(x,y,e,st,sp)
activation = nil
end
elseif activation == "createroidatt" then
if activationlast == 4 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local x = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local x = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 3 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local y = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local y = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local num = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local num = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local size = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local size = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
end
if activationlast == 0 then
for i = 1,num do
AddAsteroid(x+math.random(-size,size),y+math.random(-size,size))
end
activation = nil
end
elseif activation == "createvalue" then
if activationlast == 2 then
local id = tonumber(line)
elseif activationlast == 1 then
local val = tonumber(line)
end
activationlast = activationlast - 1
if activationlast == 0 then
customvalue[id] = val
latestid = id
activation = nil
end
elseif activation == "changeid" then
activationlast = activationlast - 1
if activationlast == 0 then
latestid = tonumber(line)
activation = nil
end
elseif activation == "createsfx" then
if activationlast == 17 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local x = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local x = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 16 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local y = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local y = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 15 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local r = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local r = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 14 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local g = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local g = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 13 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local b = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local b = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 12 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local a = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local a = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 11 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local size = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local size = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 10 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local rd = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local rd = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 9 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local gd = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local gd = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 8 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local bd = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local bd = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 7 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local ad = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local ad = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 6 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local sized = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local sized = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 5 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local rcs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local rcs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 4 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local gcs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local gcs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 3 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local bcs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local bcs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local acs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local acs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local scs = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local scs = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
end
if activationlast == 0 then
CreateSFX(x,y,r,g,b,a,size,rd,gd,bd,ad,sized,rcs,gcs,bcs,acs,scs)
activation = nil
end
elseif activation == "change" then
if activationlast == 3 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local id = tonumber(line)
activationlast = activationlast - 1
else
gettingvalue = true
end
else
local id = customvalue[tonumber(line)]
gettingvalue = false
activationlast = activationlast - 1
end
elseif activationlast == 2 then
local what = tostring(line)
activationlast = activationlast - 1
elseif activationlast == 1 then
local changeto = line
activationlast = activationlast - 1
end
if activationlast == 0 then
if what == "owner" then
GetAsteroid(id).Owner = changeto
elseif what == "treecap" then
GetAsteroid(id).TreeCap = changeto
elseif what == "addseedlings" then
GetAsteroid(id):AddSeedlings(changeto)
elseif what == "addsuperseedlings" then
GetAsteroid(id):AddSuperSeedlings(changeto)
elseif what == "adddysontree" then
GetAsteroid(id):AddDysonTree()
elseif what == "adddefensetree" then
GetAsteroid(id):AddDefenseTree()
elseif what == "moving" then
GetAsteroid(id).Moveable = changeto
end
activation = nil
end
end
if subactivation == "add" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid] + val
subactivation = nil
end
elseif subactivation == "minus" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid] - val
subactivation = nil
end
elseif subactivation == "times" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid] * val
subactivation = nil
end
elseif subactivation == "divide" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid] / val
subactivation = nil
end
elseif subactivation == "expo" then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[latestid] = customvalue[latestid]^val
subactivation = nil
end
elseif subactivation == "random" then
if actionlast == 3 then
local id = tostring(line)
elseif subactivationlast == 2 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val1 = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val1 = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
elseif subactivationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val2 = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val2 = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[id] = math.random(val1,val2)
latestid = id
subactivation = nil
end
elseif subactivation == "sin" then
if actionlast == 2 then
local id = tostring(line)
elseif subactivationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val1 = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val1 = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[id] = math.sin(val1)
latestid = id
subactivation = nil
end
elseif subactivation == "cos" then
if actionlast == 2 then
local id = tostring(line)
elseif subactivationlast == 1 then
if gettingvalue ~= true then
if line ~= "getvalue" then
local val1 = tonumber(line)
subactivationlast = subactivationlast - 1
else
gettingvalue = true
end
else
local val1 = customvalue[tonumber(line)]
gettingvalue = false
subactivationlast = subactivationlast - 1
end
end
subactivationlast = subactivationlast - 1
if subactivationlast == 0 then
customvalue[id] = math.cos(val1)
latestid = id
subactivation = nil
end
end
else
if line == "Open" then
activation = line
activationlast = 1
elseif line == "Win" then
activation = line
activationlast = 1
elseif line == "Lost" then
activation = line
activationlast = 1
elseif line == "WinType" then
activation = line
activationlast = 1
elseif line == "AI" then
activation = line
activationlast = 1
elseif line == "Time" then
activation = line
activationlast = 1
elseif line == "createroid" then
activation = line
activationlast = 2
elseif line == "createroidatt" then
activation = line
activationlast = 5
elseif line == "createvalue" then
activation = line
activationlast = 2
elseif line == "add" or line == "minus" or line == "divide" or line == "times" or line == "expo" then
subactivation = line
subactivationlast = 1
elseif line == "random" then
subactivation = line
subactivationlast = 3
elseif line == "sin" or line == "cos" then
subactivation = line
subactivationlast = 2
elseif line == "changeid" then
activation = line
activationlast = 1
elseif line == "createfield" then
activation = line
activationlast = 4
elseif line == "createsfx" then
activation = line
activationlast = 17
elseif line == "change" then
activation = line
activationlast = 3
end
end
end
end
endThe error I get, comes particularilry from the createvalue activation

It is the customvalue[id] = val that causes it :/