Script Call Support Boards

If you are going this way, i would split configuration and logic and do it like this:

Configuration somewhere in a module:

MAPPING = {  1 => "Just Another Fetch Quest",  2 => "Revenge",  ...}Actual call:

$game_variables[68] = <module_name>::MAPPING[$game_variables[67]] || $game_variables[68]I have been wanting to do something like this for the longest time, but creating a script and referencing the modules scares me. Though I do understand it could save me a lot of time in the long run.
I just came up with this, and it's a bit dynamic, letting you be able able to decide what variable is checked and what one is set.

module Test class Choice #variable thats being checked, variable that's being set def self.select(check, display) @var1 = $game_variables[check] @var2 = "" @var1 <= 1 ? @var2 = "Just Another Fetch Quest" : nil @var1 == 2 ? @var2 = "Revenge" : nil @var1 == 3 ? @var2 = "Out of Control" : nil @var1 == 4 ? @var2 = "Leave Me Alone" : nil @var1 == 5 ? @var2 = "Flowers for Mom" : nil @var1 == 6 ? @var2 = "Healing Burns" : nil @var1 == 7 ? @var2 = "Epic Lootz" : nil @var1 == 8 ? @var2 = "Scavenger Hunt" : nil @var1 == 9 ? @var2 = "Finding a Tenant" : nil @var1 >= 10 ? @var2 = "Dessert in the Desert" : nil $game_variables[display] = @var2 end endendThis is the script call

Test::Choice.select(67, 68)67, and 68 can be whatever variables you want them to be. And you would put the first script set in the script editor in materials.

And the call would in the event.

Of course Test, choice, and select can be whatever you like. With this set up, you can have multiple sets of choices dynamically set for whatever situation you like. It was funner than I thought, to make that I mean. And of course I've tested it. You just got me make sure to set the "check" variable before calling the script.
I'm wanting to do a fast fade out of the player's sprite, and came up with this - which doesn't appear to do anything.

$game_player.opacity_change(50, 8)

What I thought I was doing was telling it to change to opacity 50 in 8 frames, but clearly not.  What should this be?

Thanks.
I'm wanting to do a fast fade out of the player's sprite, and came up with this - which doesn't appear to do anything.

$game_player.opacity_change(50, 8)

What I thought I was doing was telling it to change to opacity 50 in 8 frames, but clearly not.  What should this be?
Alright, so it's a bit crude but here ya go.

(edited: I readjusted it so it will work as a fade in and out. Plus has a quick clear command)

  class Game_CharacterBase   alias_method🙂old_initialize, :initialize)   alias_method🙂old_update, :update)     def initialize    init_opacity_fade    old_initialize  end  def init_opacity_fade    @opacity = 255    @opacity_duration = 0    @target_opacity = 255    @opacity_difference = 0    @fadeout_in = ""  end  def change_opacity(target_opacity, duration)    @target_opacity = target_opacity    @opacity_duration = duration    @opacity_difference = (@opacity - @target_opacity)    @opacity > @target_opacity ? @fadeout_in = true : @fadeout_in = false  end  def fadein    if @opacity_duration >= 1          d = @opacity_duration          @opacity = (@opacity * (d - 1) + @target_opacity) / d          @opacity_duration -= 1    end  end    def fadeout    if @opacity_duration >= 1      d = @opacity_duration      @opacity_difference = (@opacity_difference * (d - 1)) / d      @opacity = @opacity_difference + @target_opacity      @opacity_duration -= 1    end    end  def fade_clear    @opacity_duration = 0    @opacity = 255  end  def update    old_update      if @fadeout_in == true        fadeout      else        fadein      end  endend#Script call $game_player.change_opacity(target_opacity, frame duration)#target opacity = the opacity you want to end up at#frame = how long it take you to get there.#remember 60 frames = 1 secondAs per usual just paste this into a slot in the materials section of your script editor, You can include the comments at the bottom since they wont affect the script. I have tested it, and it seems to work fine. The script call is at the bottom but for example you wanted to reduce the players opacity to 50 over the course of 8 frames. (Which is practically instant) you would simply call $game_player.change_opacity(50, 8)

