mzscript 0.9.13 question Thread last updated on 2006-10-10 17:05:52

Posted by member 302889 on 2006-10-09 15:06:39

Hi all.

If i have three vars set in mzscript as follows...

SleepHrs
SleepMins
SleepSecs

...and i want to use the !LabelSetText bang to set the text of a label, what is the syntax i need to use to input those vars in the text. e.g....

*Script exec !LabelSetText SleepCounter "%{SleepHrs}:%{SleepMins}:%{SleepSecs}"

Is this a good guess? I'm having a few probs with my script and need to narrow down what the problem is and what it isn't. If i knew this piece of code was correct or incorrect it would help me a lot.

I'm making a sleep function for my theme so you can set the time before the PC shuts down e.g. 5 mins, 30 mins, 3 hours etc but i need to be able to update the display with an accurate time reading. i have made a nice wee script to continually pause for 1000 milliseconds and then to calculate the values of each part of the time, hours, minutes and seconds and just need to get the display part sorted. When the counter reaches zero, the PC should then shutdown.

I'm basing this code on an example i got from the Obsidian theme which was created by Immortal and Norman Bates. Cheers guys!!!

Any help would be appreciated.

Cheers all.

John

Posted by member 212670 on 2006-10-09 15:31:42 link

The line looks correct, assuming that the vars contain the values you want.

What is the error you're actually having?

Posted by member 302889 on 2006-10-09 15:55:49 link

There isn't an error message coming up, it just isn't working right.

You've helped me a lot though.

I'll just check my code in another .rc file because i think there is only one other thing that it could be.

I'll get back to you soon if it works. Cheers.

John

Posted by member 212670 on 2006-10-09 18:53:40 link

If you can't figure it out, post the code, or feel free to email me.

Posted by member 302889 on 2006-10-09 19:24:10 link

ok, i was wrong. i still can't get it working.

i'm using the timer-0.5 module and the ByeWindows-0.4 aling with xlabel and mzscript.

lets say for example that i set the timer to countdown for 3 hours before turning the PC off. That works out at 10800000 millisceonds.

How do i write a piece of mzscript which will interpret that and convert it to hours, minutes and seconds.

i can show the calculations on my xlabel using the code i posted earlier but they show up lots of odd numbers and decimal places and it doesn't even count down for the length of time that it should.

If you are interested, here is the code i have so far

*Script bang !Panel_Sleep
*Script exec !NetReloadModule ByeWindows-0.4
*Script exec !NetReloadModule Timer-0.5
*Script exec !LabelShow SleepPanel
*Script exec !varset sleepstarted 0
*Script exec !LabelSetText SleepDownPanelBtn2 "START"
*Script exec !TimerAdd Sleep 300000 !Sleep
*Script exec !varset SleepMSecs 300000
*Script ~bang

*Script bang !Sleep_Start_Countdown
*Script exec !varset sleepstarted 1
*Script exec !LabelSetText SleepDownPanelBtn2 "CANCEL"
*Script exec !LabelRefresh SleepDownPanelBtn2
*Script exec !TimerStart Sleep
*Script exec !Shutdown_Sleep_Counter
*Script ~bang

*Script bang !Shutdown_Sleep_Counter
*Script gotoif ("%{canceled}" = "1") Counter_End
*Script exec !Pause 1000
*Script exec !varAdd SleepMSecs -1000
*Script exec !Varset SleepHrs %{SleepMSecs}
*Script exec !varDiv SleepHrs 3600000
*Script exec !Varset SleepHrsMod %{SleepMSecs}
*Script exec !varMod SleepHrsMod 3600000
*Script exec !varAdd SleepHrs -%{SleepHrsMod}
*Script exec !Varset SleepMins %{SleepMSecs}
*Script exec !Varset SleepMinsMod %{SleepHrs}
*Script exec !VarMul SleepMinsMod 3600000
*Script exec !ifEval ("%{SleepHrs}" > "0") !varAdd SleepMins -%{SleepMinsMod}
*Script exec !varDiv SleepMins 60000
*Script exec !Varset SleepMinsMod2 %{SleepMSecs}
*Script exec !varMod SleepMinsMod2 60000
*Script exec !varAdd SleepMins -%{SleepMinsMod2}
*Script exec !Varset SleepSecs %{SleepMSecs}
*Script exec !ifEval ("%{SleepHrs}" > "0") !varAdd SleepSecs -%{SleepMinsMod}
*Script exec !Varset SleepSecsMod %{SleepMins}
*Script exec !VarMul SleepSecsMod 60000
*Script exec !varAdd SleepSecs -%{SleepMinsMod}
*Script exec !varDiv SleepSecs 1000
*Script exec !LabelSetText SleepCounter "%{SleepHrs}:%{SleepMins}:%{SleepSecs}"
*Script exec !Cycle
*Script goto end
*Script label Counter_End
*Script exec !LabelHide SleepPanel
*Script label end
*Script exec !Varset canceled 0
*Script exec !varset sleepstarted 0
*Script ~bang

