Knob XP scripting

Support for KnobXP, share your experience and KnobXP modes.

Moderators: russ, Ralph

Message
Author
Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Knob XP scripting

#21 Post by Kaellis991 »

Keith Baxter wrote: Mon Sep 05, 2022 9:58 pm Hi

Lua is not that complex when you start to understand.

Lets do a simple table. my_table = {"Jack", "Fred", Jane"}
If this was a .json, then after the static_data_load(), my_table would = {"Jack", "Fred", Jane"}

Now lets change the value of the 2nd index "Fred" to "Tom"
my_table = {"Jack", "Tom", Jane"}

If we call ....print(my_table[2]) we would receive a print value of Tom.
This would not change the value in the .json. Only the value in the loaded table my_table()

Keith
Thanks for explaining that table concept....but
1. Is "my_table" a user defined variable or is that a lua function?
2. What is "the static_data_load()," ?
3. The "print(my_table[2])" returns the second item in the list of those three names?
4. You edit the original .json file and change the 2nd index of Fred to Tom.
5. What is the "loaded table" and where is it loaded?
6. Are you saying that the table, wherever it is loaded, is no longer the same as the original .json?

Not ever having programmed before, I have lots of questions about those terms you use. This is where an in person tutor available to answer and explain some of the basics would be very helpful.
Sometimes it takes asking the questions in different ways to get to an understanding of the concepts. And trying to do that with printed communication rather than direct talking can take lots of time.
Human communication is such an inexact science...

I've been trying to find some local programming tutors that I can meet with here in my town, but not having any luck so far.

User avatar
Keith Baxter
Posts: 4671
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Knob XP scripting

#22 Post by Keith Baxter »

Kaellis991 wrote: Mon Sep 05, 2022 10:27 pm

Thanks for explaining that table concept....but
1. Is "my_table" a user defined variable or is that a lua function?
It is a user defined VAR

2. What is "the static_data_load()," ?
.json and other static data can be used to load when and if required. https://siminnovations.com/wiki/index.p ... _data_load

3. The "print(my_table[2])" returns the second item in the list of those three names?
Correct

4. You edit the original .json file and change the 2nd index of Fred to Tom.
No not the original. The loaded VAR

5. What is the "loaded table" and where is it loaded?
A table can be declared anywhere. eg data ={}
then you can do anything to manipulate that table.
http://lua-users.org/wiki/TablesTutorial


6. Are you saying that the table, wherever it is loaded, is no longer the same as the original .json?
The .json will never change. Corjan has disabled that. You cannot write to a static data file. However you can write to a persistence file.
When you load a static_data_load() that loads the data to a custom VAR/TABLE (my_table), You can then manipulate that table. Not the .json. But you can reload the same .json or other .json files to the same (VAR/TABLE (my_table))as many times as you want.



Not ever having programmed before, I have lots of questions about those terms you use. This is where an in person tutor available to answer and explain some of the basics would be very helpful.
Sometimes it takes asking the questions in different ways to get to an understanding of the concepts. And trying to do that with printed communication rather than direct talking can take lots of time.
Human communication is such an inexact science...

I've been trying to find some local programming tutors that I can meet with here in my town, but not having any luck so far.
I hope my comments help. You are always welcome to ask help my side.


Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Knob XP scripting

#23 Post by Kaellis991 »

Thanks Keith

Post Reply