Logo

How to force an Update to an element (REALLY NEED HELP)

Register Log In Back To Forums

Post #1 · Posted at 2015-06-29 08:11:05pm 8.8 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"
Hello, I really need help in this, I am working on my Theme where recently I have added a function where you can enter (in this case) the rate mod manually. Via the ScreenTextEntry I can enter for example a rate of 1.25, etc. That's ok everything works.

But I am having problems because, when I enter 1.5 for example I would like to make the BPM for example automatically updated to the corresponding ratemod entered.

I already have a lua that calculate the BPM * ratemod. The problem is it requires to the screen be refreshed (via F3 + 2) in the Theme category (F6) for example. I have tried everything and nothing works...

I have tried using MessageCommands likes SongOptionsChanged, adding (* ratemod) here and there, also using a SetUpdateFunction... even this:

Quote
OnCommand=function(self) if IsPlayerEnabled(PLAYER_1) then self:queuecommand("Update") end end;
UpdateCommand=function(self)
self:settext(BPMDisplay())
self:sleep(0.01)
self:queuecommand("Update")
end;

This is helpful in some situation for example the Alive Time I added, but no in this case.

I really apreciate if someone can help me.
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #2 · Posted at 2015-06-29 08:18:24pm 8.8 years ago

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

"I'm honestly pissed off."

Last updated: 2015-06-29 08:47pm
You can broadcast custom message commands by using MESSAGEMAN:Broadcast.
So when you change the rate mod you could do something like this:

MESSAGEMAN:Broadcast("rate_changed", {new_rate= 1.1})

Then have an actor with the rate_changed command:

