It is currently April 27th, 2024, 12:59 am
lua question
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua question
There's a problem with the TextClock.lua file: this new file is not working well. I have a previous TextClock.lua, you've used before and that is 100% ok. You'll find it attached to this message. Just replace the existing file, with this one.
You do not have the required permissions to view the files attached to this post.
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua question
I suppose it's not impossible. If you won't find a solution, tomorrow I'll try to find one.dvo wrote:then i have again what i don't want i guess it shows the time from the clock and not the time of the set timer ....
both will not work i know that the other one works couse it runs on os time and not on the set timer
what i'm trying to make is that the lua the time out of the set timer loads instead of the real time
-
- Posts: 826
- Joined: November 20th, 2012, 11:58 pm
Re: lua question
Out of curiosuty, can you post an example (a simple code or numerical) of what you want?
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua question
You'll find the skin in dvo's first post above.FreeRaider wrote:Out of curiosuty, can you post an example (a simple code or numerical) of what you want?
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua question
Here is the fix of your last problem. If you want that on the alarm clock the text indicate not the current time, but what you've set to the alarm, you'll have to work with the TextClock.lua. This file takes the hour and minute of the operating system and you'll want instead to take the Time variable from the Arc.ini and work with it. To achieve this, just replace thedvo wrote:lua had to be fixed couse lua says simply take the time of the operation system ....instead of hour and minutes out of the variable tried many ways but don't understand lua script yet ..
Code: Select all
hour = tonumber(os.date('%I'))
minute = tonumber(os.date('%M'))
Code: Select all
AlarmTime = SKIN:GetVariable('Time')
LenAlarmTime = string.find(AlarmTime, ':') - 1
hour = tonumber(string.sub(AlarmTime, 1, LenAlarmTime))
if hour > 12 then
hour = hour - 12
end
minute = tonumber(string.sub(AlarmTime, -2, -1))
The next step is to get from the alarmTime variable the number of hours and the number of minutes. hour = tonumber(string.sub(AlarmTime, 1, LenAlarmTime)) determines the hour, copying from the AlarmTime variable everything from the first, until the LenAlarmTime character (one or two characters). Also minute = tonumber(string.sub(AlarmTime, -2, -1)) copies the last two characters of AlarmTime. In both cases the copied characters are converted to numbers by the tonumber function.
The last thing you'll have to do, is to extract 12 from the number of hours, if this is greater then 12 (the lua script works only if the number of hours is below 12).
I left the rest of the TextClock.lua file untouched. It can use with no problems the hour and minute variables determined previously.
To be honest, I just believe this is a good solution, because I don't know Dutch at all, so I practically can't check. But I think it's a good solution. Please let me know if it indeed is.
Also note that with all this changes, you won't be able to use the TextClock.lua file into the TextClock.ini. If you want to use it, you'll have to recreate the initial TextClock.lua, name it for example TextClock2.lua and replace its name in the [MeasureTime] measure of the TextClock.ini.
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua question
Please upload the last package you have. I worked in the meantime with those skins and it would be useful to have a "clean" package. Thanks.
EDIT: Sorry, you've edited your post in the meantime. It's ok.
EDIT: Sorry, you've edited your post in the meantime. It's ok.
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua question
No, no at all. As I posted in the EDIT, it's ok now.dvo wrote:this is the altered version of jsmorley and the addon of yours ... you want the clean version of jsmorley?
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua question
The same situation we have in Hungarian. So, here is what to do: just add the hour = hour == 12 and 1 or hour + 1 line under the elseif statement in the Update() function:dvo wrote:balala i found a little mistake had to befixed in lua : in english we say half past 9 for 9:30 in dutch we say half ten
is it possible to add a +1 in hour on half time?
like this it had to be : kwarter past 9 , half ten , kwarter to ten .... 10 o' clock
Code: Select all
if minute < 30 then
adjustedMinute = minute
midText = afterText
elseif minute == 30 then
adjustedMinute = minute
midText = halfText
hour = hour == 12 and 1 or hour + 1
else
midText = untilText
adjustedMinute = 60 - minute
hour = hour == 12 and 1 or hour + 1
end
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: lua question
No, at all. You've copied the wholedvo wrote:like this? is doesn't change any thing here ...yet
Code: Select all
if minute < 30 then
...
elseif minute == 30 then
...
else
...
end
Here is the TextClock.lua:
Code: Select all
function Initialize()
afterText = SKIN:GetVariable('AfterText')
untilText = SKIN:GetVariable('UntilText')
halfText = SKIN:GetVariable('HalfText')
AlarmTime = SKIN:GetVariable('Time')
numTable = {}
numTable['0'] = 'nul'
numTable['1'] = 'een'
numTable['2'] = 'twee'
numTable['3'] = 'drie'
numTable['4'] = 'vier'
numTable['5'] = 'vijf'
numTable['6'] = 'zes'
numTable['7'] = 'zeven'
numTable['8'] = 'acht'
numTable['9'] = 'negen'
numTable['10'] = 'tien'
numTable['11'] = 'elf'
numTable['12'] = 'twaalf'
numTable['13'] = 'dertien'
numTable['14'] = 'veertien'
numTable['15'] = 'kwart'
numTable['16'] = 'zestien'
numTable['17'] = 'zeventien'
numTable['18'] = 'achttien'
numTable['19'] = 'negentien'
numTable['30'] = 'half'
end
function Update()
hour = tonumber(os.date('%I'))
minute = tonumber(os.date('%M'))
if minute < 30 then
adjustedMinute = minute
midText = afterText
elseif minute == 30 then
adjustedMinute = minute
midText = halfText
hour = hour == 12 and 1 or hour + 1
else
midText = untilText
adjustedMinute = 60 - minute
hour = hour == 12 and 1 or hour + 1
end
if adjustedMinute >= 20 and adjustedMinute < 30 then
if adjustedMinute == 20 then
minuteText = 'twintig minuten'
else
minuteText =numTable[tostring(adjustedMinute - 20)]..' en twintig minuten'
end
else
if adjustedMinute ~= 15 and adjustedMinute ~= 45 and adjustedMinute ~= 30 then
if adjustedMinute == 1 then
minuteText = numTable[tostring(adjustedMinute)]..' minuut'
else
minuteText = numTable[tostring(adjustedMinute)]..' minuten'
end
else
minuteText = numTable[tostring(adjustedMinute)]
end
end
if adjustedMinute == 0 then
return numTable[tostring(hour)]..' uur'
else
return minuteText.. ' '..midText..' '..numTable[tostring(hour)]
end
end