*Script bang !Cycle
*Script exec !Shutdown_Sleep_Counter
*Script ~bang

*Script bang !Sleepdown_Cancel
*Script exec !TimerKill Sleep
*Script exec !LabelHide SleepPanel
*Script exec !Pause 2000
*Script exec !NetUnloadModule Timer-0.5
*Script exec !NetUnloadModule ByeWindows-0.4
*Script exec !LabelSetText Counter 10
*Script exec !Varset canceled 1
*Script ~bang


this is really begining to bug my ti*s.

cheers

John

Posted by member 302889 on 2006-10-09 19:26:37 link

actually, i've just noticed one error at the bottom of the !Shutdown_Sleep_Counter script.

should read...

*Script exec !Cycle
*Script goto end
*Script label Counter_End
*Script exec !LabelHide SleepPanel
*Script exec !Varset canceled 0
*Script exec !varset sleepstarted 0
*Script label end
*Script ~bang

Posted by member 302889 on 2006-10-09 19:33:07 link

i've deleted the !Cycle script now and changed the !Shutdown_Sleep_Counter script to this. It works better this way i think...

*Script bang !Shutdown_Sleep_Counter
*Script label start
*Script gotoif ("%{canceled}" = "1") end
*Script exec !Pause 1000
*Script exec !varAdd SleepMSecs -1000
*Script exec !Varset SleepHrs %{SleepMSecs}
*Script exec !varDiv SleepHrs 3600000
*Script exec !Varset SleepHrsMod %{SleepMSecs}
*Script exec !varMod SleepHrsMod 3600000
*Script exec !varAdd SleepHrs -%{SleepHrsMod}
*Script exec !Varset SleepMins %{SleepMSecs}
*Script exec !Varset SleepMinsMod %{SleepHrs}
*Script exec !VarMul SleepMinsMod 3600000
*Script exec !ifEval ("%{SleepHrs}" > "0") !varAdd SleepMins -%{SleepMinsMod}
*Script exec !varDiv SleepMins 60000
*Script exec !Varset SleepMinsMod2 %{SleepMSecs}
*Script exec !varMod SleepMinsMod2 60000
*Script exec !varAdd SleepMins -%{SleepMinsMod2}
*Script exec !Varset SleepSecs %{SleepMSecs}
*Script exec !ifEval ("%{SleepHrs}" > "0") !varAdd SleepSecs -%{SleepMinsMod}
*Script exec !Varset SleepSecsMod %{SleepMins}
*Script exec !VarMul SleepSecsMod 60000
*Script exec !varAdd SleepSecs -%{SleepMinsMod}
*Script exec !varDiv SleepSecs 1000
*Script exec !LabelSetText SleepCounter "%{SleepHrs}:%{SleepMins}:%{SleepSecs}"
*Script gotoif ("%{SleepMSecs}" => "0") Start
*Script label end
*Script exec !LabelHide SleepPanel
*Script exec !Varset canceled 0
*Script exec !varset sleepstarted 0
*Script ~bang

Posted by member 212670 on 2006-10-10 17:05:52 link

Have a look here. I made it with hours now. It's not pretty but it works. ;) (Lslua would be much better suited for this.)