This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Global variables and constants
#1
Hi! 

I am new to Lua and Logic Machine 4 (I do not have LM5), but trying to learn. 
I have a question I hope someone can help me with. 

I want to controll heating loads in my house, by turning these on and off to reduce peak power. 
I therefore need to define constants and variables that all scripts (resident, event and in user library) can find, I belive these are called "global". 
I belive the declaration of the constants and variables can be written like this: 

------------------Constants in the system (temperatures) ---------------------

T_s={
  comfort={kitchen=22, bathroom=24, hall=20},
  save={kitchen=18, bathroom=20, hall=18
}


--------Declaration of the variables in the system -----------

loads={
  vb={k=5, room='bathroom', ad='2/0/5', B=0, P=3000},
  vk={k=4, room='bathroom', ad='11/0/0' ,B=1, P=60, T=T_test.bathroom},
  po={k=3, room='kitchen', ad='11/0/4', B=0, P=800, T=T_test.kitchen},
  vf_gang={k=2, room='hall', ad='2/0/6', B=0, P=860, T=T_test.hall},
  vf_kj={k=1, room='kitchen', ad='11/0/2', B=0, P=15, T=T_test.kitchen}
  }



I have read something about storage.set(), but is this the only way to do it? If so, in what script? And I am going to use these values a lot, will I always have to write  storage.get()?
Or can I make a library in User Library and just define all constants and variables like above, and then they are "global"? 

Thank you for all help!
Reply


Messages In This Thread
Global variables and constants - by camillsg - 04.03.2020, 14:59
RE: Global variables and constants - by admin - 04.03.2020, 16:39
Global variables and constants - by mjaanes - 05.03.2020, 06:47
RE: Global variables and constants - by admin - 05.03.2020, 06:49
Global variables and constants - by mjaanes - 09.03.2020, 13:25

Forum Jump: