Request for Vehicle transparency

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
Hello everyone, I've been trying to finish a key mechanic in my project and I am one step away from hopefully completing it and being done with it.

I am in need of a plugin or script that can command a vehicle to turn transparent ON and OFF on command, the transparent event command on page 2 only seems to apply to the party members on foot something I think MV has overlooked.
Alternatively I could easily change the vehicle graphic into nothing but I need to avoid that so that I do not clutter up my event pages/common events with several graphical changes over the course of the game.

If anyone can help me out here that would be extremely helpful!
 

magnaangemon01

Miles Montgomery
Veteran
Joined
Jun 7, 2014
Messages
479
Reaction score
284
First Language
English
Primarily Uses
RMVXA
That is a good question and could work in my game as well. Watching to find out the answer as well.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
847
First Language
English
Primarily Uses
RMMV
@Skurge If possible, you could use a one-line script to do that :

Code:
/**
* @method vehicle
* @param {string} name
* @param {boolean} transparent
* @return {object} The 'boat', 'ship', or 'airship' vehicle object.
*/
$gameMap.vehicle(name).setTransparent(transparent)

/** Example */
$gameMap.vehicle('ship').setTransparent(true)
 

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
How do I properly use this script?
I just get an error "cannot read property 'setTransparent of null
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
847
First Language
English
Primarily Uses
RMMV
Hmm, where are you using the script at? In a comment event, or?
 

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
Event and Common event use, it's all part of a map/room mechanic i've been trying to complete.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
847
First Language
English
Primarily Uses
RMMV
Hmm, could you take a screen shot of the event, or within the common event panel press CTRL+A to select all of the commands, and then Right-Click > 'Copy as Text' so you can paste the text of the event into a post.
 

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
◆If:Button [Cancel] is pressed down
◆Script:Galv.SPAWN.clear(0,true);
◆Control Switches:#0007 VEHICLE ENTRY = ON
◆Common Event:MAP ROOM [EXIT]

:End
◆If:Button [OK] is pressed down
◆Script:Galv.SPAWN.clear(0,true);
◆Control Switches:#0007 VEHICLE ENTRY = ON
◆Common Event:MAP ROOM [EXIT]

:End
I pretty much a script or plugin command to enable the vehicle's transparency on or off. I intend to have it happen after the teleport even is commenced.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,577
Reaction score
875
First Language
Dutch
Primarily Uses
RMMV
@Skurge he meant a screenshot where you used the script and how you used it.
if the common event is the scriptcall above, than how is the script used?

as plugin or scriptcall?

also the event above can be smaller if you do:

◆if: script: input.isPressed("cancel") || input.isPressed("ok")
◆Script:Galv.SPAWN.clear(0,true);
◆Control Switches:#0007 VEHICLE ENTRY = ON
◆Common Event:MAP ROOM [EXIT]
: end

unless 1 ENTRY should be false? or different common event.
 

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
Oh, I literally cut and pasted the script, I don't really know what difference a plugin call or script call makes.

The common events are there to garentee each button press results in the same but I could perhaps just combine it.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
530
Reaction score
232
First Language
English
Primarily Uses
RMMV
Are you using the Change Transparency event command, or the movement route command? I think the following plugin (untested) should patch the Change Transparency event command so that if the player is in a vehicle then the vehicle will be made transparent instead of the player:

JavaScript:
(function() {
    Game_Interpreter.prototype.command211 = function() {
        var transparent = this._params[0] === 0;
        if($gamePlayer.isInVehicle()) $gamePlayer.vehicle().setTransparent(transparent)
        else $gamePlayer.setTransparent(transparent);
        return true;
    };

    var old_getOnVehicle = Game_Player.prototype.updateVehicleGetOn;
    Game_Player.prototype.updateVehicleGetOn = function() {
        var canGetOn = !this.areFollowersGathering() && !this.isMoving();
        var fixTransparent = canGetOn && this.isTransparent();
        old_getOnVehicle.call(this);
        if(fixTransparent) {
            this.vehicle().setTransparent(true);
        }
    };

    var old_getOffVehicle = Game_Player.prototype.updateVehicleGetOff;
    Game_Player.prototype.updateVehicleGetOff = function() {
        var canGetOff = !this.areFollowersGathering() && this.vehicle().isLowest();
        var fixTransparent = canGetOff && this.vehicle().isTransparent();
        if(fixTransparent) {
            this.vehicle().setTransparent(false);
        }
        old_getOffVehicle.call(this);
        if(fixTransparent) {
            this.setTransparent(true);
        }
    };
})();
A similar approach may work for the movement route command, but it's a bit trickier to implement since movement route commands are not aliasable.
 

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
I was using just the 'change transparency' event command but that does not make the vehicle invisible when driven.

Been giving it tests but it seems to render the vehicle invisible when exiting it after doing map teleportation.

I think I would prefer the option to have a command made via script call or plugin command to handle this just for the sake of avoiding bugs, having it built in second hand into the engine seems to have a few unexpected faults rather than a plugin. I hope that isn't too much to ask :o
 
Last edited:

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
530
Reaction score
232
First Language
English
Primarily Uses
RMMV
If you just want to make the vehicle transparent or not transparent, create a "script" command in the event (not a plugin command) and paste in one of the following lines:

JavaScript:
$gamePlayer.vehicle().setTransparent(true);

$gameMap.vehicle('boat').setTransparent(true);
This is the same as what @Ossra said. The first version of it only works if the player is in a vehicle and applies the transparency to that vehicle. The second version applies it to a specific vehicle of your choice.
 

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
OK i'm terribly confused right now, I don't know if I'm supposed to have the plugin installed in order for this to work or just to use these lines of a script in the call, either way I've been putting the script calls in the event sequence where I need the boat vehicle to turn transparent and when to return visible but something is causing them to behave like so;


Now i'm not 100% sure I'm doing this correct but if I wish to toggle this vehicle transparency off (visible) I set the line to false instead of true?

I really appreciate the help here everyone, i'm just having difficulty figuring out what to do.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
530
Reaction score
232
First Language
English
Primarily Uses
RMMV
It depends which version you use.
The first multi-line version I posted is a plugin, which (assuming it works - I didn't test it) will cause the game to set the vehicle transparent if you use a Change Transparency command while the player is in a vehicle.

The version Ossra posted, which I added to in my second post, is something that you would copy-paste into a Script Command node in your event. To make it visible again, you change true to false just as you guessed.
 

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
Sorry to report but I'm still getting the same results previously with both script calls made seperately.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
847
First Language
English
Primarily Uses
RMMV
Hmm ... that is rather strange. The javascript snippet "$gameMap.vehicle('boat').setTransparent(true);" really should work, if you want to turn the 'boat' vehicle transparent. "setTransparent(false)" should work to cause the vehicle to appear, too.

Are you using any plugins that might affect the player or vehicles? Are you using the 'Set Vehicle Location' command in a common event? If you transfer to another map and then come back, the transparency is probably going to be reset to the default value (true). Depending on what is going on, we can debug from there.
 

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
I am using a plugin that makes the player vehicle physically larger than the 48x48 tile sizes i.e 3 blocks when facing horizontal and 2 blocks long when vertically facing. But I'm fairly certain size shouldn't be effecting the general visibility of it, I could be wrong.

Other vehicle effects from various plugins alter speed and steering/acceleration but I feel they wouldn't be behind this either.

To handle the player's transparency I simply use the transparency command on page 2 which by all means works fine. But using the script commands seems to make the program confuse the sequences either way.

I have this handled by conditional branch defining whether the boat is currently driving that should make the script command take effect; else is supposed to just use the regular transparency option that applies to characters normally.
sgsd.png
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
530
Reaction score
232
First Language
English
Primarily Uses
RMMV
Why do you need a plugin to make the vehicle larger? The vehicle is a "character" so it should support arbitrary-sized sprites. Unless the issue is collision rather than just size..
 

Skurge

" (GASP) What's going on!? "
Veteran
Joined
Jul 12, 2015
Messages
1,195
Reaction score
268
First Language
English
Primarily Uses
N/A
My vehicle graphics are larger than the default 48x48 grid and needed a plugin to accommodate there size.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I stumbled upon 2 articles about why time goes faster as we age, and how to "slow down time".
Check them out, very interesting read. :D
Faster Time
Slower Time
Anyone can recommend a good gaming mouse? My mouse wheel has given up. Last mouse was steel series diablo iii edition (I know, it's been a while)
And then I figured out a way to doing a "regular animation" that's affected by PIXI particles. So now each frame of the animation gets particle effects. Soon my dreams of a world without QSprite will be realized. :kaopride:
Currently every NPC in my RPG gets a name, its kinda useless to name all, but Its also cool, somehow.
Biggest prob is to come up with different names. xD
I'm back from my visit to my family. Was really great to see them again after a year even if I had to get tested for covid for the visit.

Forum statistics

Threads
104,267
Messages
1,005,104
Members
135,778
Latest member
Moguta
Top