It is currently June 16th, 2021, 11:08 am

Editing and adding more lights to this script

Help with creating, editing & fixing problems with skins
cyanfire
Posts: 3
Joined: June 11th, 2021, 11:49 am

Editing and adding more lights to this script

Post by cyanfire »

https://www.deviantart.com/lordskelethom/art/Fairy-lights-skin-for-Rainmeter-498901683

I want to edit this script and re-arrange the lights, that part i have no issues with but i would like to be able to add more lights but i can't seem to figure it out, adding more than the default 13 doesn't seem to work. What am i doing wrong? I have added a [MeterLightOff14] and [MeterLightOn14] as can be seen from my edited FairyLights.ini below. I have also altered the FairyLights.lua lightnum value to 14 to correspond with the added light but the new light doesn't flash and just remains off. I have added the altered lua code below too.


Rainmeter 4.4.0.3452 beta (64-bit)
Language: English (1033)
Build time: 2021-05-24 5:26:35
Windows 10 Pro 2004 64-bit (build 19041) - English (2057)
Path: C:\Program Files\Rainmeter\
SkinPath: C:\Users\killa\Documents\Rainmeter\Skins\
SettingsPath: C:\Users\killa\AppData\Roaming\Rainmeter\
IniFile: C:\Users\killa\AppData\Roaming\Rainmeter\Rainmeter.ini


FairyLights.ini

Code: Select all

[Rainmeter]
Update=1000

[Metadata]
Name=FairyLights
Author=LordSk
Version=1.0
Information=Works best on 1920x1080 setups

# Light patterns : 1-3
# Use 0 for random patterns
[LightScript]
Measure=Script
ScriptFile=FairyLights.lua
LightPattern=0

#wire
[MeterWire]
Meter=Image
ImageName=Images\fil.png
DynamicVariables=1

#light styles
[sRedOff]
ImageName=Images\fl_red_off.png
Hidden=1

[sRedOn]
ImageName=Images\fl_red_on.png

[sGreenOff]
ImageName=Images\fl_green_off.png

[sGreenOn]
ImageName=Images\fl_green_on.png

[sBlueOff]
ImageName=Images\fl_blue_off.png

[sBlueOn]
ImageName=Images\fl_blue_on.png

[sPurpleOff]
ImageName=Images\fl_purple_off.png

[sPurpleOn]
ImageName=Images\fl_purple_on.png

[sOrangeOff]
ImageName=Images\fl_orange_off.png

[sOrangeOn]
ImageName=Images\fl_orange_on.png

[sYellowOff]
ImageName=Images\fl_yellow_off.png

[sYellowOn]
ImageName=Images\fl_yellow_on.png

#light meters
[MeterLightOff1]
Meter=Image
MeterStyle=sRedOff
ImageRotate=206
X=-55
Y=-52

[MeterLightOn1]
Meter=Image
MeterStyle=sRedOn
ImageRotate=206
X=-55
Y=-52

[MeterLightOff2]
Meter=Image
MeterStyle=sGreenOff
ImageRotate=187
X=73
Y=0

[MeterLightOn2]
Meter=Image
MeterStyle=sGreenOn
ImageRotate=187
X=73
Y=0

[MeterLightOff3]
Meter=Image
MeterStyle=sBlueOff
ImageRotate=164
X=165
Y=-21

[MeterLightOn3]
Meter=Image
MeterStyle=sBlueOn
ImageRotate=164
X=165
Y=-21

[MeterLightOff4]
Meter=Image
MeterStyle=sPurpleOff
ImageRotate=200
X=274
Y=-44

[MeterLightOn4]
Meter=Image
MeterStyle=sPurpleOn
ImageRotate=200
X=274
Y=-44

[MeterLightOff5]
Meter=Image
MeterStyle=sOrangeOff
ImageRotate=173
X=393
Y=-19

[MeterLightOn5]
Meter=Image
MeterStyle=sOrangeOn
ImageRotate=173
X=393
Y=-19

