Author Topic: [XP][VX][VXA] Fade Events  (Read 7206 times)

Offline Heretic86

  • Astral Trancist
  • *****
  • Posts: 776
  • LV: 34
    • View Profile
[XP][VX][VXA] Fade Events
« on: April 23, 2012, 11:50:00 PM »
Fade Events
Authors: Heretic
Version: 1.0
Type: Fade Events with Duration
Key Term: Misc Add-on

Introduction

This script will allow you to Fade Events in and out gradually.  The Default Options allow you to change an events opacity, but does not allow you to make a gradual transition.  Thus, if you wanted to have an Event that "dissolved", "teleported" or "flickered", you would have to use quite a few Change Opacity commands, then use Wait after each and every Change Opacity command.  Sorry to say, but I think that is a pain in the behind.  This script offers an easier way to accomplish that same effect by using one line of script: fade_event(new_opacity, duration).  Short Fades can be accomplished without this script by adjusting the opacity every frame for a few frames, but if you need rather long Fades that take a lot of frames, then this is the script for you!

Features

  • Saves Time by changing Opacity for you Automagically
  • Super Duper easy to use
  • Only ONE Command to Remember
  • No Configuration Necessary
  • High Degree of Compatability
  • Reported to me to be compatible with VX and VXA as well

Screenshots
(click to show/hide)


Demo

http://www.775.net/~heretic/downloads/rmxp/fade_event/fade_event.exe

Script

Fade Event (with Developer Errors)
(has a little more code, lets you know if you do something wrong)

(click to show/hide)


Fade Event (no Developer Errors)
(has less code, no errors displayed if you do something wrong, so you're on your own)

(click to show/hide)

Instructions

Just put the code above main somewhere...

Compatibility

No Incompatability Issues, as far as I know...

Credits and Thanks

  • I'd like to thank the Academy, Chucky Cheese, and inspiration from Chuck Norris!
  • Thanks to everyone who has been helping me improve my scripting skills!

Author's Notes

Thursday is Garbage Day so don't forget to take out the Trash!  Oh, wait, that isnt really a note related to this Script!  How embarassing!


---

I dont own copies of VX or VXA, but it has been reported to me that this script is compatible with VX and VXA as well!  Please advise if there are any issues and I'll see what I can do for you.
« Last Edit: April 25, 2012, 10:07:32 PM by Heretic86 »
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Offline Calintz

  • Guardian of Chaos
  • ********
  • Posts: 3803
  • LV: 108
  • Gender: Male
  • A Pixel's Worst Nightmare
    • View Profile
Re: [XP] Fade Events
« Reply #1 on: April 24, 2012, 12:47:59 AM »
this was a wonderful idea. +1

Offline LiTTleDRAgo

  • Astral Trancist
  • *****
  • Posts: 851
  • LV: 517
  • Gender: Male
    • View Profile
    • ~
Re: [XP] Fade Events
« Reply #2 on: April 24, 2012, 03:22:09 AM »
Actually, brief side note.  I dont have RMVX or VXA so Im not sure if this script would be compatible with those or not, but if someone feels like testing it out and posting results...

and yes, it's compatible with VX - VXA

Offline G_G

  • Green Gmod Game_Guy AKA G4 AKA hyper-G AKA G-force
  • Global Moderator
  • Chaos Ultimate
  • ****
  • Posts: 6591
  • LV: 407
  • Gender: Male
    • View Profile
Re: [XP] Fade Events
« Reply #3 on: April 24, 2012, 04:23:26 AM »
Snippet so you can use the code in Event Commands > Script Call rather than doing it through the Set Move Route command.
Code: [Select]
class Interpreter
  def fade_event(opacity, duration, event = 0)
    character = get_character(event)
    return true if character == nil
    character.fade_event(opacity, duration)
  end
end

Called in a script call window.
Code: [Select]
fade_event(opacity, duration, target_event = 0)
target_event = -1 (the player), 0 (event the script was called in), or other_event_id
If target_event is omitted, it'll target the event that the script call was placed in.

And instead of checking to see if the opacity value is less than 0 or greater than 255, its a simple array check like so.
Code: [Select]
arg_opacity_target = [[arg_opacity_target, 0].max, 255].minWhich clamps the number between 0 and 255.

Also no offense, but those warning messages and parameter checks are a little useless in my opinion. You clearly state in your instructions what to use for your parameters, so if the end-user of a script can't read some simple instructions, its their own fault if they can't get the script to work. I know you're trying to make this user-friendly but your code could be so much cleaner if you got rid of those messages.

One more thing, instead of checking to see if arg_opacity_duration is a positive number, just use the abs method or "absolute" method, which is the placement away from zero. Always returns a positive number.
Code: [Select]
arg_opacity_duration = arg_opacity_duration.abs
« Last Edit: April 24, 2012, 04:36:14 AM by game_guy »

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3255
  • LV: 298
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP] Fade Events
« Reply #4 on: April 24, 2012, 04:38:33 AM »
You don't need to clamp opacity values, they are already by the underlying library.

