turn on and off the lantern by pressing a button

MaxMoonS

Veteran
Veteran
Joined
Oct 28, 2015
Messages
20
Reaction score
0
First Language
Italian
Primarily Uses
hello everyone, I am using the script khas awesome light effects, and I would turn on and off the lantern with the press of a button. I tried some solutions in the forum but I could not make it work. Can anyone help me?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Please post a screenshot of what you have so far in the event. Most likely it's a problem in the loop needed to check for pressed buttons.
 

MaxMoonS

Veteran
Veteran
Joined
Oct 28, 2015
Messages
20
Reaction score
0
First Language
Italian
Primarily Uses
this is a common event that I created




yes I'm Italian. however, at the beginning it says conditional branch if the z button is pressed
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
first, to check a button press you'll need a parallel process event - the event in the screenshot has no trigger, which means it can only be used if called by a skill or by another event. It might work if called by a parallel process event, but it would be a lot better to make it parallel itself.


If you make that event a parallel process, then include a wait(10) or so - you don't need to check the lantern sixty times per second, six times is enough and a lot less lag.
 

MaxMoonS

Veteran
Veteran
Joined
Oct 28, 2015
Messages
20
Reaction score
0
First Language
Italian
Primarily Uses
ok. Now the event that starts with a parallel process and it works!. But if I turn Off/ON quickly the lantern several times, it does not always work and I have to press the button a second time. why?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Most probably the wrong number of waits - either too few (lagging the response) or too many (making the event skip the button press).


You'll have to test the correct number yourself (and might have to retest if you later have maps with larger lag)
 

MaxMoonS

Veteran
Veteran
Joined
Oct 28, 2015
Messages
20
Reaction score
0
First Language
Italian
Primarily Uses
Most probably the wrong number of waits - either too few (lagging the response) or too many (making the event skip the button press).


You'll have to test the correct number yourself (and might have to retest if you later have maps with larger lag)









I did not understand what you mean by number of waits. How can I test it? I'm sorry but I'm a beginner.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
Actually, that is a bug in the default engine. The interpreter skips some frames because of it.


Source made a little fix for it, here: 




Here is the direct snippet, because the one in that topic is messed up:

# Parallel Process Events Execution Bug Fix.
# Version 1.0.0
# 09/02/15 - DD/MM/YY
# www.rpgmakersource.com
# forums.rpgmakersource.com

class Game_Interpreter

# Overwrites default method with the fixed version.

def run
wait_for_message
while @list[@index] do
execute_command
@index += 1
end
@fiber = nil
Fiber.yield
end

end

Add that snippet right at the top of your custom script list.


That should fix the frame skip issue, and your button press should be triggered normally.
 

MaxMoonS

Veteran
Veteran
Joined
Oct 28, 2015
Messages
20
Reaction score
0
First Language
Italian
Primarily Uses
Actually, that is a bug in the default engine. The interpreter skips some frames because of it.


Source made a little fix for it, here: 





Here is the direct snippet, because the one in that topic is messed up:

# Parallel Process Events Execution Bug Fix.
# Version 1.0.0
# 09/02/15 - DD/MM/YY
# www.rpgmakersource.com
# forums.rpgmakersource.com

class Game_Interpreter

# Overwrites default method with the fixed version.

def run
wait_for_message
while @list[@index] do
execute_command
@index += 1
end
@fiber = nil
Fiber.yield
end

end

Add that snippet right at the top of your custom script list.


That should fix the frame skip issue, and your button press should be triggered normally.


tried the fix but nothing to do. Maybe that's not the problem, there could be errors in event I created? However, if I have not explained well: sometimes if I press several times the lantern button does not light or otherwise does not turn off and flash.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
You can try to change that "button Z is pressed" check to a scripted one instead.


That would look like this:


"Input.trigger?:)Z)"


So, in the conditional branch settings, select "Script" and enter that (without the quotation marks).


The event seems good to me, I had the same one in my old project and that worked for me.


If it still won't work, than I have no idea. What FPS you get on the map? If it is low, than it can skip input checks occasionally. 


Ohh and I just read that Andar wrote that you need a wait command in that event. You don't need a wait command there at all, so remove it.


The event only triggers if you press the button, so there can be no lag because of it.


If it would change a switch or variable constantly, than there would be lag, but this event does not do that.


So, if you have a wait command in it, than it is normal that the lantern won't always show up.
 

MaxMoonS

Veteran
Veteran
Joined
Oct 28, 2015
Messages
20
Reaction score
0
First Language
Italian
Primarily Uses
GREAT! I solved using the script in the conditional branch. I also checked the fps and are a little bit lower, in small maps 18-20 and 13-14 on the larger ones. how can I do to increase it? Thanks again for help you are giving me
 
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Show a screenshot of your current event, and we'll see what can be done to improve them.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
The default map scene is far from being optimized performance wise.


Adding Khas' Lighting script gives another blow to your FPS, because that one is a heavy script.


One of the greatest FPS-booster scripts out there are the "plane rewrite" scripts. 


I personally use FenixFyreX's Plane Fix script, and that one doubles my FPS on the map. You should try it out too.


Aside from that, badly designed parallel process events can drop your FPS as well.


Any such event which changes a switch, self-switch or variable non-stop (every single frame, which means 60 times in a second) will drop the FPS for sure.


And some other things can affect your FPS too, such as:


- Changing the resolution of your game (the higher the resolution, the bigger the FPS drop)


- Huge maps (I can't verify this, because I never actually used a huge map, but people seem to notice FPS drops from this)


- Tons of events on the map (don't make dozens of events if you can do it with only one, for example, 1 parallel event can control everything on a map, no need for more)


- Tinting the screen with a changed gray value (changing the gray value alone will drop your FPS)


- Weather effects


- In-game time systems (scripted or evented, doesn't matter)


- Other custom systems which might need a lot of processing time or which are not optimized (aka some custom scripts)
 

MaxMoonS

Veteran
Veteran
Joined
Oct 28, 2015
Messages
20
Reaction score
0
First Language
Italian
Primarily Uses
I tried the script but the situation has not changed. Surely the fall in fps is due by the number of scripts that use and some are heavy as that of khas lighting and also use an abs called re weapon system II then there are also several events with self-switch and switch all with parallel processes .
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Parallel Processes usually have a higher effect on FPS than scripts - besides Khas Light script I don't know of a script that will have a regular impact on lag and FPS unless it is involved with parallel processes as well, but a single badly designed parallel process can drop the FPS to zero, and the lag from parallel processes is additive - they all add to the effect.


If they have a good logic structure that additive effect is minimal, but checking that is difficult - which is why I always suggest to use as few parallels as possible.
 

beenbaba

Slowly getting there
Veteran
Joined
Apr 28, 2015
Messages
289
Reaction score
159
First Language
English
I'm not sure whether you're still looking for a way to do this / possibly a more efficient way but I use Yanflys Button Common Events to bind a common event which turns the lantern on and off when a certain key is pressed. This means the common event doesn't need to be a parallel process and is only ever run when the player presses the designated key.


I can post a screenshot / additional information if you want to know some more //rmwforums.s3.amazonaws.com/emoticons/default_biggrin.gif
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top