[MeterLightOff6]
Meter=Image
MeterStyle=sYellowOff
ImageRotate=210
X=470
Y=-27

[MeterLightOn6]
Meter=Image
MeterStyle=sYellowOn
ImageRotate=210
X=470
Y=-27

[MeterLightOff7]
Meter=Image
MeterStyle=sRedOff
ImageRotate=283
X=513
Y=46

[MeterLightOn7]
Meter=Image
MeterStyle=sRedOn
ImageRotate=283
X=513
Y=46

[MeterLightOff8]
Meter=Image
MeterStyle=sGreenOff
ImageRotate=264
X=514
Y=128

[MeterLightOn8]
Meter=Image
MeterStyle=sGreenOn
ImageRotate=264
X=514
Y=128

[MeterLightOff9]
Meter=Image
MeterStyle=sBlueOff
ImageRotate=245
X=512
Y=175

[MeterLightOn9]
Meter=Image
MeterStyle=sBlueOn
ImageRotate=245
X=512
Y=175

[MeterLightOff10]
Meter=Image
MeterStyle=sPurpleOff
ImageRotate=300
X=492
Y=225

[MeterLightOn10]
Meter=Image
MeterStyle=sPurpleOn
ImageRotate=300
X=492
Y=225

[MeterLightOff11]
Meter=Image
MeterStyle=sOrangeOff
ImageRotate=281
X=481
Y=306

[MeterLightOn11]
Meter=Image
MeterStyle=sOrangeOn
ImageRotate=281
X=481
Y=306

[MeterLightOff12]
Meter=Image
MeterStyle=sYellowOff
ImageRotate=253
X=477
Y=368

[MeterLightOn12]
Meter=Image
MeterStyle=sYellowOn
ImageRotate=253
X=477
Y=368

[MeterLightOff13]
Meter=Image
MeterStyle=sRedOff
ImageRotate=241
X=496
Y=427

[MeterLightOn13]
Meter=Image
MeterStyle=sRedOn
ImageRotate=241
X=496
Y=427

[MeterLightOff14]
Meter=Image
MeterStyle=sGreenOff
ImageRotate=264
X=530
Y=128

[MeterLightOn14]
Meter=Image
MeterStyle=sGreenOn
ImageRotate=264
X=530
Y=128
FairyLights.lua

Code: Select all

function clamp(val, min , max)
	if val < min then
		return min
	elseif val > max then
		return max
	end
	return val
end