The reason it wasn't working for you is because the method you were calling, doesn't exist(At least, I couldn't find it.). What my script does, is allow it to exist and function within the scripts that already reside there. The opacity drop is based off the (fade_out) method for the screen. It's called tweening, and seems to be the generally used fading in the game script. So I just borrowed it. Literally copied it and renamed it. Defined what they were, and made sure they updated right. The alias is so the this new update runs WITH the old one, and not overwrites it.

Lol, sorry if I talk(type) a lot. lol.

This was fun.

(edited script to include fade out, fade in, and a quick clear command. Fading in or out will happen automatically depending on your choice for opacity. and the quick clear command is included in the comments of the script.)
@HollowMonty

Thank you so very much for this.  I hadn't realized that what I wanted to do didn't exist.  Yeah, 8 frames is almost instantly, but it's to give the impression of someone falling down a hole.  Until I could see it, I couldn't know by how much to adjust it; 8 was merely the starting point. Tested it and at 22 frames it's just right for the size of the hole.

How do I credit? HollowMonty or something else?
If you want to apply some sort of easing to your fading our have it available in a generic way, i can suggest you to take a look at Animate Everything linked in my signature ^^
No problem ksjp17. Happy to help. And yeah, crediting HollowMonty is fine. It's not like it's very expansive. Just does the one thing, but hey, got to start somewhere. Helping others on this forum is helping me sharpen my scripting skills so it's a win win. If you have anymore script questions I'd love to give it a shot. 🙂
@HollowMonty

I've hit a snag.  I posted the above having tested it in a New Game, because of the lengthy cut scene leading up to the point where it's needed.  Everything was fine.  However, in game I get a crash when I load the game.  The map shows for a flash and then the NoMethodError message comes up for line 19

'>=' for Nil:NilClass

@Iavra

I had a look at that script when it was released.  To be honest, I don't understand it; I think it's written for other advanced scripters.  For example, in Configuration where it says

To enable animating for a class (and all of its subclasses), you have to register it first, like this:

I don't even know what that means, let alone know how to do it.
Yeah, i often tend to overcomplicate things. You have to define a generic getter and setter that works for every attribute you want to animate. There are 2 examples in the script and in like 90% of all cases one of these will suffice.


If you have further questions, i would prefer to do so in the other thread, before we are derailing this one.
Try it now. I edited it. I had that same error when I was making it the first time. Must have posted that one I had saved on notepad instead of the one in the script editor. There should be no reason for it. The argument is perfectly valid. I have tested it several times. It works now. Let me know it it's still bugging you.
Sadly I'm still getting the same error message.
I don't understand... hmm. if I remember correctly all I did was delete that line and retyped that same thing back into the same place. It confused that heck out of me that it worked. I don't see how there can be any problem when I'm using the exact script and it's working for me. I'm sorry buddy.

Iavra, can you see what the problem is? Seeing as your more experienced with scripts it might be clearer to you.
@HollowMonty: Your script works for me. Though i don't have any custom scripts in that projects except my own animation script, which doesn't overwrite or extend any methods in Game_CharacterBase, so it might be an incompatibility with another script.


Either that, or ksjp17 loads a savefile that was created prior to your script, since you add some instance variables to the class that need to be initialized (i try to avoid that, whenever possible).
Most probably you didn't type it exactly the same - even an additional or missing space or line break can change the result in programming...
I think it might be a compatibility issue.  I'm having a mega one at the moment, and this may be being caught up in that.  Until the scripter gets back to me I shan't know for sure.  I think this might be a long haul.
In order to use only script calls, maybe something like this?

Code:
if $game_player.opacity == 50else$game_player.opacity -= 25.625wait(1)end
Any chance you opened a save file? That requires some variables to be set when the characters are created. If you saved a file before adding the script, those variables won't exist. You need to start a new game. Or add a temporary extra snippet that will set them if they don't exist.
I've spoken with HollowMonty by pm about it, and everything is now sorted.

Thanks to all who contributed to the thinking.
What was the solution? As the problem was posted and discussed publicly, it'd be nice to make the solution public as well - just in case anyone else wants to try the script.
Turns out it was just a compatibility issue with another script that he had. My script works fine. 

Original thread: https://forums.rpgmakerweb.com/threads/script-call-support-boards.25767/