lua help Thread last updated on 2008-03-25 07:24:03

Posted by member 305666 on 2008-03-24 21:22:40

Hello,

I'm making a new theme, and for a really long time I've wanted to emulate the "dynamo" effect that fractal.design has used in a few of his themes.

The effect can best be described as an icon with a duplicate on top of it, and when you click it, the duplicate grows and fades out in a smooth continuous motion, leaving the original.

Upon examination fractal's themes, i found that he was doing this in lua. Me being such a n00b in lua (understatement, i can't read it at all), I have no idea how to implement his script or how in the world its being called or importing variables, so I attempted to recreate this effect with mzscript.

I was successful in doing so, but it doesn't always work as smooth as it should, and I would like to know how I can take the code from fractal's themes and plug it into my own.

Here's how I did it with mzscript:

Theme.rc settings:
*Label Panel1
Panel1X 85
Panel1Y -60
Panel1Width 242
Panel1Height 55
Panel1PaintingMode ".image"
Panel1Image QPanel.png
Panel1StartHidden True
Panel1Alwaysontop True
Panel1BehindWindow xlabel icon1_ghost
Panel1OnLeave !Panel1Hide

*Label Icon1
*panel1modulehook !labellsboxhook Icon1
Icon1X 10
Icon1Y 4
Icon1Width 32
Icon1Height 32
Icon1Paintingmode ".image"
Icon1Image "$lsimagefolder$icons\Video1.png"
Icon1AlwaysOntop true

*Label Icon1_Ghost
*Icon1_Ghostdockedto panel1
Icon1_Ghostx 95
Icon1_Ghosty -56
Icon1_Ghostwidth 32
Icon1_Ghostheight 32
Icon1_Ghostpaintingmode ".image"
Icon1_Ghostimage "$lsimagefolder$icons\Video2.png"
Icon1_GhostAlwaysOnTop true
Icon1_GhostBehindWindow xlabel MainBar
Icon1_Ghostalphamap true
;Icon1_Ghoststarthidden true
Icon1_Ghostonleftclick !Icon1_GhostBang
Icon1_GhostAlphafade true
Icon1_GhostCustomalphafade 40 20


Script.rc Settings:
*script bang !Icon1_GhostBang
*script exec !labelrefresh Icon1_Ghost Icon1_Ghostimage "$lsimagefolder$icons\Video3.png"
*script exec !LabelRepositionBy Icon1_Ghost -8 -8 16 16 4 10
*script exec !LabelHide Icon1_Ghost
*script exec "$MediaPlayer$"
*script ~bang



This is how fractal does it with lua:
[code]
function misc.dynamo (labelname, labelimage, parentlabelname, superparentlabelname)-- parent and superparent cater for hooking, as the currentx of a hooked label is relative to the parent and the parent to the "superparent" etc
if evar.dynamo == "true" then
if parentlabelname == nil then
evar.dynamox = evar[labelname.."currentx"]
evar.dynamoy = evar[labelname.."currenty"]

else
if superparentlabelname == nil then
evar.dynamox = evar[parentlabelname.."currentx"] + evar[labelname.."currentx"]
evar.dynamoy = evar[parentlabelname.."currenty"] + evar[labelname.."currenty"]

else
evar.dynamox = evar[superparentlabelname.."currentx"] + evar[parentlabelname.."currentx"] + evar[labelname.."currentx"]
evar.dynamoy = evar[superparentlabelname.."currenty"] + evar[parentlabelname.."currenty"] + evar[labelname.."currenty"]

end
end

if tonumber(evar.dynamomax) < 16 then evar.dynamomax = 16 end-- they should just turn it off if the want lower. And this keeps the math for the popup good.
if tonumber(evar[labelname.."currentwidth"])

Posted by member 305666 on 2008-03-24 21:26:03 link

Hrmm, that last bit of code was cut off and i can't edit for some reason...

This is how fractal does it with lua:

[code]function misc.dynamo (labelname, labelimage, parentlabelname, superparentlabelname)-- parent and superparent cater for hooking, as the currentx of a hooked label is relative to the parent and the parent to the "superparent" etc
if evar.dynamo == "true" then
if parentlabelname == nil then
evar.dynamox = evar[labelname.."currentx"]
evar.dynamoy = evar[labelname.."currenty"]

else
if superparentlabelname == nil then
evar.dynamox = evar[parentlabelname.."currentx"] + evar[labelname.."currentx"]
evar.dynamoy = evar[parentlabelname.."currenty"] + evar[labelname.."currenty"]

else
evar.dynamox = evar[superparentlabelname.."currentx"] + evar[parentlabelname.."currentx"] + evar[labelname.."currentx"]
evar.dynamoy = evar[superparentlabelname.."currenty"] + evar[parentlabelname.."currenty"] + evar[labelname.."currenty"]

end
end

if tonumber(evar.dynamomax) < 16 then evar.dynamomax = 16 end-- they should just turn it off if the want lower. And this keeps the math for the popup good.
if tonumber(evar[labelname.."currentwidth"])

Posted by member 305666 on 2008-03-24 21:28:33 link

wtf... lua breaks these forums lol. you can find the config for that in fractal's iconifuckation theme btw.

Posted by member 1 on 2008-03-25 07:24:03 link

yea...all those brackets make the forum unhappy.