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

[Solved] Vars In Api Are Not Beeing Loaded ?!

Started by mark332, 24 August 2013 - 03:34 AM
mark332 #1
Posted 24 August 2013 - 05:34 AM
Hey Guys, I just wanted a simple Configuration File with variables in it,

but I don't want to read it and assign a variable to each line/value, so I tried using os.loadAPI("myFile") on my File, but It only includes 1 of 3 variables defined in my file…


The File, which is beeing loaded via. os.loadAPI("settings")

language= 1 ,
IHTMLvNumber = "0.1",
languages={"German","English n/a"}
textutils.serialize(settings) returns

{["HTMLvNumber = "0.1""]}

Any1 has an Idea why this happens, or how to fix this ?

Greetings ;)/>

mark332
PixelToast #2
Posted 24 August 2013 - 06:15 AM
it would actually return {["HTMLvNumber"] = "0.1"]}
but anyway
i actually tried this and i got a syntax error from the ,s
but all the variables are in there when i remove them
mark332 #3
Posted 24 August 2013 - 08:12 AM
?

Excuse me, if I don't understand everything…. I'm german at first. :D/>
GopherAtl #4
Posted 24 August 2013 - 11:46 AM
Like this instead

language= 1
IHTMLvNumber = "0.1"
languages={"German","English n/a"}

The ","s at the ends were invalid syntax.
mark332 #5
Posted 24 August 2013 - 01:26 PM
Well, if I do this:


language= 1
IHTMLvNumber = "0.1"
languages={"German","English n/a"}
and load it with os.loadAPI("settings")

textutils.serialize(settings) returns

{["HTMLvNumber = "0.1",}

I'm near at thinking "CC ist trolling me, right?" :huh:/>
GopherAtl #6
Posted 24 August 2013 - 01:32 PM



works fine. If it's not working for you, then you're doing something else, not explained in this thread, that is breaking it.

Full, actual code, please.
mark332 #7
Posted 24 August 2013 - 01:42 PM
There's no full, actual code, I just type "lua" and then "os.loadAPI("BeTECH/USERDATA/bt-settings/settings")" (<– Full Path to the File) and then, just this happenes :(/>
Lyqyd #8
Posted 24 August 2013 - 02:13 PM
As you can clearly see, what you've said is happening doesn't make sense. The same thing you claim to be doing is working for Gopher the way you intend this to work. You must be doing something wrong on your end. Please verify that you've copied the code from the settings file correctly and that you aren't reloading another version of the settings file that does not contain all of the information or some similar problem.
mark332 #9
Posted 24 August 2013 - 02:20 PM
well, I'll poste the File…

here:
http://hastebin.com/gogudukudi.ini


I also could make a recording, if you don't belive that… D:
mark332 #10
Posted 24 August 2013 - 02:37 PM
The thing is, If I type: "edit BeTECH/USERDATA/bt-settings/settings" im the main shell it shows me

language= 1
IHTMLvNumber = "0.1"
languages={"German","English n/a"}

:/
mark332 #11
Posted 24 August 2013 - 03:00 PM
Well, now it works IF I load it up manually via. lua,

but: If I use this code, the Problem is still there:


{Code has been removed!}

Tell me, if you need the values of the functions/vars, then, I'll Post them at HasteBin
Lyqyd #12
Posted 24 August 2013 - 03:56 PM
We need all of the code in order to help.
GopherAtl #13
Posted 24 August 2013 - 03:56 PM
Full, actual code, please.

That is clearly not all of the code. It defines a function, startup, which is not being called, and it calls a function, MainMenu, which is not defined.
mark332 #14
Posted 24 August 2013 - 04:01 PM
The Function MainMenu doesn't Matter, 'cause I've terminated the Programm, before the MainMenu could be called… but
here is my "gen" API:
http://hastebin.com/vajeruwada.lua


And, like the name of the Function sais, "startup()" is the first executed thing of my program ;)/>
Lyqyd #15
Posted 24 August 2013 - 04:06 PM
You do realize we're trying to figure out why you think your settings aren't being loaded correctly, right? I still haven't seen anything that even references the settings at all. How do you expect us to help if you won't give us all of the code that's involved here?
mark332 #16
Posted 24 August 2013 - 04:58 PM
Well, okay, I'll Post a Link of a .zip, which includes the three relevant files…
mark332 #17
Posted 24 August 2013 - 05:01 PM
http://www.mediafire.com/download/b6yemn08kg2y9pv/Neuer_Ordner.zip

To run it, enter "BeTECH/OS"
GopherAtl #18
Posted 24 August 2013 - 06:07 PM
The only thing I see referencing settings after it is loaded is the cat_config function in the OS file, which tries to access settings.tVars.language and settings.tVars.language, which shouldn't exist, as there is no tVars table declared in the settings file.
mark332 #19
Posted 25 August 2013 - 09:24 AM
The only thing I see referencing settings after it is loaded is the cat_config function in the OS file, which tries to access settings.tVars.language and settings.tVars.language, which shouldn't exist, as there is no tVars table declared in the settings file.

oh, thanks, but my problem is not in the program "OS" itself, it's, if I've runned the program, terminated it and trying to access settings.<notIHTMLvNumber>.
textutils.serialize always returns {["IHTMLvNumber = "0.1",} on settings….
It just looks like, "hey, I'm Lua, let's ignore 2 of 3 lines…" -.-
mark332 #20
Posted 25 August 2013 - 02:40 PM
Nevermind, found my Mistake in Line 1:

settings = { IHTMLvNumber = "0.1"}
xDD