Post #1 · Posted at 2017-11-16 04:18:09pm 6.8 years ago
leadbman | |
---|---|
Member | |
263 帖子 | |
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.
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.
Post #2 · Posted at 2017-11-16 04:50:48pm 6.8 years ago
Kyzentun | |
---|---|
Member | |
3,209 帖子 | |
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,
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,
Post #3 · Posted at 2017-11-17 02:09:40am 6.8 years ago
leadbman | |
---|---|
Member | |
263 帖子 | |
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?
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?
Post #4 · Posted at 2017-11-17 03:05:05am 6.8 years ago
Kyzentun | |
---|---|
Member | |
3,209 帖子 | |
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.
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.
Post #5 · Posted at 2017-11-17 03:55:03am 6.8 years ago
leadbman | |
---|---|
Member | |
263 帖子 | |
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.
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.
Post #6 · Posted at 2017-11-17 04:21:30pm 6.8 years ago
Kyzentun | |
---|---|
Member | |
3,209 帖子 | |
Reg. 2008-02-20 | |
"I'm honestly pissed off." |
Probably forgot to set your "pn" variable. What is it set to?
Post #7 · Posted at 2017-11-17 04:55:14pm 6.8 years ago
leadbman | |
---|---|
Member | |
263 帖子 | |
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?
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?
Post #8 · Posted at 2017-11-17 07:32:13pm 6.8 years ago
MadkaT | |
---|---|
Member | |
824 帖子 | |
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
https://github.com/MadkaT182/DDREX2/blob/master/BGAnimations/ScreenGameplay%20decorations/lifebars.lua
Post #9 · Posted at 2017-11-17 07:46:11pm 6.8 years ago
Kyzentun | |
---|---|
Member | |
3,209 帖子 | |
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.
Post #10 · Posted at 2017-11-18 04:00:51am 6.8 years ago
leadbman | |
---|---|
Member | |
263 帖子 | |
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
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