Logo

[SM5] Get Difficulty Within ScreenGameplay?

Register Log In Back To Forums

Post #1 · Posted at 2017-09-20 11:36:50pm 6.5 years ago

Offline leadbman
leadbman Avatar Member
263 Posts
Australia
Reg. 2016-02-01

"Working On: 5thMix BGA bgchanges"
Hi all,

Just wondering how I can find out the difficulty of the song currently being played? I'd like to adjust some decorations if the difficulty is Challenge and I can't seem to work out how to check if the current difficulty is challenge.

Hope someone can help, thanks in advance!
https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #2 · Posted at 2017-09-20 11:57:24pm 6.5 years ago

Offline ZTS
ZTS Avatar Member
139 Posts
Not Set
Reg. 2015-01-13

"But enough talk! Have at you!"

Last updated: 2017-09-20 11:59pm
Please check the lua docs. https://dguzek.github.io/Lua-For-SM5/API/Lua.xml#GameState

GAMESTATE:GetCurrentSteps(pn):GetDifficulty() will return the difficulty. https://dguzek.github.io/Lua-For-SM5/API/Lua.xml#ENUM_Difficulty

Substituting pn for the player you want.
Get Rave It Out! https://sites.google.com/view/riodevs/home
Want your theme made? I take commissions, PM for details.

Post #3 · Posted at 2017-09-20 11:59:36pm 6.5 years ago

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


Last updated: 2017-09-21 12:00am
EDIT: Oops, sniped by ZTS. Oh well.

I could just hand you the code to make this happen, but it's probably better to guide you to the solution.

1. Do you know how to use StepMania's Lua.xml API?

2. What is "the current difficulty" an attribute of? By which I mean, is difficulty an attribute of a player? Is difficulty an attribute of a song?

If you respond to these questions, I can try to help you from there.

Post #4 · Posted at 2017-09-21 12:25:42am 6.5 years ago

Offline leadbman
leadbman Avatar Member
263 Posts
Australia
Reg. 2016-02-01

"Working On: 5thMix BGA bgchanges"
Thanks for the responses guys, I already have code for it, but it wasn't working. I should have included it within my original post.

Quote
local steps = GAMESTATE:GetCurrentSteps();
local difficulty = steps:GetDifficulty()

I'm not sure how to use the enums to get what I'm after. Could I say:

Quote
local steps = GAMESTATE:GetCurrentSteps();
local difficulty = steps:GetDifficulty("4")

Or should I be saying:

Quote
local steps = GAMESTATE:GetCurrentSteps();
local difficulty = steps:GetDifficulty("Difficulty_Challenge")

I knew what I was going for and I already worked out the appropriate calls, I should have explained myself a bit better in the first post as I was just after how I can use the enum to work it out. I'm not as fluent on how to use enums as I am with other parts of lua coding.

Actually I might need to use GetHardestStepsDifficulty() in this case as I would want to apply the code for the whole screen if the hardest difficulty is challenge.

Can someone explain how I can use the enum values? You don't have to give me the code, but it'd be great if you could explain how to use the enums within the code as that's where I'm getting lost.

Thanks again.
https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #5 · Posted at 2017-09-21 01:08:28am 6.5 years ago

Offline razorblade
razorblade Avatar Member
1,099 Posts
Not Set
Reg. 2011-03-01


Last updated: 2017-09-21 01:09am
local r = Enum.Reverse("Difficulty");
local s = r[GAMESTATE:GetCurrentSteps():GetDifficulty()];

s value will return the enum equivalent

Post #6 · Posted at 2017-09-21 01:24:54am 6.5 years ago

Offline leadbman
leadbman Avatar Member
263 Posts
Australia
Reg. 2016-02-01

"Working On: 5thMix BGA bgchanges"
Quote: razorblade
local r = Enum.Reverse("Difficulty");
local s = r[GAMESTATE:GetCurrentSteps():GetDifficulty()];

s value will return the enum equivalent

I'm still confused. Here's my code, I put your suggestion in to replace how I was trying to attain the difficulty:

Quote
t[#t+1] = LoadActor( "Storm.mp4" )..{
InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;scaletoclipped,1280,1100;);
OnCommand=cmd(playcommand,"Set");

SetCommand=function(self)
local r = Enum.Reverse("Difficulty");
local s = r[GAMESTATE:GetCurrentSteps():GetDifficulty()];
if s == "4" then
self:diffusealpha(1);
else
self:diffusealpha(0);
end
end
};

I'm trying to get the storm background to play in this instance when a challenge song is being played. I would like to be able to detect if the song has mines in it too but I think that's way too far outside of my knowledge base as I've looked at how other themes get the "Shock Arrow" icons on the song wheel to show up and I couldn't really wrap my head around that.

Am I using the value incorrectly? When I run the code, it's just showing the video all the time, no matter whether it's a challenge difficulty or not.

Sorry that I'm not understanding properly.
https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #7 · Posted at 2017-09-21 02:35:33am 6.5 years ago

Offline ZTS
ZTS Avatar Member
139 Posts
Not Set
Reg. 2015-01-13

"But enough talk! Have at you!"

Last updated: 2017-09-21 02:49am
1. You didn't put PLAYER_1 or PLAYER_2 in GetCurrentSteps(), which is required for it to work. Also, GetDifficulty doesn't accept any arguments.

2. If you want the difficulty as a number for some reason, the above works fine but here's the one line method.
Difficulty:Reverse()[d] (Where d is a difficulty enum)

3. I already linked that GAMESTATE:GetCurrentSteps(pn):GetDifficulty() will always return a value from the difficulty enum, which is one of these strings: "Difficulty_Beginner", "Difficulty_Easy", "Difficulty_Medium", "Difficulty_Hard", "Difficulty_Challenge", "Difficulty_Edit". You just need to check if it's one of these strings.
https://arcofswords.s-ul.eu/Ss6yrm9g.png

If you think that's too long to type you can do ToEnumShortString(d) where d is a difficulty enum. For example, "Difficulty_Beginner" will become "Beginner".

4. You are trying to compare a string "4" to a number. You want s == 4, not s == "4". Putting quotes around something means it's a string.
Get Rave It Out! https://sites.google.com/view/riodevs/home
Want your theme made? I take commissions, PM for details.

Post #8 · Posted at 2017-09-21 03:06:29am 6.5 years ago

Offline leadbman
leadbman Avatar Member
263 Posts
Australia
Reg. 2016-02-01

"Working On: 5thMix BGA bgchanges"
Sorted it! Thanks for your help guys, now I understand the enums better and how to use them properly, I'll see if I can work out how to find out if a song has mines.

My code ended up being:

Quote
local s = GAMESTATE:GetCurrentSteps(PLAYER_1):GetDifficulty();
local s2 = GAMESTATE:GetCurrentSteps(PLAYER_2):GetDifficulty();
if s == 'Difficulty_Challenge' or s2 == 'Difficulty_Challenge' then
self:diffusealpha(1);
else
self:diffusealpha(0);
end

https://zenius-i-vanisher.com/ddrsig/18213.png?t=1510895050
Really need to add my scores to the tracker soon.
Always learning, always trying to push the boundaries of SM.

Post #9 · Posted at 2017-09-21 03:05:54pm 6.5 years ago

Offline razorblade
razorblade Avatar Member
1,099 Posts
Not Set
Reg. 2011-03-01

You can do this instead: https://codeshare.io/5Zbq97
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: 3% · Database: 4% · Server Time: 2024-04-24 04:49:22
This page took 0.006 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language