Page 1 sur 1

How do I use myLib?

Message non luPosté: 23 Juil 2022, 00:37
de chalex0
I want to use myLib for the purposes of recalling strings or tables, as a separately updateable package to my main program. I have looked at some programs that use it but I'm too silly to understand what is going on, could somebody point me towards myLib lua references/documentation or provide a brief explanation on how to achieve this? Thanks :)

Re: How do I use myLib?

Message non luPosté: 23 Juil 2022, 00:39
de Adriweb
Here's an example : https://github.com/adriweb/EEPro-for-Ns ... tabase.lua :)
The called Basic functions must in this case return lua code, since it's executed with loadstring.

Re: How do I use myLib?

Message non luPosté: 23 Juil 2022, 00:54
de chalex0
Adriweb a écrit:Here's an example : https://github.com/adriweb/EEPro-for-Ns ... tabase.lua :)
The called Basic functions must in this case return lua code, since it's executed with loadstring.

I had seen this before but sadly I didn't get how to implement it myself :(

Re: How do I use myLib?

Message non luPosté: 23 Juil 2022, 14:02
de Adriweb
What exactly are you stuck on?
You can download the .tns and look at the Basic part, too.

Re: How do I use myLib?

Message non luPosté: 24 Juil 2022, 23:34
de chalex0
Adriweb a écrit:What exactly are you stuck on?
You can download the .tns and look at the Basic part, too.

Hi, I've progressed my understanding that now I know I can store and recall within just Lua, as this is what Minecraft 2D uses; it appears to be different but I am no expert.

For example, to retrieve content it uses this:
var.recall("test\\content")

I am, however stuck on how to actually embed/store this information within the tns file. I have tried var.store("test","x") but this for some reason cannot be recognised as being a library thing. I'm also unable to remove anything by setting it to nil. I've included the file I have been playing with, it uses the database from mc2d as a base, and the pre existing var "content" is recognised while "test" does not. This probably stems from unfamiliarity with storing variables in general :/

Re: How do I use myLib?

Message non luPosté: 26 Juil 2022, 11:45
de Adriweb
You can't use the "foo\\bar" syntax for var.recall/store, that gives nil, and the error message "cannot recall variable test\content". Indeed this API is just for storing/retrieving variables from the same document. While foo\bar is the syntax for retrieving the bar public variable in a MyLib document called foo.
I don't know what Minecraft2D uses, but in the case of FormulaPro, what I did is create a public basic function that returns lua code, so that I can math.eval it (with the backslash syntax) and then execute the code.

Re: How do I use myLib?

Message non luPosté: 26 Juil 2022, 15:10
de chalex0
Adriweb a écrit:You can't use the "foo\\bar" syntax for var.recall/store, that gives nil, and the error message "cannot recall variable test\content". Indeed this API is just for storing/retrieving variables from the same document. While foo\bar is the syntax for retrieving the bar public variable in a MyLib document called foo.
I don't know what Minecraft2D uses, but in the case of FormulaPro, what I did is create a public basic function that returns lua code, so that I can math.eval it (with the backslash syntax) and then execute the code.

Thanks for this advice, I know what caused the issue before, and I hate to admit that I hadn't refreshed the libraries when trying your implementation :sob: now it all makes so much more sense

ps. I wanted to also mention inspired lua is down :p

Re: How do I use myLib?

Message non luPosté: 26 Juil 2022, 15:43
de Adriweb
Oh yeah refreshing the libs is needed... :P

And yeah, Inspired-Lua has been taken down temporarily while we try to fix what seems to be a WordPress issue. I'll check (again...) if there's a way for me to just make it static, no more Wordpress :p

Re: How do I use myLib?

Message non luPosté: 26 Juil 2022, 23:19
de chalex0
Adriweb a écrit:Oh yeah refreshing the libs is needed... :P

And yeah, Inspired-Lua has been taken down temporarily while we try to fix what seems to be a WordPress issue. I'll check (again...) if there's a way for me to just make it static, no more Wordpress :p

Yeah really dumb mistake on my part #_#. I do want to ask about something else that has bugged me for some time, when using timer (in lua) if I turn off and on the calc the whole problem freezes (the screen only updates if the focus changes). It is only mitigated by manually switching off the timer before turning off, and then turning the timer back on again. Do you know of any way to solve this, like automatically turning off timer? I tried various events but they don't do much.

Re: How do I use myLib?

Message non luPosté: 28 Juil 2022, 09:32
de Adriweb
I'm not really sure - I would try events like on.deactivate/activate, and using the latest apilevel... ?