Logo

[Help] How does the OptionsRow works ??

Register Log In Back To Forums

Post #1 · Posted at 2014-11-18 07:01:02pm 9.4 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"

Last updated: 2014-11-19 08:30pm
I have been working in add some "features" to my Theme, I have got nice results using for example the code ThemePrefs.Get for make a option where you can choose between the old LifeMeter bar and the Surround style from SL.. and of course more options too...

The problem I got making options with this method is that for example in that same case, the ThemePrefs.Get("SurroundLife") == "On" corresponding to the Surround Life, it makes a unique value that is saved on the ThemePrefs.ini, so that save SurroundLife=On or Off depending the choose I select, the value is used for both Players...

Thats why I have tried with no good results try to make a OptionRow where I can make values for each player, the case of the ProTiming that saves 2 files, ProTimingP1 and ProTimingP2.

In shorts words, I wanna try to make a simple and even with no direct results a OptionRow, just it appears on the ScreenPlayerOptions, with that at least I can start to experiment with it.

What I wanna get is using the SurroundLife ThemePref transform it to a UserPref, like that both players can choose a different option.

I hope you can understand with a need... Any help for start about this would be amazing ! Big Grin Sorry again for my English.
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #2 · Posted at 2014-11-18 07:53:56pm 9.4 years ago

Offline Kyzentun
Kyzentun Avatar Member
3,209 Posts
United States
Reg. 2008-02-20

"I'm honestly pissed off."
Make a function named "music_wheel_transform" in one of your lua files in Scripts/.
Then set the ItemTransformFunction metric to the name of that function.
Done.
silenttype01: Kyzentun is never harsh. He says it how it is.

GENERATION 24: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

Post #3 · Posted at 2014-11-20 04:08:28pm 9.4 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"

Last updated: 2014-11-20 04:08pm
Quote: Kyzentun
Make a function named "music_wheel_transform" in one of your lua files in Scripts/.
Then set the ItemTransformFunction metric to the name of that function.
Done.

I tried like 100 ways and nothing, you tell me something so easy and works at first .-.

Thanks anyway now it works

I need help about this... anyone know somethin about how to make a easy ThemePrefRow ??
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #4 · Posted at 2014-12-03 03:47:51pm 9.3 years ago

Offline dbk2
dbk2 Avatar Member
332 Posts
Not Set
Reg. 2012-04-30


Last updated: 2014-12-03 04:10pm
Quote: Th3_Ov3rHell_3XoduZ
Thats why I have tried with no good results try to make a OptionRow where I can make values for each player, the case of the ProTiming that saves 2 files, ProTimingP1 and ProTimingP2.

In shorts words, I wanna try to make a simple and even with no direct results a OptionRow, just it appears on the ScreenPlayerOptions, with that at least I can start to experiment with it.

What I wanna get is using the SurroundLife ThemePref transform it to a UserPref, like that both players can choose a different option

The ThemePrefs and ThemePrefsRow systems are best used for settings that apply to ALL players.

What you're describing (SurroundLife for one player, or the other, or both) would use an OptionRow.

You are lucky in that documentation on OptionRows now exists (thank Kyzentun!). When I was porting Simply Love, I had to figure it out on my own...

You can read Kyzentun's documentation here:
https://github.com/stepmania/stepmania/blob/master/Docs/Themerdocs/Examples/OptionRowHandlerLua.lua

If you want a mostly simple example of an OptionRow, look at the BackgroundFilter from my port of Simply Love.

There are a few parts to it:

1. The OptionRow is declared in Metrics.ini here

2. ...and the Metrics call a function which is defined here

3. ...that function has sub-functions. In the SaveSelections() function, each player's choice is saved to a custom Lua table that I made for Simply Love. I named the table SL and it is defined here.

4. ...The SL table is probably more complex than anything you'll need. The important part is you have some way to save PLAYER_1's choice and PLAYER_2's choice in some kind of table.

5. ...the LoadSelections() function uses a helper function FindInTable() that I defined here. Feel free to use it.

6. Finally, you need to do something with the player's choice. For BackgroundFilters in Simply Love, I retrieved the values on ScreenGameplay underlay like this and drew the filter with different opacities. Your SurroundLifebar will be similar; you'll probably want to put it in ScreenGameplay underlay...

Hopefully this gets you started.

Post #5 · Posted at 2014-12-03 09:13:39pm 9.3 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"

Last updated: 2014-12-03 09:26pm
Quote: dbk2
Quote: Th3_Ov3rHell_3XoduZ
Thats why I have tried with no good results try to make a OptionRow where I can make values for each player, the case of the ProTiming that saves 2 files, ProTimingP1 and ProTimingP2.

