It is currently April 23rd, 2024, 6:44 am

[Solved] Procedural meters generation?

Get help with creating, editing & fixing problems with skins
MikeG621
Posts: 87
Joined: March 18th, 2013, 1:59 pm

Re: Procedural meters generation?

Post by MikeG621 »

SilverAzide wrote:The trick is to create your skin with all the meters you need in advance.
Not necessarily. My notes skin (heavily modified Enigma) procedurally generates the meters it needs within the Lua code. If I decide I want more tabs, I change the total and if the meters don't exist then Lua creates them. When my skin is "empty", there's only 2 meters. First run with 3 tabs and now the skin has 11 meters. I don't delete anything when I reduce the count though, the unused meters just sit there.

When using the !WriteKeyValue bang, if the key doesn't exist it's created. So you can create the key name with a counter and increment it within the code. This is one portion of my loop for one of the meters that's created from scratch (Note#.Label.Outside).

Code: Select all

local meter = _prefix..'Note'..i..'.Label.'
SKIN:Bang('!WriteKeyValue', meter..'Outside', 'Meter', 'Image')
SKIN:Bang('!WriteKeyValue', meter..'Outside', 'MeterStyle', 'Styles.LabelUnselectedOutside')
SKIN:Bang('!WriteKeyValue', meter..'Outside', 'X', '(['.._prefix..'Label:X]-(#*CurrentNote*#-'..i..'+1)*#*LabelShift*#-2+(['.._prefix..'Note'..i..'.State] = 2 ? (['.._prefix..'Label.Top:W]+11) : 0))')
SKIN:Bang('!WriteKeyValue', meter..'Outside', 'Y', '(['.._prefix..'Label.Top:Y]+6)')
SKIN:Bang('!WriteKeyValue', meter..'Outside', 'DynamicVariables', '1')
SKIN:GetMeter(meter..'Outside'):Show()
But like the others said, it's up to you. If you're doing it once, not sure if it's worth the effort when copy/paste can be pretty fast. If you're expecting to by dynamically changing the meters a lot, then maybe it is.
User avatar
MetalTxus
Posts: 46
Joined: October 19th, 2016, 9:03 pm
Location: Spain

Re: Procedural meters generation?

Post by MetalTxus »

For anyone interested: I haven't solved the issue but I've implemented a workaround.

For my current needs, which is drawing a grid of y rows and x cols, I've settled to procedurally generate 50 cells outside the skin, paste them inside and set the ones I won't be using to H = W = 0. It will obviously crash whenever a bigger value is set but there's no real solution to that issue.

I don't like wasting memory but I've found no other way to draw on screen as many entries as defined by the user in any other way that doesn't require much more effort than its worth it. I appreciate everyone's suggestions but as you yourselves said, it's probably not worth it.
Image
• GitHub | • DeviantArt
OS: W10 x64 / GPU: GTX 1050 Ti / CPU: i3-4160 / RAM: 8GB