Post #1 · Posté à 2017-11-16 04:18:09pm il y a 6.5 années
leadbman | |
---|---|
Member | |
263 Messages | |
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 · Posté à 2017-11-16 04:50:48pm il y a 6.5 années
Kyzentun | |
---|---|
Member | |
3,209 Messages | |
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 · Posté à 2017-11-17 02:09:40am il y a 6.5 années
leadbman | |
---|---|
Member | |
263 Messages | |
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 · Posté à 2017-11-17 03:05:05am il y a 6.5 années
Kyzentun | |
---|---|
Member | |
3,209 Messages | |
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 · Posté à 2017-11-17 03:55:03am il y a 6.5 années
leadbman | |
---|---|
Member | |
263 Messages | |
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 · Posté à 2017-11-17 04:21:30pm il y a 6.5 années
Kyzentun | |
---|---|
Member | |
3,209 Messages | |
Reg. 2008-02-20 | |
"I'm honestly pissed off." |
Probably forgot to set your "pn" variable. What is it set to?
Post #7 · Posté à 2017-11-17 04:55:14pm il y a 6.5 années
leadbman | |
---|---|
Member | |
263 Messages | |
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 · Posté à 2017-11-17 07:32:13pm il y a 6.5 années
MadkaT | |
---|---|
Member | |
822 Messages | |
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 · Posté à 2017-11-17 07:46:11pm il y a 6.5 années
Kyzentun | |
---|---|
Member | |
3,209 Messages | |
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 · Posté à 2017-11-18 04:00:51am il y a 6.5 années
leadbman | |
---|---|
Member | |
263 Messages | |
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