Post #1 · Posted at 2017-09-16 03:52:57pm 6.6 years ago
leadbman | |
---|---|
Member | |
263 Posts | |
Reg. 2016-02-01 | |
"Working On: 5thMix BGA bgchanges" |
Hi all,
Long time no post! Been a bit busy with life outside Stepmania/DDR lately unfortunately =/ Hope you've all been well.
I've got a question for the theme creators out there - is there a way to set the current noteskin? With the theme I'm creating, everything currently changes per the song you're playing (it does take into account missing files/it does revert back to the originally selected preferences (mostly)).
TL:DR - If I select a song, I'd like to be able to change the arrows used for the song. For example, if I select a DDR Solo 2000 song, I'd like it to change the noteskin to the solo noteskin.
Part of my code is shown below, with the bold section being what I'm trying to figure out:
I don't think this is the correct syntax or method to do this, this is what I'd like help with. From what I can tell I think SM5 calls the noteskin from the profile, which is why I've used PROFILEMAN. Right now the noteskin doesn't change at all so obviously I'm either using the wrong call or I've got my syntax wrong - hence this thread.
Can anyone help me out? I know that this is a bit of a random idea but if I could get it to work that'd really finish off my theme well.
Long time no post! Been a bit busy with life outside Stepmania/DDR lately unfortunately =/ Hope you've all been well.
I've got a question for the theme creators out there - is there a way to set the current noteskin? With the theme I'm creating, everything currently changes per the song you're playing (it does take into account missing files/it does revert back to the originally selected preferences (mostly)).
TL:DR - If I select a song, I'd like to be able to change the arrows used for the song. For example, if I select a DDR Solo 2000 song, I'd like it to change the noteskin to the solo noteskin.
Part of my code is shown below, with the bold section being what I'm trying to figure out:
Quote
local song = GAMESTATE:GetCurrentSong();
local songgroup = song:GetGroupName();
if songgroup:find("ddrs2000ac") then
ANNOUNCER:SetCurrentAnnouncer("Solo");
PROFILEMAN:set_preferred_noteskin("dance","solo")
local songgroup = song:GetGroupName();
if songgroup:find("ddrs2000ac") then
ANNOUNCER:SetCurrentAnnouncer("Solo");
PROFILEMAN:set_preferred_noteskin("dance","solo")
I don't think this is the correct syntax or method to do this, this is what I'd like help with. From what I can tell I think SM5 calls the noteskin from the profile, which is why I've used PROFILEMAN. Right now the noteskin doesn't change at all so obviously I'm either using the wrong call or I've got my syntax wrong - hence this thread.
Can anyone help me out? I know that this is a bit of a random idea but if I could get it to work that'd really finish off my theme well.
Post #2 · Posted at 2017-09-16 07:13:56pm 6.6 years ago
Jousway | |
---|---|
Member | |
137 Posts | |
Reg. 2011-07-12 | |
"Noteskins !== Quality " |
GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("solo")
GAMESTATE:GetPlayerState(PLAYER_2):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("solo")
like this
Post #3 · Posted at 2017-09-17 12:20:20am 6.6 years ago
Daniel_BMS | |
---|---|
Member+ | |
645 Posts | |
Reg. 2007-09-01 | |
Can you give me an example with an individual song? I would love to be able to do this too. Not sure it is possible.
Post #4 · Posted at 2017-09-17 03:25:03am 6.6 years ago
leadbman | |
---|---|
Member | |
263 Posts | |
Reg. 2016-02-01 | |
"Working On: 5thMix BGA bgchanges" |
Quote: Jousway
GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("solo")
GAMESTATE:GetPlayerState(PLAYER_2):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("solo")
like this
Thanks for that! I'll give it a go shortly.
Quote: Daniel_BMS
Can you give me an example with an individual song? I would love to be able to do this too. Not sure it is possible.
I can help you out, sure. What are you trying to achieve? Just the noteskin swap?
Post #5 · Posted at 2017-09-17 04:07:47am 6.6 years ago
Daniel_BMS | |
---|---|
Member+ | |
645 Posts | |
Reg. 2007-09-01 | |
Yes, can you give me the code using the example of an individual song with a noteskin. Like say you want USWdefault9SM5 to come up when Butterfly is selected.
Post #6 · Posted at 2017-09-17 01:03:05pm 6.6 years ago
leadbman | |
---|---|
Member | |
263 Posts | |
Reg. 2016-02-01 | |
"Working On: 5thMix BGA bgchanges" |
Last updated: 2017-09-17 01:30pm
So this works absolutely perfectly! Thanks Jousway! You are a legend!
In your case Daniel, if you're only targeting a single song, you could do something like this within the ScreenGameplay in folders lua:
I'm doing my changes on the song wheel itself, but it's a similar idea, using:
This lets us make the changes using a function on song change. So your code might look like:
Obviously this is simplified and a lot of my code has been stripped out as you're not doing the same functions I am, but hopefully this helps/gets you started. For me, instead of targeting a single song, I'm targeting an entire folder. To get the folder of a song, you can use:
The only issue you may run into while doing this is if someone else uses your theme, as the song folders can vary greatly in name, so to can song titles which may cause issues.
But in my experience, since I'm purely making my theme for me (as to be honest, it's hitting the 3gb mark and I doubt I'll ever put it up, though I will probably put up the bones of it one day without so much of the media I've got in it for people to get character select screens working etc) but if it's just for you, this should work fine.
Edit: One more thing I should add, have a look here http://ec2.stepmania.com/wiki/Lua_scripting_and_Actor_commands to see what sort of things you can do within the realms of lua in SM5. It's pretty interesting to check out and could prove pretty helpful if you get stuck. It's not exhaustive by any means, but it's a good thing to read through to get some more understanding with regards to SM5 lua work.
Also, check out dbk2's lua stuff here - http://dguzek.github.io/Lua-For-SM5/ this has been an invaluable resource for me as I've been learning.
Read through the stepmania github source files too (https://github.com/stepmania/stepmania/tree/master/src) while they might not explain what's going on, you can at least find the correct code calls or find out if what you want to do can work (trust me, even if you think it's impossible, there are either people on here who can help or you can work out a way over time). Looking through files like song.cpp for example, can show you all the calls to find out anything about a song. While it's a crude way to go, it's really handy to find out if you're calling something incorrectly.
If there are any faults in my code I apologise, I just got home from work and I just quickly threw this together to give you some ideas. Any questions, feel free to ask.
In your case Daniel, if you're only targeting a single song, you could do something like this within the ScreenGameplay in folders lua:
Quote
local song = GAMESTATE:GetCurrentSong(); This gets the current song information.
if song:GetDisplayMainTitle() == "Butterfly" then Checks to see if the songs displayed title matches what you want.
GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("USWdefault9SM5")
GAMESTATE:GetPlayerState(PLAYER_2):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("USWdefault9SM5")
else
Not doing anything here but you could choose to change the arrow type to something else for any other track.
end
if song:GetDisplayMainTitle() == "Butterfly" then Checks to see if the songs displayed title matches what you want.
GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("USWdefault9SM5")
GAMESTATE:GetPlayerState(PLAYER_2):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("USWdefault9SM5")
else
Not doing anything here but you could choose to change the arrow type to something else for any other track.
end
I'm doing my changes on the song wheel itself, but it's a similar idea, using:
Quote
CurrentSongChangedMessageCommand=cmd(playcommand,"Set");
This lets us make the changes using a function on song change. So your code might look like:
Quote
t[#t+1] = Def.ActorFrame {
CurrentSongChangedMessageCommand=cmd(playcommand,"Set"); This makes the function "Set" run each time you move the cursor along on the song wheel.
SetCommand=function(self) Here's where the function starts.
local song = GAMESTATE:GetCurrentSong(); This gets the current song information.
if song:GetDisplayMainTitle() == "Butterfly" then Checks to see if the songs displayed title matches what you want.
GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("USWdefault9SM5")
GAMESTATE:GetPlayerState(PLAYER_2):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("USWdefault9SM5")
else
Not doing anything here but you could choose to change the arrow type to something else for any other track.
end
end
}
CurrentSongChangedMessageCommand=cmd(playcommand,"Set"); This makes the function "Set" run each time you move the cursor along on the song wheel.
SetCommand=function(self) Here's where the function starts.
local song = GAMESTATE:GetCurrentSong(); This gets the current song information.
if song:GetDisplayMainTitle() == "Butterfly" then Checks to see if the songs displayed title matches what you want.
GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("USWdefault9SM5")
GAMESTATE:GetPlayerState(PLAYER_2):GetPlayerOptions('ModsLevel_Preferred'):NoteSkin("USWdefault9SM5")
else
Not doing anything here but you could choose to change the arrow type to something else for any other track.
end
end
}
Obviously this is simplified and a lot of my code has been stripped out as you're not doing the same functions I am, but hopefully this helps/gets you started. For me, instead of targeting a single song, I'm targeting an entire folder. To get the folder of a song, you can use:
Quote
local song = GAMESTATE:GetCurrentSong(); This gets the current song information.
local songgroup = song:GetGroupName(); This gets the song group information (The folder from the Songs folder).
We can use this information like this:
if songgroup == "DDR" then
Which will change things for any song falling under the "DDR" group/folder.
local songgroup = song:GetGroupName(); This gets the song group information (The folder from the Songs folder).
We can use this information like this:
if songgroup == "DDR" then
Which will change things for any song falling under the "DDR" group/folder.
The only issue you may run into while doing this is if someone else uses your theme, as the song folders can vary greatly in name, so to can song titles which may cause issues.
But in my experience, since I'm purely making my theme for me (as to be honest, it's hitting the 3gb mark and I doubt I'll ever put it up, though I will probably put up the bones of it one day without so much of the media I've got in it for people to get character select screens working etc) but if it's just for you, this should work fine.
Edit: One more thing I should add, have a look here http://ec2.stepmania.com/wiki/Lua_scripting_and_Actor_commands to see what sort of things you can do within the realms of lua in SM5. It's pretty interesting to check out and could prove pretty helpful if you get stuck. It's not exhaustive by any means, but it's a good thing to read through to get some more understanding with regards to SM5 lua work.
Also, check out dbk2's lua stuff here - http://dguzek.github.io/Lua-For-SM5/ this has been an invaluable resource for me as I've been learning.
Read through the stepmania github source files too (https://github.com/stepmania/stepmania/tree/master/src) while they might not explain what's going on, you can at least find the correct code calls or find out if what you want to do can work (trust me, even if you think it's impossible, there are either people on here who can help or you can work out a way over time). Looking through files like song.cpp for example, can show you all the calls to find out anything about a song. While it's a crude way to go, it's really handy to find out if you're calling something incorrectly.
If there are any faults in my code I apologise, I just got home from work and I just quickly threw this together to give you some ideas. Any questions, feel free to ask.
Post #7 · Posted at 2017-09-17 02:46:39pm 6.6 years ago
razorblade | |
---|---|
Member | |
1,099 Posts | |
Not Set | |
Reg. 2011-03-01 | |
There is actually an alternative for setting your noteskins and you should use it instead of Jousway's suggestion because GetPlayerOptions will no longer work in next official build after 5.0.12 and you'll end updating your codes to make them work again. It's through the use of PlayerOptionsString that is still available in future builds (the new SM 5.1). The old SM5.1 that has some new system will be moved to 5.2.
Post #8 · Posted at 2017-09-17 03:36:43pm 6.6 years ago
leadbman | |
---|---|
Member | |
263 Posts | |
Reg. 2016-02-01 | |
"Working On: 5thMix BGA bgchanges" |
Quote: razorblade
There is actually an alternative for setting your noteskins and you should use it instead of Jousway's suggestion because GetPlayerOptions will no longer work in next official build after 5.0.12 and you'll end updating your codes to make them work again. It's through the use of PlayerOptionsString that is still available in future builds (the new SM 5.1). The old SM5.1 that has some new system will be moved to 5.2.
Thanks for letting me know, I was unaware of the upcoming change. How do you use the PlayerOptionsString? Would it work within the current version of SM5? Is there any documentation I could read up on?
Post #9 · Posted at 2017-09-17 03:42:59pm 6.6 years ago
dbk2 | |
---|---|
Member | |
332 Posts | |
Not Set | |
Reg. 2012-04-30 | |
Quote: razorblade
next official build after 5.0.12
I don't believe there are any official builds planned at this time. SM5 is effectively in stasis for the time being.Post #10 · Posted at 2017-09-17 03:47:37pm 6.6 years ago
leadbman | |
---|---|
Member | |
263 Posts | |
Reg. 2016-02-01 | |
"Working On: 5thMix BGA bgchanges" |
Quote: dbk2
Quote: razorblade
next official build after 5.0.12
I don't believe there are any official builds planned at this time. SM5 is effectively in stasis for the time being.That's what I had assumed, though I would be interested in future proofing the build, just in case. Hello there by the way!
Post #11 · Posted at 2017-09-18 12:33:21am 6.6 years ago
FlameyBoy | |
---|---|
Member | |
335 Posts | |
Reg. 2011-03-09 | |
5.1 will come out eventually. It is being worked on, just very slowly...
Post #12 · Posted at 2017-09-18 09:08:16am 6.6 years ago
Quote: leadbman
Quote: razorblade
There is actually an alternative for setting your noteskins and you should use it instead of Jousway's suggestion because GetPlayerOptions will no longer work in next official build after 5.0.12 and you'll end updating your codes to make them work again. It's through the use of PlayerOptionsString that is still available in future builds (the new SM 5.1). The old SM5.1 that has some new system will be moved to 5.2.
Thanks for letting me know, I was unaware of the upcoming change. How do you use the PlayerOptionsString? Would it work within the current version of SM5? Is there any documentation I could read up on?
> checks commits
https://github.com/stepmania/stepmania/commit/0d9b024a3264b23bba545cfbc2928525b8d80f98
Quote
Turn on defective mode when GetPlayerOptionsArray and GetPlayerOptionsString are used because they're also deprecated and used in some simfiles.
and GetPlayerOptions seems to still exists just fine
Post #13 · Posted at 2017-09-18 09:29:53am 6.6 years ago
razorblade | |
---|---|
Member | |
1,099 Posts | |
Not Set | |
Reg. 2011-03-01 | |
GetPlayerOptions is different from GetPlayerOptionsString.
Post #14 · Posted at 2017-09-18 09:40:00am 6.6 years ago
Jousway | |
---|---|
Member | |
137 Posts | |
Reg. 2011-07-12 | |
"Noteskins !== Quality " |
Quote: razorblade
GetPlayerOptions is different from GetPlayerOptionsString.
you dont sayQuote: razorblade
It's through the use of PlayerOptionsString that is still available in future builds (the new SM 5.1). The old SM5.1 that has some new system will be moved to 5.2.
Post #15 · Posted at 2017-09-18 09:46:00am 6.6 years ago
Here is what I did to custom-set NoteSkins using PlayerState's GetPlayerOptionsString:
https://codepaste.net/trg6mq
I mentioned that GetPlayerOptions (as what you suggested earlier) doesn't work in past 5.0.12. I suggested him to use GetPlayerOptionsString instead (PlayerOptionsString before, typo)
https://codepaste.net/trg6mq
Quote: Jousway
Quote: razorblade
GetPlayerOptions is different from GetPlayerOptionsString.
you dont sayQuote: razorblade
It's through the use of PlayerOptionsString that is still available in future builds (the new SM 5.1). The old SM5.1 that has some new system will be moved to 5.2.
I mentioned that GetPlayerOptions (as what you suggested earlier) doesn't work in past 5.0.12. I suggested him to use GetPlayerOptionsString instead (PlayerOptionsString before, typo)
Post #16 · Posted at 2017-09-18 09:48:13am 6.6 years ago
Quote: razorblade
Here is what I did to custom-set NoteSkins using PlayerState's GetPlayerOptionsString:
https://codepaste.net/trg6mq
I mentioned that GetPlayerOptions (as what you suggested earlier) doen't work in past 5.0.12. i suggested to GetPlayerOptionsString (PlayerOptionsString before)
https://codepaste.net/trg6mq
Quote: Jousway
Quote: razorblade
GetPlayerOptions is different from GetPlayerOptionsString.
you dont sayQuote: razorblade
It's through the use of PlayerOptionsString that is still available in future builds (the new SM 5.1). The old SM5.1 that has some new system will be moved to 5.2.
I mentioned that GetPlayerOptions (as what you suggested earlier) doen't work in past 5.0.12. i suggested to GetPlayerOptionsString (PlayerOptionsString before)
1) GetPlayerOptionsString is the one thats being removed
2) Its prob being removed because if you want to add stuff to the string you have to add the old string first resulting in "x1, default, overhead, c400, delta, distance" for example, and if you have it in your update command, may god have mercy on your soul
3) https://github.com/stepmania/stepmania/blob/5_1-new/src/PlayerState.cpp#L243-L248 its right there
Post #17 · Posted at 2017-09-18 10:04:11am 6.6 years ago
1) GetPlayerOptionsString is the one thats being removed
You are referring to master branch (a.k.a. 5.2).
I'm referring to 5.1-new branch which is past 5.0.12 that didn't have the new notefield and noteskins system.
You are referring to master branch (a.k.a. 5.2).
I'm referring to 5.1-new branch which is past 5.0.12 that didn't have the new notefield and noteskins system.
Post #18 · Posted at 2017-09-18 11:21:36am 6.6 years ago
Jousway | |
---|---|
Member | |
137 Posts | |
Reg. 2011-07-12 | |
"Noteskins !== Quality " |
I dont see anywere anything about removing getplayeroptions can you give source to your statements?
Post #19 · Posted at 2017-09-18 12:24:51pm 6.6 years ago
razorblade | |
---|---|
Member | |
1,099 Posts | |
Not Set | |
Reg. 2011-03-01 | |
I didn't look at the source. At one point i was surprised that the function I used for a long time in my themes didn't work anymore, asked Kyzentun about that and he suggested me to use GetPlayerOptionsString instead.
Post #20 · Posted at 2017-09-18 02:42:14pm 6.6 years ago
Kyzentun | |
---|---|
Member | |
3,209 Posts | |
Reg. 2008-02-20 | |
"I'm honestly pissed off." |
Quote: razorblade
I didn't look at the source. At one point i was surprised that the function I used for a long time in my themes didn't work anymore, asked Kyzentun about that and he suggested me to use GetPlayerOptionsString instead.
That was probably back in 2014, before GetPlayerOptions was added. Since it's not in my IRC logs, or google site search of ziv, it was probably in the removed chat.Over the years, there have been at least three variants of bugs related to the Get/SetPlayerOptionsString (and similar) functions clearing the noteskin field and causing a crash or resetting it to detault or just squashing what the player meant to set it to for this song.
(related: Go make a noteskin named "drunk" and try setting it. Try with both GetPlayerOptionsString and with GetPlayerOptions)
(also related: Spaces in noteskin names run afoul of the mod string parsing.)
GetPlayerOptions gives you an object you can use to access individual parts, get their current values, and set them to specific values. GetPlayerOptionsString goes through the PlayerOptions data structure and crams it all into a string (except for things at default values). SetPlayerOptionsString then has to parse it all out. All that extra work is a waste when only one thing needs to be done.
As for anyone wondering why leadbman's first post had "PROFILEMAN:set_preferred_noteskin", well, that's closer to the right way to do it on the current master branch. Noteskin has been moved out of the PlayerOptions structure into the profile. "PROFILEMAN:GetProfile(pn):set_preferred_noteskin(player_skin)" is the way to set the noteskin that will be used, if it is called before gameplay starts.
The profile keeps a list of preferred noteskins (any noteskin that has been set with set_preferred_noteskin), and set_preferred_noteskin bumps that noteskin to the top. Then when gameplay starts, it finds the top noteskin that works with the current stepstype and uses that. (there's also unprefer_noteskin, for bumping a skin out of the list)
If there isn't a fitting skin in the list, the alphabetically first skin that works is used.