Logo

[Help] Insert credits image

Register Log In Back To Forums

Post #1 · Posted at 2016-11-11 04:32:10pm 7.4 years ago

Offline kenny
kenny Avatar Member
572 Posts
United States
Reg. 2014-06-14

I am working on the SN2 AC theme for Stepmania 5 and I need help with the "Insert Credits" Image. Basically, I want it to show when There are no credits inserted and I also want to hide it if the person is on Event Mode or on Free play or if someone has credits inserted. Can anyone help me with this?

Post #2 · Posted at 2016-11-11 05:03:06pm 7.4 years ago

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

For the coins use GetCoins()
Quote
if GetCoins() > 0

And for the coin mode compare with the ENUM:
http://dguzek.github.io/Lua-For-SM5/API/Lua.xml#ENUM_CoinMode

Post #3 · Posted at 2016-11-11 05:11:58pm 7.4 years ago

Offline kenny
kenny Avatar Member
572 Posts
United States
Reg. 2014-06-14


Last updated: 2016-11-11 05:11pm
So like this?

Quote


if GetCoins() > 0
LoadActor( "Insert.png" )..{
};
else
if coinmode == 'CoinMode_Free'' == true then
LoadActor( "Button1A.png" )..{
};


Probably did that wrong TBH >.<

Post #4 · Posted at 2016-11-11 11:33:35pm 7.4 years ago

Offline Inorizushi
Inorizushi Avatar Member
487 Posts
Not Set
Reg. 2012-10-25

"huhbluh"

Last updated: 2016-11-11 11:39pm
Quote: kenny
So like this?

Quote


if GetCoins() > 0
LoadActor( "Insert.png" )..{
};
else
if coinmode == 'CoinMode_Free'' == true then
LoadActor( "Button1A.png" )..{
};


Probably did that wrong TBH >.<

Quote

if GAMESTATE:GetCoins() > 0 then
LoadActor("Insert.png");
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
LoadActor("Button1A.png");
end;

or you can set it up as a Sprite.

Quote

Def.Sprite{
InitCommand=cmd(xy,<x>,<y>;queuecommand,("Set"));
SetCommand=function(self)
if GAMESTATE:GetCoins() > 0 then
self:Load(pathtoinsert.png);
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
self:Load(pathtobutton1a.png);
end;
end;
};

Post #5 · Posted at 2016-11-12 12:42:40am 7.4 years ago

Offline kenny
kenny Avatar Member
572 Posts
United States
Reg. 2014-06-14

Quote

if GAMESTATE:GetCoins() > 0 then
LoadActor("Insert.png");
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
LoadActor("Button1A.png");
end;

Got an unexpected symbol near if error when I used this one

Post #6 · Posted at 2016-11-12 12:44:53am 7.4 years ago

Offline Inorizushi
Inorizushi Avatar Member
487 Posts
Not Set
Reg. 2012-10-25

"huhbluh"
did you put it into an actortable

Post #7 · Posted at 2016-11-12 12:52:28am 7.4 years ago

Offline kenny
kenny Avatar Member
572 Posts
United States
Reg. 2014-06-14

Yeah and this is how I did it

Quote
-- Start Button
Def.Actor{
if GAMESTATE:GetCoins() > 0 then
LoadActor("InsertCredits.png");
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
LoadActor("Button1A.png");
end;
end
}

Post #8 · Posted at 2016-11-12 07:32:52pm 7.4 years ago

Offline Inorizushi
Inorizushi Avatar Member
487 Posts
Not Set
Reg. 2012-10-25

"huhbluh"

Last updated: 2016-11-12 07:35pm
Quote: kenny
Yeah and this is how I did it

Quote
-- Start Button
Def.Actor{
if GAMESTATE:GetCoins() > 0 then
LoadActor("InsertCredits.png");
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
LoadActor("Button1A.png");
end;
end
}

It should be something along the lines of

Quote

local t = Def.ActorFrame{};
t[#t+1]=Def.ActorFrame{
if GAMESTATE:GetCoins() > 0 then
LoadActor("InsertCredits.png");
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
LoadActor("Button1A.png");
end;
}

return t

Post #9 · Posted at 2016-11-12 09:18:02pm 7.4 years ago

Offline kenny
kenny Avatar Member
572 Posts
United States
Reg. 2014-06-14

Quote: Inorizushi
Quote: kenny
Yeah and this is how I did it

Quote
-- Start Button
Def.Actor{
if GAMESTATE:GetCoins() > 0 then
LoadActor("InsertCredits.png");
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
LoadActor("Button1A.png");
end;
end
}

It should be something along the lines of

Quote