Def.BitmapText{
Font= "Common Normal",
rate_changedMessageCommand= function(self, param)
self:settext(param.new_rate)
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 2015-06-29 08:35:01pm 8.8 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"
Quote: Kyzentun
You can broadcast custom message commands by using MESSAGEMAN:Broadcast.
So when you change the rate mod you could do something like this:

MESSAGEMAN:Broadcast("rate_changed", {new_rate= 1.1})
[code]
Then have an actor with the rate_changed command:
[code]
Def.BitmapText{
Font= "Common Normal",
rate_changedMessageCommand= function(self, param)
self:settext(param.new_rate)
end,
}

Ok, I tried but still not working, maybe I am using wrong the code, first I tried this:

Quote
MESSAGEMAN:Broadcast("rate_changed", {new_rate= 1.1})

t[#t+1] = Def.ActorFrame{
Def.BitmapText{
InitCommand=cmd(xy,CenterX()+200,CenterY());
Text="0",
Font="Common Normal",
rate_changedMessageCommand=function(self, param)
self:settext(param.new_rate)
end,
};
};

nothing happens, then, this:

Quote
t[#t+1] = Def.ActorFrame{
Def.BitmapText{
InitCommand=cmd(xy,CenterX()+200,CenterY());
Text="0",
Font="Common Normal",
SongOptionsChangedMessageCommand=function(self)
MESSAGEMAN:Broadcast("rate_changed", {new_rate= 1.1});
end;
rate_changedMessageCommand=function(self, param)
self:settext(param.new_rate)
end;
};
};

I thought that the SongOptions message would start the rate_mod command but that would be technically the same, also I replace SongsOptionsChangedMessageCommand with a OnCommand to make sure the code is running, but this by obviously reason run automatically the rate_changed without changing of ratemod.

I still not understanding in which moment the code know I have changed of ratemod. I have tried things like an entire month to fix this and I still not finding it.
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #4 · Posted at 2015-06-29 08:49:07pm 8.8 years ago

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

"I'm honestly pissed off."
You have to broadcast the message from your code that changes the rate. You said you were using ScreenTextEntry to get the rate the player wants, so you should broadcast the change method from the function that takes the string the player puts in and applies it to the options.
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 2015-06-29 09:05:05pm 8.8 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"

Last updated: 2015-06-29 09:05pm
Quote: Kyzentun
You have to broadcast the message from your code that changes the rate. You said you were using ScreenTextEntry to get the rate the player wants, so you should broadcast the change method from the function that takes the string the player puts in and applies it to the options.
Hahaha, wow finally I got it... yeah now I understand, I put the "MESSAGEMAN:Broadcast("rate_changed", {new_rate=answer});" into the function where you enters the ratemod... and now IT FINALLY WORKS!!

Thanks you a lot, u dont know how much time i spent trying to make this... I am happy now Big Grin

EDIT: I noticed something, ok when I change the ratemod, the BPM is automatically updated with the ratemod, but I got a lua error at the moment of change of song: attempt to index local "param" a nil value.

I added CurrentSongChangedMessageCommand, because when I change song still the bpm from the last song.

Why?
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #6 · Posted at 2015-06-29 09:40:47pm 8.8 years ago

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

"I'm honestly pissed off."
Read the first few chapters of Programming in Lua. Then you can learn at least some fundamentals of programming and understand what variables and arguments are.
Work your way through the book, typing up each code example and testing it so you understand how it works.
Since you are using lua in an embedded environment, you'll have to use Trace instead of print. You can just put the code for your learning exercises in a screen, then reload the screen and flush the log to see the output.

Without some basis in programming knowledge, error messages will forever be a mystery.
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 2015-06-30 01:23:46am 8.8 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"
Well... after all I already tried... I tried the last thing, thanks to a function dbk2 made I have finally solved the problem with no issues...
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released

Post #8 · Posted at 2015-06-30 06:24:14pm 8.8 years ago

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

Quote: Th3_Ov3rHell_3XoduZ
Well... after all I already tried... I tried the last thing, thanks to a function dbk2 made I have finally solved the problem with no issues...

Because I am curious to learn how other people learn, what function of mine helped you understand better?

Post #9 · Posted at 2015-06-30 06:45:46pm 8.8 years ago

Offline Th3_Ov3rHell_3XoduZ
Th3_Ov3rHell_3XoduZ Avatar Member
313 Posts
Chile
Reg. 2012-09-13

"ITG, The Best Dance Machine!"

Last updated: 2015-06-30 06:46pm
Quote: dbk2
Quote: Th3_Ov3rHell_3XoduZ
Well... after all I already tried... I tried the last thing, thanks to a function dbk2 made I have finally solved the problem with no issues...

Because I am curious to learn how other people learn, what function of mine helped you understand better?

After tried everything, I figured out something before I give up... I fix it with this function you made from a beginning for ur port of Simply Love, this function save a value in memory for each variable.

The Line I used for fix the example I posted in the first post of this thread, was how to update automatically the BPM depending of the ratemod selected. I saved the ratemod in here:

MetroQuad.Global.MiscOptions.RateModUsed --> This has stored the ratemod used and it is updated to a new one if a player changed it. From where?? from the function I made where a player can set any ratemod manually or from a preset list.

Then, with this finally I got something, I got a variable that permanently has stored the ratemod, after this I just reupdate the code from the BPMDisplay lua file I use. Something like this in short:

BPMDisplay * MetroQuad.Global.MiscOptions.RateModUsed --> (Example) 200 * 1.0 = 200

the Ratemod always start at 1.0, at the moment to update the ratemod, the variable will update too and the BPM is automatically updated.

BPMDisplay * MetroQuad.Global.MiscOptions.RateModUsed --> (Example) 200 * 1.1 = 220

Doing this I have solved the problem but with something missing... I noticed that for see the result I have to move the musicwheel at least 1 move to see the BPM updated, of course, the OnCommand that display the BPMDisplay must be updated, it is updated with the CurrentSongChanged message command.

How to fix that I need to move 1 movement to see the BPM updated, to fix that problem I fixed it using the MESSAGEMAN:Broadcast() function. the Broadcast() updated the BPM at the moment to change the variable the rated has stored.

And finally everything was good and me happy Big Grin

Maybe it sound weird but remember that my english is not good enough. Your function dbk2 has been so helpful for my theme because it let me save information in differents variables and then I can make even new functions with those variables to make good features.

My theme won't works without this function... that's why the script lua that contains that function is called MQ_Init.lua It is the Initial script that is loaded and then all the others.

Smile
Quote: Released Themes for SM5 Beta 3
Quote: Released Themes for SM5 Beta 4 & 5.0.7
Quote: Simfles Packs Released
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: 4% · Server Time: 2024-04-19 22:29:56
This page took 0.009 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language