In shorts words, I wanna try to make a simple and even with no direct results a OptionRow, just it appears on the ScreenPlayerOptions, with that at least I can start to experiment with it.

What I wanna get is using the SurroundLife ThemePref transform it to a UserPref, like that both players can choose a different option

The ThemePrefs and ThemePrefsRow systems are best used for settings that apply to ALL players.

What you're describing (SurroundLife for one player, or the other, or both) would use an OptionRow.

You are lucky in that documentation on OptionRows now exists (thank Kyzentun!). When I was porting Simply Love, I had to figure it out on my own...

You can read Kyzentun's documentation here:
https://github.com/stepmania/stepmania/blob/master/Docs/Themerdocs/Examples/OptionRowHandlerLua.lua

If you want a mostly simple example of an OptionRow, look at the BackgroundFilter from my port of Simply Love.

There are a few parts to it:

1. The OptionRow is declared in Metrics.ini here

2. ...and the Metrics call a function which is defined here

3. ...that function has sub-functions. In the SaveSelections() function, each player's choice is saved to a custom Lua table that I made for Simply Love. I named the table SL and it is defined here.

4. ...The SL table is probably more complex than anything you'll need. The important part is you have some way to save PLAYER_1's choice and PLAYER_2's choice in some kind of table.

5. ...the LoadSelections() function uses a helper function FindInTable() that I defined here. Feel free to use it.

6. Finally, you need to do something with the player's choice. For BackgroundFilters in Simply Love, I retrieved the values on ScreenGameplay underlay like this and drew the filter with different opacities. Your SurroundLifebar will be similar; you'll probably want to put it in ScreenGameplay underlay...

Hopefully this gets your started.

Wow that's a lot I have to learn, but will helps a lot... Thanks you dbk2... Im gonna start to learn right know Big Grin

___________________________________________________________________________________________________

Well nevermind, I figure out why shows that error, now If I enters to the PlayerOptions I can see the OptionRow, the problem is when I try to use it... for example, the OptionRow has two values, Red and Blue... I tryied to use it on the LifeBar, this is in Metrics.ini but I move it to LUA Script likes this:

[ScreenGameplay]

LifeP1X=SurroundLifeP1X()
LifeP1Y=SurroundLifeY()
LifeP1OnCommand=%SurroundLifeOnCommand
LifeP1OffCommand=

And %SurroundLifeOnCommand corresponding to this:

function SurroundLifeOnCommand(self) self:diffuse( GetLifeColor() ) self:draworder(-1) self:rotationz(-90) self:zoomy(1.1) end

that one is in a Script file. the command diffuse call that function GetLifeColor(), that one is this:

function GetLifeColor()
pName = pname(Player)
local gColor

local lColor = SL[pName].ActiveModifiers.LifeColor
if lColor == "Blue" then
gColor = color("#0000FF")
elseif lColor == "Red" then
gColor = color("#FF0000")
end
end

I dont know, why it show this error: (This is harder than I thought)

http://fc07.deviantart.net/fs70/f/2014/337/f/2/untitled_by_ov3rhell3xoduz-d88knqv.png
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #6 · Posted at 2014-12-04 12:17:53am 9.3 years ago

Offline Kyzentun
Kyzentun Avatar Member
3,209 Posts
United States
Reg. 2008-02-20

"I'm honestly pissed off."

Last updated: 2014-12-04 12:18am
Quote: dbk2
If I were to rewrite that today, I'd use "lua.ReportScriptError" instead of "Trace", so the feedback messages could show up on screen.

Quote: Th3_Ov3rHell_3XoduZ
pName = pname(Player)
"Player" is the name of one of the classes in Stepmania. pname is a function that must be passed a PlayerNumber enum value (PLAYER_1 or PLAYER_2). Thus, when that line of code runs, it passes pname the class (which is internally a table, we call it a class to express how it's used), and pname throws an error because you didn't pass it a PlayerNumber enum value.

In general, try to avoid using the names of things that are built into Stepmania when naming your own variables. It's a source of confusion and general problems.
silenttype01: Kyzentun is never harsh. He says it how it is.

GENERATION 24: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
Register Log In Back To Forums

0 User(s) Viewing This Thread (Past 15 Minutes)

©2006-2024 Zenius -I- vanisher.com -5th style- IIPrivacy Policy
Web Server: 6% · Database: 4% · Server Time: 2024-04-19 14:36:51
This page took 0.006 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language