It is currently November 30th, 2020, 11:13 pm

Rewriting a skin to use Lua for better efficiency?

Discuss the use of Lua in Script measures.
User avatar
Halloyo
Posts: 31
Joined: June 17th, 2020, 3:08 am

Rewriting a skin to use Lua for better efficiency?

Post by Halloyo »

Hello,

So in this skin I am working on, the user has multiple options to choose from. Every time an option is selected (clicked), the skin writes about 33 variables to variables.inc using !WriteKeyValue. Obviously this skin isn't always loaded as it is a settings skins. Also, this skin only updates when an option is selected.

Everything was done within the skin, but looking back, I was wondering if it would be more efficient to redo the bangs within lua?

What I have summed up in rainmeter (obviously this isn't the full code, it'd take too much place):

Code: Select all

 
[Option1]
LeftMouseUpAction=[!WriteKeyValue Variables Option "1"][!WriteKeyValue Variables Place1X "1"][!WriteKeyValue Variables Place1Y "1"][!WriteKeyValue Variables Place2X "1"][!WriteKeyValue Variables Place2Y "1"]...[!Refresh]

[Option2]
LeftMouseUpAction=[!WriteKeyValue Variables Option "2"][!WriteKeyValue Variables Place1X "2"][!WriteKeyValue Variables Place1Y "2"][!WriteKeyValue Variables Place2X "2"][!WriteKeyValue Variables Place2Y "2"]...[!Refresh]
 

