Logo

[SM5] Is it possible to find out what percentage the life meter is at?

Register Log In Back To Forums

Post #1 · Posted at 2017-11-16 04:18:09pm 6.3 years ago

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

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

Just wondering if it's possible to get the percentage of the life meter constantly while a song is playing? I'm trying to work out some triggers for failing in DDR Solo mode.

Any help would be appreciated.
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-11-16 04:50:48pm 6.3 years ago

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

"I'm honestly pissed off."
LifeChanged message. The param table contains Player (the player number) and LifeMeter (the meter actor that broadcast the change). Battery meter also has LivesLeft (number of lives remaining) and LostLife (true if the player lost a life).

LifeChangedMessageCommand= function(self, param)
if param.Player == pn then
local goal_life= param.LifeMeter:GetLife()
if goal_life == life then return end
self:playcommand("life_update", {life= goal_life})
end
end,

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 2017-11-17 02:09:40am 6.3 years ago

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

"Working On: 5thMix BGA bgchanges"
Thanks for that Kyzentun.

With what you've said, what value is the "life" variable there? As in, can I say if goal_life == "20%" or is that value held differently?
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 #4 · Posted at 2017-11-17 03:05:05am 6.3 years ago

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

"I'm honestly pissed off."
The code I pasted is just a snippet from my surround life bar. I only picked it because it uses the parameters of the message. The functions for LifeMeter are listed in Lua.xml.

For the bar meter, GetLife returns a number from 0 to 1 (the LifeMeterBar::LifeMultiplier metric).
For the battery meter, it's from 0 to 1, where 1 means they have all the lives they started with.

```if goal_life == "20%"``` would be comparing a number to a string, so of course it would not work. You would need to use 0.2, which is a number.
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 #5 · Posted at 2017-11-17 03:55:03am 6.3 years ago

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

"Working On: 5thMix BGA bgchanges"
Yeah I just had a quick read and realised my mistake regarding the string after I'd posted.


t[#t+1] = LoadActor( "Solo/static" )..{
InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y);
OnCommand=cmd(diffusealpha,0;);

LifeChangedMessageCommand=function(self, param)
if param.Player == pn then
local goal_life = param.LifeMeter:GetLife()
if goal_life < 0.5 then
self:diffusealpha(1);
else
self:diffusealpha(0);
end
end
end
};


I'm trying to run this as a test, it's not throwing me any errors but it's not showing the static when goal_life is below 0.5. Not sure what I'm doing wrong? If I swap the diffusealpha values around I get nothing either.
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 #6 · Posted at 2017-11-17 04:21:30pm 6.3 years ago

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

"I'm honestly pissed off."
Probably forgot to set your "pn" variable. What is it set to?
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 #7 · Posted at 2017-11-17 04:55:14pm 6.3 years ago

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

"Working On: 5thMix BGA bgchanges"
I had this:
local pn = (Player == PLAYER_1) and 1 or 2;

But I also tried:
param.Player == PLAYER_1

And neither worked.

I'm thinking I'm doing something incorrect with my syntax for pn? It's odd that PLAYER_1 didn't work though because I'm assuming that param.Player is looking for either PLAYER_1 or PLAYER_2 as that's usually the case?
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 #8 · Posted at 2017-11-17 07:32:13pm 6.3 years ago

Offline MadkaT
MadkaT Avatar Member
820 Posts
Not Set
Reg. 2009-11-24

This is the code of the extreme2 lifebars that I've coded, is not the best, but could help you to play with code :wink:

https://github.com/MadkaT182/DDREX2/blob/master/BGAnimations/ScreenGameplay%20decorations/lifebars.lua

Post #9 · Posted at 2017-11-17 07:46:11pm 6.3 years ago

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

"I'm honestly pissed off."
param.Player will be either PLAYER_1 or PLAYER_2, you can use Trace to print it to the log or system message it so you see it on screen if you want to see what it is.
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 #10 · Posted at 2017-11-18 04:00:51am 6.3 years ago

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

"Working On: 5thMix BGA bgchanges"
Got it working now, with this:


LifeChangedMessageCommand=function(self, param)
if param.Player == PLAYER_1 then
if param.LifeMeter:GetLife() < 0.40 then
self:linear(0.3):diffusealpha(1);
else
self:linear(0.3):diffusealpha(0);
end;
end;
end;

Not sure what I was doing wrong before when I tried PLAYER_1 there. Oh well, at least it's functional now!

Thanks for your assistance everyone Smile
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.
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-03-28 09:34:25
This page took 0.01 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language