Quote from: The RMXP Help Manual
opacity
The sprite's opacity (0-255). Values out of range are automatically corrected.

Code: [Select]
sprite = Sprite.new
sprite.opacity = -34345
p sprite.opacity
sprite.opacity = 63728374328472
p sprite.opacity

I agree with G_G about the unneeded checks. They are nothing more than an extra lines of code to perform.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Heretic86

  • Astral Trancist
  • *****
  • Posts: 776
  • LV: 34
    • View Profile
Re: [XP] Fade Events
« Reply #5 on: April 24, 2012, 05:14:11 AM »
Okie dokie, I'll add those things in when I get two minutes free.  Dogs are telling me its "take a dump o'clock", so I have to take em for a walk...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Offline Heretic86

  • Astral Trancist
  • *****
  • Posts: 776
  • LV: 34
    • View Profile
Re: [XP] Fade Events
« Reply #6 on: April 24, 2012, 08:42:44 AM »
So I've been thinking about your guys suggestions.  And Im not the most experienced scripter, so I am listening to your advice.  So no offense taken.

In order to make a script both "User Friendly" and "Compact", which appears to be a balance between adding extra code to provide those messages, and make it run fast, what would be the "Official" way to do it?  I mean by the book?  I have no books to reference, just mostly the internet and listening to what you guys have to say.

Here is my therory.  If "User Friendly" has to run extra code and makes a script run like garbage because it causes a bigtime performance hit, the extra User Friendliness code has to go.  Performance and stability is top priority.  Such as doing User Friendly error messages in a repeating loop.  Bad Idea.  I get that.  But for a script that executes only every so often, and printing errors doesnt cause any noticable performance hits (yeah I know they add up quickly), is it better to let the person using the script know they've messed up by not clamping, even if clamping would fix that problem before it is an issue, or to allow them to continue to falsely "think" that 320000000 is within an acceptable range of Opacity?

Admitted, half the code is just there to advise the User on potential errors, and the Interpreter one doesnt run at all unless it is called from the wrong script window.  Now, on the Interpreter error vs just make it work philosophy, would it make more sense to a user to run a script from only one place, or from where ever they want, even though it requires additional arguments (parameters) to be passed to the method?  Im trying to keep it simple for stupid (k.i.s.s.) as I am sure that many of the people that use RM arent scripters, and many when they first start out dont even know how to insert a new script.  Everyone has to start somewhere, which means we were all of us "stupid" at some point.

Help me out with this.  I've got what seems like slightly conflicting advice.  One says get rid of as much extra code as possible, other says auto-fix all user created problems with bits of extra code.  Both arguments are valid.  What is the Balance I should be aiming for?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20016
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP][VX][VXA] Fade Events
« Reply #7 on: April 24, 2012, 10:25:17 AM »
There are two philosophies on this: The "professional" one and the "amateur" one.

The professional one says that you should make certain errors obvious to the user. Since this is the "professional" one, it's usually used in professional software.

