It is currently August 17th, 2019, 9:53 pm

Move a skin by using a LUA Script!

Discuss the use of Lua in Script measures.
FlorianG
Posts: 20
Joined: September 18th, 2013, 11:31 am

Move a skin by using a LUA Script!

FlorianG » December 16th, 2013, 12:08 am

Hi there,

i tried to move a skin/config with a LUA script. With this script i can only move a meter along X and Y. is this possible to finished it?

Code: Select all

[Rainmeter]
Author=

[Variables]
scroll.step=60
dY=0

[LuaMain]
Measure=Script
ScriptFile="#CURRENTPATH#lua\\Main.lua"
UpdateDivider=-1

[MeasureMouseWheel]
Measure=Plugin
plugin=Plugins\MouseWheelCapture.dll
;Enabled=0 (by default)
MouseWheelAction=[!CommandMeasure "LuaMain" "MoveRX('MeterImage1',(%/-120)*#scroll.step#)"]
UpdateDivider=-1

[MeterMouseWheel]
MeasureName=MeasureMouseWheel
Meter=String
X=100
Y=100
W=800
H=50
SolidColor=0,0,0,255
MouseOverAction=[!SetOption MeasureMouseWheel Enabled 1][!UpdateMeasure MeasureMouseWheel]
MouseLeaveAction=[!SetOption MeasureMouseWheel Enabled 0][!UpdateMeasure MeasureMouseWheel]

[MeterImage1]
Meter=Image
ImageName=Avatar.png
X=4
Y=4
W=256
H=126
PreserveAspectRatio=1
DynamicVariables=1
LUA:

Code: Select all

function Initialize()
end

function MoveRX(meter, x)
	m = SKIN:GetMeter(meter)
	SKIN:Bang('!MoveMeter '..(m:GetX()+x)..' '..m:GetY()..' '..meter)
	SKIN:Bang('!UpdateMeter '..meter)
	SKIN:Bang('!Redraw')
end

function MoveRY(meter, y)
	m = SKIN:GetMeter(meter)
	SKIN:Bang('!MoveMeter '..m:GetX()..' '..(m:GetY()+y)..' '..meter)
	SKIN:Bang('!UpdateMeter '..meter)
	SKIN:Bang('!Redraw')
end

function Update()
	return 0
end
FlorianG
Posts: 20
Joined: September 18th, 2013, 11:31 am

Re: Move a skin by using a LUA Script!

FlorianG » December 18th, 2013, 10:19 pm

Nothing? i don't know enough about LUA to help by myself. Please anyone have hints for me?
User avatar
Mordasius
Posts: 1061
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Move a skin by using a LUA Script!

Mordasius » December 19th, 2013, 1:55 am

I've not heard of the MouseWheelCapture plugin before but don't see why you need to use a plugin and Lua script anyway.

Why not use the Mouse Wheel Scroll Options?

I think you'll find you can do all you want with MouseScroll Up/Down and !MoveMeter bangs in an Image Meter.
FlorianG
Posts: 20
Joined: September 18th, 2013, 11:31 am

Re: Move a skin by using a LUA Script!

FlorianG » December 19th, 2013, 11:32 pm

Mordasius wrote:I've not heard of the MouseWheelCapture plugin before but don't see why you need to use a plugin and Lua script anyway.

Why not use the Mouse Wheel Scroll Options?

I think you'll find you can do all you want with MouseScroll Up/Down and !MoveMeter bangs in an Image Meter.
Hi, thanks for reply... but can i move the whole skin with this bangs? i know about the mouse wheel scroll options but i think that's not what i am looking for. i don't want to move a skin only one time at the specific position, rather a few pixels if i use the mouse wheel. like a scrollbar! i try to explain this on a picture...

FlorianG
Posts: 20
Joined: September 18th, 2013, 11:31 am

Re: Move a skin by using a LUA Script!

FlorianG » December 21st, 2013, 11:06 pm

oh please, is there any way to do this? i tried the last few days some things, but nothing work for me... is this possible or not?
FlyingHyrax
Posts: 251
Joined: July 1st, 2011, 1:32 am
Location: US

Re: Move a skin by using a LUA Script!

FlyingHyrax » December 22nd, 2013, 2:29 am

My first impression is that this is perfectly doable. I'm out of time for the next 18 hours or so, but I'll try to work on it tomorrow afternoon and see if I can get a prototype working for you.

I haven't used that mouse scroll plugin before, so I'll try it with the native MouseScroll actions that Mordasius mentioned first. Those should be sufficient as we can just put the actions on the scrollbar meter. You shouldn't need a plugin and you probably won't even need any Lua.
Flying Hyrax on DeviantArt
User avatar
Dank420
Posts: 147
Joined: April 3rd, 2013, 1:04 am
Location: O-High-O

Re: Move a skin by using a LUA Script!

Dank420 » December 22nd, 2013, 3:54 am

Try this, not LUA but works

Code: Select all

[Rainmeter]
Update=1000
[Metadata]
Name=ScrollFish
Information=
Version=
License=
Author=Dank420
[Variables]
movedistance=15
Style=style1

[Style1]
Imagename=betafish4.png
W=175
[Style2]
Imagename=betafish5.png
w=175

[measurelength]
measure=calc
formula=#CURRENTCONFIGX#+#movedistance#
dynamicvariables=1

