Jump to content




How to load API from / into /rom


  • You cannot reply to this topic
9 replies to this topic

#1 zacekjakub

  • Members
  • 28 posts

Posted 24 July 2014 - 12: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 by zacekjakub, 24 July 2014 - 12:48 AM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 24 July 2014 - 01: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?

#3 zacekjakub

  • Members
  • 28 posts

Posted 24 July 2014 - 01: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. :)

#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 24 July 2014 - 01: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!

#5 zacekjakub

  • Members
  • 28 posts

Posted 24 July 2014 - 03: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. :)

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 24 July 2014 - 03:37 PM

Please post all of the involved code.

What happens if you attempt to run config_file?

#7 zacekjakub

  • Members
  • 28 posts

Posted 24 July 2014 - 03:54 PM

it works well until it is in /rom... I am on a mobile phone, will post code later. :). Thanks

#8 zacekjakub

  • Members
  • 28 posts

Posted 25 July 2014 - 06: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.

#9 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 25 July 2014 - 06:43 AM

"load.api"? Where's that coming from?

$usr? $pass? $db? $msg? What's with the $ signs?

Edited by Bomb Bloke, 25 July 2014 - 06:44 AM.


#10 zacekjakub

  • Members
  • 28 posts

Posted 25 July 2014 - 08: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...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users