The amateur one says who cares. If the user doesn't properly use the script, it's their fault. This philosophy is basically used all over the RMXP community. And it's ok. If there were that many additional error messages in scripts, things would really become too cluttered. e.g. Your example with opacity. If somebody is stupid enough (no offense meant here for the users) to try to set the opacity to 32000000 (regardless of the fact that RMXP sliently clamps the value within the range), then it's their own fault. You can't expect that something works if you just keep "pressing random buttons".

As for your specific problem, remove all extra code. You should add in the instructions how the script is used and what kind of limitations there are. People who try to use the scripts just like that without reading the instructions (you wouldn't believe how many people don't read them) usually end up giving up on their projects anyway. They are not even committed enough to their projects to read a few sentences. Besides, even if you added error messages and all, they will still post and complain that your script isn't working and that it's giving them errors.

So my personal recommendation: No extra checks unless you think it really, really makes sense. No extra code. Use instructions. If people ask stupid questions, tell them to read the instructions, it's all there. Everybody in the RM community does it that way and it works best from what I have seen in my 6 years in the community.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline LiTTleDRAgo

  • Astral Trancist
  • *****
  • Posts: 851
  • LV: 517
  • Gender: Male
    • View Profile
    • ~
Re: [XP] Fade Events
« Reply #8 on: April 24, 2012, 03:45:10 PM »
Im trying to keep it simple for stupid (k.i.s.s.) as I am sure that many of the people that use RM arent scripters,

it will be simpler to correcting the user simple mistake silently in the shadows,
if the mistake is fatal, that's a different story

enterbrain does it too doesn't it?

  • look at the draw_text in vx / vxa
    even if you typed an integer in draw_text, it will automatically changed to string
  • opacity will automatically corrected if out of range
  • etc, etc, etc

if something trivial triggers an error / message, the user probably will think your script is annoying

There are two philosophies on this: The "professional" one and the "amateur" one.

I'll probably go with "amateur" one

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20016
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP][VX][VXA] Fade Events
« Reply #9 on: April 24, 2012, 04:15:46 PM »
Everybody in the RM community does and I think it's the best one for something like this. Unless you are being paid, there is not really a point for the professional one.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3255
  • LV: 298
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: [XP][VX][VXA] Fade Events
« Reply #10 on: April 24, 2012, 09:47:01 PM »
I really only see the purpose if you are developing some type of framework or API that users will be compounding upon. Other than, simply telling the user how to make the call is sufficient.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20016
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP][VX][VXA] Fade Events
« Reply #11 on: April 25, 2012, 10:07:56 AM »
Yes, a framework or some sort of SDK would be the only exceptions to the rule. Maybe even certain development/scripting tools. e.g. When using a console, there should be proper error handling for syntax errors and such. But this still comes down to simple and generic error handling instead of covering "all possible cases".
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Heretic86

  • Astral Trancist
  • *****
  • Posts: 776
  • LV: 34
    • View Profile
Re: [XP][VX][VXA] Fade Events
« Reply #12 on: April 25, 2012, 10:17:58 PM »
Ok, temporary edit to original post.  I'll update the demo when I've come up with a product that everyone can be happy.

I put two versions up, just temporarily.  One has the errors in it (original), the other has all the extra code pulled out.  Both versions I changed "self.opacity_duration = arg_opacity_duration" to "self.opacity_duration = arg_opacity_duration.abs" to do a quick fix for negative values.  I did not add anything to redirect from Interpreter if the script is called, as it is an extra optional argument, so the game will crash if fade_event(O, D) is called from non Move Route Script window.  It just seems to me that if I add in extra args, one window expects them to be there, one does not, it has too much potential to confuse even pretty sharp users of the script.  So two expected arguments that have to be called from the correct Script Window.  And I think that is the way it is going to stay.  If you use it for yourself, and already know how to script, you can modify it to suit your needs.

Since there werent really any functional differences, excluding .abs addition I didnt think that it warranted a version change, unless you guys advise otherwise.  Oh, and should I put anything in for Legal junk?  Its too small of a script to say "bla bla bla, mention me in the credits, free for commercial use" for me to really care, but what do you guys think about the Legals of it?

Any other suggestions? 
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)