function Initialize()
	math.randomseed(os.time())
	
	lightsOff = {}
	lightsOn = {}
	lightNum = 14
	
	for i = 1, lightNum do
		lightsOff[#lightsOff + 1] = SKIN:GetMeter('MeterLightOff'..i)
		lightsOff[#lightsOff]:Show()
		
		lightsOn[#lightsOn + 1] = SKIN:GetMeter('MeterLightOn'..i)
		lightsOn[#lightsOn]:Hide()
	end
	
	-- Light patterns
	patterns = {}
	patterns[1] = {
		{1,1,1,1,1,1,1,1,1,1,1,1,1},
		{0,0,0,0,0,0,0,0,0,0,0,0,0},
		{1,1,1,1,1,1,1,1,1,1,1,1,1},
		{0,0,0,0,0,0,0,0,0,0,0,0,0},
	}
	patterns[2] = {
		{0,1,0,1,0,1,0,1,0,1,0,1,0},
		{1,0,1,0,1,0,1,0,1,0,1,0,1},
		{0,1,0,1,0,1,0,1,0,1,0,1,0},
		{1,0,1,0,1,0,1,0,1,0,1,0,1},
	}
	patterns[3] = {
		{1,1,0,0,0,0,0,0,0,0,0,1,1},
		{1,1,1,1,0,0,0,0,0,1,1,1,1},
		{1,1,1,1,1,1,0,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1,1,1,1},
		{0,0,0,0,0,0,0,0,0,0,0,0,0},
	}
	
	patternCur = 1
	lightPatternOptn = SELF:GetNumberOption('LightPattern', 0)
	pattChosen = clamp(lightPatternOptn, 1, #patterns)
	
	-- random pattern
	if lightPatternOptn == 0 then
		pattChosen = math.random(1, #patterns)
	end
end

function Update()
	for i = 1, lightNum do
		if patterns[pattChosen][patternCur][i] == 1 then
			lightsOn[i]:Show()
			lightsOff[i]:Hide()
		else
			lightsOn[i]:Hide()
			lightsOff[i]:Show()
		end
	end
	
	-- Current pattern ended
	if lightPatternOptn == 0 and patternCur == #patterns[pattChosen] then
		pattChosen = math.random(1, #patterns)
		patternCur = 1
	else
		patternCur = patternCur%#patterns[pattChosen] + 1
	end
end
User avatar
death.crafter
Posts: 176
Joined: April 24th, 2021, 8:13 pm

Re: Editing and adding more lights to this script

Post by death.crafter »

cyanfire wrote: June 11th, 2021, 12:57 pm FairyLights.lua

Code: Select all

function Initialize()
	math.randomseed(os.time())
	
	lightsOff = {}
	lightsOn = {}
	lightNum = 14
	
	for i = 1, lightNum do
		lightsOff[#lightsOff + 1] = SKIN:GetMeter('MeterLightOff'..i)
		lightsOff[#lightsOff]:Show()
		
		lightsOn[#lightsOn + 1] = SKIN:GetMeter('MeterLightOn'..i)
		lightsOn[#lightsOn]:Hide()
	end
	
	-- Light patterns
	patterns = {}
	patterns[1] = {
		{1,1,1,1,1,1,1,1,1,1,1,1,1},
		{0,0,0,0,0,0,0,0,0,0,0,0,0},
		{1,1,1,1,1,1,1,1,1,1,1,1,1},
		{0,0,0,0,0,0,0,0,0,0,0,0,0},
	}
	patterns[2] = {
		{0,1,0,1,0,1,0,1,0,1,0,1,0},
		{1,0,1,0,1,0,1,0,1,0,1,0,1},
		{0,1,0,1,0,1,0,1,0,1,0,1,0},
		{1,0,1,0,1,0,1,0,1,0,1,0,1},
	}
	patterns[3] = {
		{1,1,0,0,0,0,0,0,0,0,0,1,1},
		{1,1,1,1,0,0,0,0,0,1,1,1,1},
		{1,1,1,1,1,1,0,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1,1,1,1},
		{0,0,0,0,0,0,0,0,0,0,0,0,0},
	}
	
	patternCur = 1
	lightPatternOptn = SELF:GetNumberOption('LightPattern', 0)
	pattChosen = clamp(lightPatternOptn, 1, #patterns)
	
	-- random pattern
	if lightPatternOptn == 0 then
		pattChosen = math.random(1, #patterns)
	end
end
You need to change the patterns too. Figure out how these patterns work and add 1 or 0 accordingly at the end of the arrays.
from the Realm of Death
cyanfire
Posts: 3
Joined: June 11th, 2021, 11:49 am

Re: Editing and adding more lights to this script

Post by cyanfire »

OMG, please forgive me i am not a coder. Thankyou very much!
User avatar
death.crafter
Posts: 176
Joined: April 24th, 2021, 8:13 pm

Re: Editing and adding more lights to this script

Post by death.crafter »

cyanfire wrote: June 11th, 2021, 1:56 pm OMG, please forgive me i am not a coder. Thankyou very much!
What? It's like adding 1s and 0s like:

patterns[1] = {
{1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
}
patterns[2] = {
{0,1,0,1,0,1,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,1,0,1,0,1,0},
{0,1,0,1,0,1,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,1,0,1,0,1,0},
}


The third one I don't want to touch since I don't know how he's making that pattern.
from the Realm of Death
cyanfire
Posts: 3
Joined: June 11th, 2021, 11:49 am

Re: Editing and adding more lights to this script

Post by cyanfire »

Haha no i completely understand what you mean, i was saying OMG as it was such a simple thing i was missing