(Just a thought: would it be more efficient to write all the values into an array? But I don't really know about arrays since I'm new to Lua. Then if the user presses an option it would look across the row to find the variables? It seems complicated for something that won't be used much...)

The array would look something like this:
Image
User avatar
Active Colors
Moderator
Posts: 624
Joined: February 16th, 2012, 3:32 am

Re: Rewriting a skin to use Lua for better efficiency?

Post by Active Colors »

Hey Halloyo,

I somehow ignored this topic as I am no way good at LUA but after reading your question I can pretty much say that you don't really need to use LUA here as you can achieve this with one CALC measure.

I see you have at the end !Refresh bang so I will omit visually updating the skin it but in case you don't want to !Refresh the skin you can just use !SetVariable bangs and then !Redraw, which is how I did in test skin. The barebones would be like this:

Code: Select all

[Variables]
Option=1

[MeasureIgnition]
Measure=Calc
Formula=MeasureIgnition+1
OnUpdateAction=[!WriteKeyValue Variables Place[MeasureIgnition]X #Option#][!WriteKeyValue Variables Place[MeasureIgnition]Y #Option#][!UpdateMeasure MeasureIgnition]
Disabled=1
IfEqualValue=5
IfEqualAction=[!DisableMeasure MeasureIgnition][!Refresh]
DynamicVariables=1

[SetOption1]
Meter=String
MeterStyle=StyleText
X=15
Y=50
Text=Option 1
LeftMouseUpAction=[!SetVariable Option 1][!WriteKeyValue Variables Option 1][!EnableMeasure MeasureIgnition][!UpdateMeasure MeasureIgnition]

[SetOption2]
Meter=String
MeterStyle=StyleText
X=100
Y=r
Text=Option 2
LeftMouseUpAction=[!SetVariable Option 2][!WriteKeyValue Variables Option 2][!EnableMeasure MeasureIgnition][!UpdateMeasure MeasureIgnition]

click on the picture to animate:
GIF.gif
  • Formula=MeasureIgnition+1 after every update of the measure it incrememnts its value by one.
  • OnUpdateAction=[!WriteKeyValue Variables Place[MeasureIgnition]X #Option#][!WriteKeyValue Variables Place[MeasureIgnition]Y #Option#] it updates repeatedly itself and with every repeat its value incrementing by one and every update it writes the values sequentially until reaches the ifEqualValue
  • IfEqualValue=5 identifies after how many times the measure will be stoped (note that it starts from 0 so you need to add plus one)
You can implement this method with ActionTimer but this way was quicker for me.
You do not have the required permissions to view the files attached to this post.
User avatar
Halloyo
Posts: 31
Joined: June 17th, 2020, 3:08 am

Re: Rewriting a skin to use Lua for better efficiency?

Post by Halloyo »

Thanks so much for the input, but I think I wasn't being very clear on my end. Actually, every Place...X/Y has a different value. And there really is no correlation between them. Basically every option is a "wallpaper" (not really, it's just a big image) and the Place...X/Y sets the position of other pictures. The pictures are in different places with every "wallpaper", so that's why originally, I had to write every Place...X/Y individually. Still, thank you for your help. :D
User avatar
Active Colors
Moderator
Posts: 624
Joined: February 16th, 2012, 3:32 am

Re: Rewriting a skin to use Lua for better efficiency?

Post by Active Colors »

Halloyo wrote: June 27th, 2020, 2:38 am Thanks so much for the input, but I think I wasn't being very clear on my end. Actually, every Place...X/Y has a different value. And there really is no correlation between them. Basically every option is a "wallpaper" (not really, it's just a big image) and the Place...X/Y sets the position of other pictures. The pictures are in different places with every "wallpaper", so that's why originally, I had to write every Place...X/Y individually. Still, thank you for your help. :D
Well, can you post some examples of your bangs? From your screenshot and the code I thought there was a correlation of Place and Option.
User avatar
Halloyo
Posts: 31
Joined: June 17th, 2020, 3:08 am

Re: Rewriting a skin to use Lua for better efficiency?

Post by Halloyo »

I've already rewritten it in lua because it's much easier for me to see (scroll down instead of sideways) and it looks like this:


Everytime, an option is clicked, it calls the specific option function so that way, it doesn't write the values when the skin is loaded, refreshed, etc.
So technically I could close this post as completed since I already rewrote it oops

Code: Select all

function Original()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodIn', '368', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodIn', '375', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodOut', '705', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodOut', '705', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1', '106', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1', '493', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2', '172', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2', '579', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace3', '30', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace3', '701', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace4', '301', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace4', '668', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace5', '431', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace5', '546', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace6', '578', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace6', '402', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace7', '800', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace7', '378', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace8', '925', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace8', '685', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace9', '836', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace9', '485', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace10', '717', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace10', '596', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1L', '91', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1L', '519', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2L', '745', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2L', '520', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSu', '1', "#@#variables.inc")
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWe', '1', "#@#variables.inc")
end

function Cafe()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodIn', '715', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodIn', '665', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodOut', '660', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodOut', '328', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1', '249', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1', '525', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2', '308', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2', '630', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace3', '35', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace3', '553', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace4', '362', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace4', '377', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace5', '474', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace5', '460', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace6', '45', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace6', '271', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace7', '496', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace7', '686', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace8', '892', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace8', '684', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace9', '716', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace9', '571', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace10', '880', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace10', '433', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1L', '260', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1L', '558', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2L', '748', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2L', '514', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSu', '1', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWe', '1', '#@#variables.inc')
end

function Modern()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodIn', '332', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodIn', '222', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodOut', '505', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodOut', '570', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1', '58', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1', '551', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2', '244', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2', '464', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace3', '174', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace3', '346', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace4', '398', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace4', '348', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace5', '639', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace5', '361', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace6', '565', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace6', '481', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace7', '477', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace7', '676', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace8', '797', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace8', '344', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace9', '733', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace9', '670', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace10', '861', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace10', '565', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1L', '103', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1L', '498', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2L', '752', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2L', '621', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSu', '1', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWe', '1', '#@#variables.inc')
end

function Rustic()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodIn', '90', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodIn', '672', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodOut', '720', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodOut', '730', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1', '426', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1', '584', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2', '478', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2', '661', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace3', '46', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace3', '475', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace4', '223', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace4', '434', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace5', '153', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace5', '599', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace6', '283', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace6', '727', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace7', '660', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace7', '221', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace8', '905', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace8', '301', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace9', '739', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace9', '657', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace10', '861', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace10', '554', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1L', '410', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1L', '615', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2L', '748', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2L', '604', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSu', '1', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWe', '1', '#@#variables.inc')
end