[fishMeter]
Meter=image
Meterstyle=#Style#
x=0
y=0
PreserveAspectRatio=1
Dynamicvariables=1
mousescrollupaction=[!setoption measurelength formula #"CURRENTCONFIGX"#+#movedistance#][!setvariable Style "Style1"][!Move [measurelength] #CURRENTCONFIGy#][!update]
mousescrolldownaction=[!setoption measurelength formula #"CURRENTCONFIGX"#-#movedistance#][!setvariable Style "Style2"][!Move [measurelength] #CURRENTCONFIGy#][!update]
You do not have the required permissions to view the files attached to this post.
User avatar
Mordasius
Posts: 1061
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Move a skin by using a LUA Script!

Mordasius » December 22nd, 2013, 4:14 am

Or you could use the code in one skin to move another skin (rather than move a meter that is in the same skin).

Save the following code as Slider.ini in the folder Skins\MoveAskin\Slider

Code: Select all

[Rainmeter]
OnRefreshAction=!ActivateConfig "MoveAskin\Box2Move" "Box.ini"

[Variables]
Xpos=90

[mXpos]
Measure=Calc
Formula=#Xpos# < 0 ? 0 : (#Xpos# > 180 ? 180 : #Xpos#)
OnChangeAction=!Move  (#CURRENTCONFIGX#+#Xpos#)  (#CURRENTCONFIGY#-100)  MoveAskin\Box2Move
DynamicVariables=1

[MtSlider]
Meter=Image
MouseScrollDownAction=[!SetVariable Xpos  (#Xpos#-5) ] [!Update]
MouseScrollUpAction=[!SetVariable Xpos  (#Xpos#+5) ] [!Update]
DynamicVariables=1
SolidColor=c4c2c3
W=200
H=20

[MtNublet]
Meter=Image
SolidColor=000000
X=[mXpos]
W=20
H=20
DynamicVariables=1
Save the following, or whatever it is you want to move, as Box.ini in the folder Skins\MoveAskin\Box2Move

Code: Select all

[Rainmeter]

[Box]
Meter=Image
H=40
W=40
SolidColor=ff9900
FlorianG
Posts: 20
Joined: September 18th, 2013, 11:31 am

Re: Move a skin by using a LUA Script!

FlorianG » December 22nd, 2013, 12:20 pm

wow, very nice... i will try it! Thanks!!! :)
FlorianG
Posts: 20
Joined: September 18th, 2013, 11:31 am

Re: Move a skin by using a LUA Script!

FlorianG » December 22nd, 2013, 1:35 pm

Mordasius wrote:Or you could use the code in one skin to move another skin (rather than move a meter that is in the same skin).

Save the following code as Slider.ini in the folder Skins\MoveAskin\Slider

Code: Select all

[Rainmeter]
OnRefreshAction=!ActivateConfig "MoveAskin\Box2Move" "Box.ini"

[Variables]
Xpos=90

[mXpos]
Measure=Calc
Formula=#Xpos# < 0 ? 0 : (#Xpos# > 180 ? 180 : #Xpos#)
OnChangeAction=!Move  (#CURRENTCONFIGX#+#Xpos#)  (#CURRENTCONFIGY#-100)  MoveAskin\Box2Move
DynamicVariables=1

[MtSlider]
Meter=Image
MouseScrollDownAction=[!SetVariable Xpos  (#Xpos#-5) ] [!Update]
MouseScrollUpAction=[!SetVariable Xpos  (#Xpos#+5) ] [!Update]
DynamicVariables=1
SolidColor=c4c2c3
W=200
H=20

[MtNublet]
Meter=Image
SolidColor=000000
X=[mXpos]
W=20
H=20
DynamicVariables=1
Save the following, or whatever it is you want to move, as Box.ini in the folder Skins\MoveAskin\Box2Move

Code: Select all

[Rainmeter]

[Box]
Meter=Image
H=40
W=40
SolidColor=ff9900
can i use the position of my active skin for this?

i have tried:

OnRefreshAction=[!WriteKeyValue #Title# X #CURRENTCONFIGX# "#@#Layout\Position.inc"][!WriteKeyValue #Title# Y #CURRENTCONFIGY# "#@#Layout\Position.inc"][!Update]

to set the position of this skin in a Position.inc file. it works, now i need to read this with the slider skin

Code: Select all

[Rainmeter]

[Variables]
@include1=#@#Layout\Position.inc
Xpos=90

[mXpos]
Measure=Calc
Formula=#Xpos# < 0 ? 0 : (#Xpos# > 180 ? 180 : #Xpos#)
OnChangeAction=!Move  (#CURRENTCONFIGX#+#Xpos#)  (#CURRENTCONFIGY#-100)  Windows_8\Panels\Firefox
DynamicVariables=1

[MtSlider]
Meter=Image
MouseScrollDownAction=[!SetVariable Xpos  (#Xpos#-5) ] [!Update]
MouseScrollUpAction=[!SetVariable Xpos  (#Xpos#+5) ] [!Update]
DynamicVariables=1
SolidColor=c4c2c3
W=200
H=20

[MtNublet]
Meter=Image
SolidColor=000000
X=[mXpos]
W=20
H=20
DynamicVariables=1
btw, this helps me alot to solved this!! Thanks again!