It is currently May 3rd, 2024, 5:33 pm

Question about the note skin

Get help with creating, editing & fixing problems with skins
cd0123
Posts: 9
Joined: December 6th, 2010, 2:20 pm

Question about the note skin

Post by cd0123 »

Hi everyone,
I would like to ask some questions about the note skin. I would like to create
a note skin that it can change every day. This idea is similar to the schedule book that
can remain us what to do on that day.
For example, I have an appointment on 31 Jan. Then I just create a notepad file called 0131.txt and
the skin will show this event on 31 Jan when I open the rainmeter on this day.
Can anyone give me some ideas to write this type of skin?
thanks for your attention.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Question about the note skin

Post by Kaelri »

Since you can't use dynamic variables in plugin measures, you'd have to use a lot of messy workarounds to do this using the traditional Quote plugin. Instead, I would recommend a simple Lua script.

Start with a couple of Time measures to get the current month and day:

Code: Select all

[MeasureMonth]
Measure=Time
Format=%m

[MeasureDay]
Measure=Time
Format=%d
Then add a Script measure, which will reference the script file that you're about to create, e.g. "Datebook.lua". Unless you want to keep all of your .txt files in the same folder as the skin, you should probably allow yourself to set the notes folder here:

Code: Select all

[MeasureDatebookScript]
Measure=Script
ScriptFile=Datebook.lua
UpdateDivider=10
NotesFolder=#CURRENTPATH#
(The "UpdateDivider=10" means the script will update every 10 seconds.)

And lastly, of course, create the meter that will be used to display your notes' content, and format it however you want:

Code: Select all

[Content]
Meter=String
MeasureName=MeasureDatebookScript
As for your script file, it's pretty straightforward:

Code: Select all

--Get the notes folder from the setting in [MeasureDatebookScript].
PROPERTIES = {
	NotesFolder = '';
}

function Initialize()
	--This function is required to exist, but you don't need to do anything here.
end

function Update()

	--Get the current month from [MeasureMonth].
	msMonth = SKIN:GetMeasure('MeasureMonth')
	sMonth = msMonth:GetStringValue()
	
	--Get the current day from [MeasureDay].
	msDay = SKIN:GetMeasure('MeasureDay')
	sDay = msDay:GetStringValue()
	
	--Open the file, get the contents, and close the file.
	sFilepath = io.input(PROPERTIES.NotesFolder..sMonth..sDay..'.txt')
	sContent = io.read('*all')
	io.close(sFilepath)
	
	--Return the contents as the value of [MeasureDatebookScript].
	return sContent
end

Should be all you need. :)
cd0123
Posts: 9
Joined: December 6th, 2010, 2:20 pm

Re: Question about the note skin

Post by cd0123 »

Kaelri wrote:Since you can't use dynamic variables in plugin measures, you'd have to use a lot of messy workarounds to do this using the traditional Quote plugin. Instead, I would recommend a simple Lua script.

Start with a couple of Time measures to get the current month and day:

Code: Select all

[MeasureMonth]
Measure=Time
Format=%m

[MeasureDay]
Measure=Time
Format=%d
Then add a Script measure, which will reference the script file that you're about to create, e.g. "Datebook.lua". Unless you want to keep all of your .txt files in the same folder as the skin, you should probably allow yourself to set the notes folder here:

Code: Select all

[MeasureDatebookScript]
Measure=Script
ScriptFile=Datebook.lua
UpdateDivider=10
NotesFolder=#CURRENTPATH#
(The "UpdateDivider=10" means the script will update every 10 seconds.)

And lastly, of course, create the meter that will be used to display your notes' content, and format it however you want:

Code: Select all

[Content]
Meter=String
MeasureName=MeasureDatebookScript
As for your script file, it's pretty straightforward:

Code: Select all

--Get the notes folder from the setting in [MeasureDatebookScript].
PROPERTIES = {
	NotesFolder = '';
}

function Initialize()
	--This function is required to exist, but you don't need to do anything here.
end

function Update()

	--Get the current month from [MeasureMonth].
	msMonth = SKIN:GetMeasure('MeasureMonth')
	sMonth = msMonth:GetStringValue()
	
	--Get the current day from [MeasureDay].
	msDay = SKIN:GetMeasure('MeasureDay')
	sDay = msDay:GetStringValue()
	
	--Open the file, get the contents, and close the file.
	sFilepath = io.input(PROPERTIES.NotesFolder..sMonth..sDay..'.txt')
	sContent = io.read('*all')
	io.close(sFilepath)
	
	--Return the contents as the value of [MeasureDatebookScript].
	return sContent
end

Should be all you need. :)
Thanks a lot!! It's great :D :thumbup: