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

How to load API from / into /rom

Started by zacekjakub, 23 July 2014 - 11:47 PM
zacekjakub #1
Posted 24 July 2014 - 01:47 AM
Hello,

I asked in other thread and nobody answered, so I am trying new one. :)/> I have my own API saved in /rom and the functions are working until I want to make it configurable via config file in root of computer, can you tell me the path I should use to load config from root directory into function in /rom? I tried to use os.loadAPI("/config_file"), but it just has broken my computer. :)/> I need users to configure advanced functions from public API saved in rom.

Thank you very much!

Jakub
Edited on 23 July 2014 - 11:48 PM
Bomb Bloke #2
Posted 24 July 2014 - 02:20 AM
So "config_file" is just another API, yeah? In that case, it seems what you're doing should work (even if just "os.loadAPI("config_file")" should suffice); if that's causing problems, then what are those problems? What's in the API file?
zacekjakub #3
Posted 24 July 2014 - 02:17 PM
There are saved just some variables, it is standard config file. If i try this, the fomputer gets black screen and is unable to reboot, I have to destroy it and place it again to get new id. :)/>
Bomb Bloke #4
Posted 24 July 2014 - 02:23 PM
The custom APIs you've added to ROM - are they placed such that they load automatically when a computer boots, or do you have to load them manually? I'm thinking one or more of them is breaking something important. Make sure none of your API names coincide with a default function name!
zacekjakub #5
Posted 24 July 2014 - 04:03 PM
it is in api "log" and function name is "set". So i just call log.set("db"," user","pass") and it is working until i use before function load.api("config_file")
with defined variables. Strange, I know. :)/>
Lyqyd #6
Posted 24 July 2014 - 04:37 PM
Please post all of the involved code.

What happens if you attempt to run config_file?
zacekjakub #7
Posted 24 July 2014 - 04:54 PM
it works well until it is in /rom… I am on a mobile phone, will post code later. :)/>. Thanks
zacekjakub #8
Posted 25 July 2014 - 07:36 AM
/rom/log:
function set(msg)
load.api("config_file")
http.get("http://minecraft.kumpacka.cz/minecraft/service/update.php?usr="..$usr.."&pass="..$pass.."&db="..$db.."&msg="..$msg)
end

/config_file (on local computer):
usr="user"
pass="pass"
db="db"

If i restart the computer with this in rom, computer doesn't start until i remove it from rom, destroy the computer and place it again to get new id.
Bomb Bloke #9
Posted 25 July 2014 - 07:43 AM
"load.api"? Where's that coming from?

$usr? $pass? $db? $msg? What's with the $ signs?
Edited on 25 July 2014 - 05:44 AM
zacekjakub #10
Posted 25 July 2014 - 09:16 AM
Sry, I don't know how it got there, I have os.loadAPI in the code like told before of course. :)/>
Maybe the "$" in the code are the problem, I am just pretty busy, working on many projects together and "$" are used in bash and other languages to define variable, so I used them, maybe it was the fail, will try today… :(/> Thank you and sorry for so lame problem, could not find that after I tried to fix the problem so long…