function Sugary()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodIn', '450', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodIn', '322', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodOut', '685', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodOut', '695', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1', '77', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1', '507', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2', '208', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2', '594', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace3', '119', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace3', '397', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace4', '343', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace4', '436', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace5', '60', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace5', '694', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace6', '440', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace6', '647', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace7', '900', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace7', '291', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace8', '929', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace8', '667', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace9', '726', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace9', '583', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace10', '843', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace10', '481', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1L', '57', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1L', '579', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2L', '756', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2L', '506', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSu', '0', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWe', '1', '#@#variables.inc')
end

function Western()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodIn', '265', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodIn', '270', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodOut', '570', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodOut', '630', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1', '144', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1', '495', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2', '274', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2', '550', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace3', '387', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace3', '406', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace4', '505', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace4', '334', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace5', '158', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace5', '676', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace6', '481', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace6', '693', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace7', '714', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace7', '695', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace8', '864', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace8', '254', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace9', '714', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace9', '532', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace10', '860', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace10', '606', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1L', '129', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1L', '512', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2L', '760', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2L', '552', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSu', '1', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWe', '0', '#@#variables.inc')
end

function Zen()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodIn', '565', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodIn', '480', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XFoodOut', '190', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YFoodOut', '720', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1', '183', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1', '584', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2', '328', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2', '501', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace3', '78', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace3', '407', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace4', '406', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace4', '261', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace5', '446', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace5', '606', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace6', '595', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace6', '430', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace7', '649', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace7', '697', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace8', '865', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace8', '634', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace9', '861', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace9', '451', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace10', '704', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace10', '539', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace1L', '215', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace1L', '525', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'XPlace2L', '783', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'YPlace2L', '473', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSu', '1', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWe', '1', '#@#variables.inc')
end

function Regular()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'Season', 'reg', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSuW', '297', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSuX', '183', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSuY', '681', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWeW', '237', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWeX', '29', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWeY', '511', '#@#variables.inc')
end

function Winter()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'Season', 'sn', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSuW', '296', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSuX', '183', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSuY', '673', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWeW', '237', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWeX', '29', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWeY', '511', '#@#variables.inc')
end

function Summer()
  SKIN:Bang('!WriteKeyValue', 'Variables', 'Season', 'su', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSuW', '283', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSuX', '190', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaSuY', '695', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWeW', '239', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWeX', '29', '#@#variables.inc')
  SKIN:Bang('!WriteKeyValue', 'Variables', 'EndagawaWeY', '489', '#@#variables.inc')
end
User avatar
Active Colors
Moderator
Posts: 624
Joined: February 16th, 2012, 3:32 am

Re: Rewriting a skin to use Lua for better efficiency?

Post by Active Colors »

Glad you did it! Though I see you have repeating !WriteKeyValue bangs.
You alternatively can do it this way if you want:

Have a separate file where respective values will be stored, for example Cafe.inc will have its values XFoodIn=715 YFoodIn=665...
Then in the skin where the actions are happening you will have an reference to the chosen option like Cafe.inc
And the values of !WriteKeyValue will be taken from Cafe.inc and written to your variables.inc

Something like:

Code: Select all

[Variables]
Option=Cafe
@include=#Option#.inc

[MeterName]
LeftMouseUpAction=[!WriteKeyValue Variables XFoodIn #XFoodIn#, "#@#variables.inc"]
So you will not have repeating actions over and over.
User avatar
Halloyo
Posts: 31
Joined: June 17th, 2020, 3:08 am

Re: Rewriting a skin to use Lua for better efficiency?

Post by Halloyo »

Why didn't I think about it?? Anyway, thanks for the help, I think I'll keep that method in mind for the future, because I'm way too lazy to redo everything for the nth time. :D