local t = Def.ActorFrame{};
t[#t+1]=Def.ActorFrame{
if GAMESTATE:GetCoins() > 0 then
LoadActor("InsertCredits.png");
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
LoadActor("Button1A.png");
end;
}

return t

Yeah I tried that and it's still giving me the error "Unexpected symbol near 'if'"

Post #10 · Posted at 2016-11-12 09:44:22pm 7.4 years ago

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


Last updated: 2016-11-12 09:44pm
Your code is wrong, if you are returning a table, the conditions could not be inside the table items, the correct way to do this is to create the conditions first, and append the Actors to the table:

local t = Def.ActorFrame{};

if GAMESTATE:GetCoins() > 0 then
t[#t+1]=Def.ActorFrame{
LoadActor("InsertCredits.png");
}
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
t[#t+1]=Def.ActorFrame{
LoadActor("Button1A.png");
}
end;

return t

Post #11 · Posted at 2016-11-12 10:20:20pm 7.4 years ago

Offline kenny
kenny Avatar Member
572 Posts
United States
Reg. 2014-06-14

Quote: MadkaT
Your code is wrong, if you are returning a table, the conditions could not be inside the table items, the correct way to do this is to create the conditions first, and append the Actors to the table:

local t = Def.ActorFrame{};

if GAMESTATE:GetCoins() > 0 then
t[#t+1]=Def.ActorFrame{
LoadActor("InsertCredits.png");
}
elseif GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
t[#t+1]=Def.ActorFrame{
LoadActor("Button1A.png");
}
end;

return t

That works but when I do a credit it shows the insert credit image instead of Press start button and It also doesn't show the Insert Credits image when there isn't a credit at all

Post #12 · Posted at 2016-11-12 11:20:48pm 7.4 years ago

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

Because the logic is not complete, if you check the first statement, It will show the insert credits image when the credits are bigger than zero, you need to practice first, until you didn't find what to do Tongue is a trial and error process. Your code should look something like this

local t = Def.ActorFrame{};

if GAMESTATE:GetCoinMode() == 'CoinMode_Free' then
t[#t+1]=Def.ActorFrame{
LoadActor("Button1A.png");
}
elseif GAMESTATE:GetCoins() > 0 then
t[#t+1]=Def.ActorFrame{
LoadActor("Button1A.png");
}

else
t[#t+1]=Def.ActorFrame{
LoadActor("InsertCredits.png");
}
end;
end;

return t


I'm assuming that the Button1A is the press start button graphic. If the code doesn't fit your need practice adapting it.

Post #13 · Posted at 2016-11-12 11:22:25pm 7.4 years ago

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


Last updated: 2016-11-12 11:23pm
Quote: kenny
That works but when I do a credit it shows the insert credit image instead of Press start button and It also doesn't show the Insert Credits image when there isn't a credit at all

It doesn't update the images when you insert a credit because you don't have any code to handle that event.

The code you have right now only loads a single image (one or the other) when the screen loads. This is problematic because when something changes, and you want to show the other image, the other image isn't there to show.

Does that make sense?

The solution is that you'll need BOTH actors (the InsertCredits image AND the PressStart image) loaded when the screen loads and you'll need to hide and show each as different events occur.

Some events you might want to handle include:

1. What happens when the screen changes?
2. What happens when the CoinMode changes?
3. What happens when the number of coins inserted changes?

You code might end up looking something like this: http://pastie.org/10961238

Please ask questions about what parts of that code you don't understand. I would much rather you understand than copy/paste code you don't understand.

Post #14 · Posted at 2016-11-13 01:11:25am 7.4 years ago

Offline kenny
kenny Avatar Member
572 Posts
United States
Reg. 2014-06-14

Quote: dbk2
Quote: kenny
That works but when I do a credit it shows the insert credit image instead of Press start button and It also doesn't show the Insert Credits image when there isn't a credit at all

It doesn't update the images when you insert a credit because you don't have any code to handle that event.

The code you have right now only loads a single image (one or the other) when the screen loads. This is problematic because when something changes, and you want to show the other image, the other image isn't there to show.

Does that make sense?

The solution is that you'll need BOTH actors (the InsertCredits image AND the PressStart image) loaded when the screen loads and you'll need to hide and show each as different events occur.

Some events you might want to handle include:

1. What happens when the screen changes?
2. What happens when the CoinMode changes?
3. What happens when the number of coins inserted changes?

You code might end up looking something like this: http://pastie.org/10961238

Please ask questions about what parts of that code you don't understand. I would much rather you understand than copy/paste code you don't understand.

This worked 100% Big Grin I understand now what I need to do I'll try to remember this If i wanted to make another theme Smile
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: 5% · Database: 72% · Server Time: 2024-04-19 16:38:37
This page took 0.012 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language