Posted 23 December 2013 - 02:27 PM
Hello AaP, I've recently been getting some programs I wrote all ready for the lime-light which means adding error checking. Most of my programs rely on an API of common utilities I wrote. I run my own server so I put the tools API into mods/ComputerCraft/lua/rom/shared so the programs always get the most up-to-date version. I realize this won't work with the newer versions of CC which is where my problem arises.
I've put a section at the beginning of my programs to check for the existence of the API in the shared folder. If it is not there, the files are assumed to be on the same computer as the program loading the API. This is the code I use for it:
As far as I can tell this is working as I want it.
The next piece in the puzzle is a program that loads the tools API (successfully), unloads it and then tries to load the termMenu API (unsuccesssfully). I've put some extra prints in to see if I could spot the error but nothing jumps out at me. The real killer is that when I try to load the API from the lua prompt it works fine. Here's the code:
The output is:
I thought it was simply a typo and I was trying to load a file with os.loadAPI that didn't exist, but the file exists (the "true").
Line 393 of bios.lua (in ComputerCraft1.53.zip\lua\) is
Pastebins:
termInterface: http://pastebin.com/jFANs4S9
termMenu: http://pastebin.com/imwqJg9N
Any thoughts? Am I missing something obvious?
I've put a section at the beginning of my programs to check for the existence of the API in the shared folder. If it is not there, the files are assumed to be on the same computer as the program loading the API. This is the code I use for it:
local fileItems = "items.tbl"
local fileTools = "tools"
local filegbMenu = "gbMenu"
local filetermMenu = "termMenu"
local filept = "pt"
local pathShared = "rom/shared/"
if fs.exists(pathShared..fileTools) then --Allows use of global shared directory
filept = pathShared..filept
fileItems = pathShared..fileItems
fileTools = pathShared..fileTools
filegbMenu = pathShared..filegbMenu
filetermMenu = pathShared..filetermMenu
end
As far as I can tell this is working as I want it.
The next piece in the puzzle is a program that loads the tools API (successfully), unloads it and then tries to load the termMenu API (unsuccesssfully). I've put some extra prints in to see if I could spot the error but nothing jumps out at me. The real killer is that when I try to load the API from the lua prompt it works fine. Here's the code:
--[[A few variable declarations and comments up here]]
local fileItems = "items.tbl"
local fileTools = "tools"
local filegbMenu = "gbMenu"
local filetermMenu = "termMenu"
local filept = "pt"
local pathShared = "rom/shared/"
if fs.exists(pathShared..fileTools) then --Allows use of global shared directory
filept = pathShared..filept
fileItems = pathShared..fileItems
fileTools = pathShared..fileTools
filegbMenu = pathShared..filegbMenu
filetermMenu = pathShared..filetermMenu
end
os.loadAPI(fileTools)
local names = tools.names()
tools.network()
local bug = tools.bug(bolDebug)
tools.unload()
--[[A few functions that don't get called yet]]
print("Starting up")
sleep(.2)
print(filetermMenu)
print(fs.exists(filetermMenu))
print(fs.getName(filetermMenu))
--error('d')
os.loadAPI(fileTermMenu)
print(termMenu)
termMenu.new(1,1,_w, _h-1, term)
--[[Rest of the program but it never gets this far]]
The output is:
tools:Loaded
tools:Loading /rom/shared/names.tbl
tools:Rednet started on wireless modem
tools:Returning 'bug'
tools:Unloaded
Starting up
rom/shared/termMenu
true
termMenu
bios:393: Expected string
I thought it was simply a typo and I was trying to load a file with os.loadAPI that didn't exist, but the file exists (the "true").
Line 393 of bios.lua (in ComputerCraft1.53.zip\lua\) is
local sName = fs.getName( _sPath )
which I included in my test cases.Pastebins:
Spoiler
Tools: http://pastebin.com/kkgiV37CtermInterface: http://pastebin.com/jFANs4S9
termMenu: http://pastebin.com/imwqJg9N
Any thoughts? Am I missing something obvious?