JavaScript questions that don't deserve their own thread

10theodie10

Villager
Member
Joined
Aug 14, 2012
Messages
8
Reaction score
0
First Language
English
Primarily Uses
@KockaAdmiralac
It works! Thanks. I appreciate the variable addition too; it helps a lot  :D
 

lolbriefcase

Warper
Member
Joined
Nov 14, 2015
Messages
4
Reaction score
2
First Language
English
I want to check what states a character has in battle. I've tried $gameParty.members()[0].states().

If I assign it to a variable and concatenate a string to it (otherwise it just crashes), I will get "[object Object]" repeated an amount equal to the number of states affecting the [0]th party member.

From the RMMV Script Calls thread/spreadsheet, I could not get $game_actors[X].states.include?($data_states[Y]) to work either (I have tried $gameActors.actor().states.include?($dataStates[Y]) and variations to no avail as well).

What am I doing wrong, and/or what would be the way to check states? For reference, I am an extreme beginner to both Javascript and RPG Maker scripting.
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
@lolbriefcase

You should use $gameActors.actor(actor_id).states() to access his states.

And I'm not sure if .include? method exists in JS.

And it's strange that thing with $gameParty isn't working, did you try to log it to console?

EDIT : Use includes() instead of include?().

Looks like below certain point in script call list are listed only RGSS script calls...
 
Last edited by a moderator:

Joronjo

Veteran
Veteran
Joined
Sep 17, 2015
Messages
155
Reaction score
29
First Language
English Spanish
Primarily Uses
I want to make it so that when the shop window is open, the help window is at 2/3 of its size. I tried making an if/else but i only got an error. Here is what i did

 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
Try putting

Code:
if(SceneManager._scene instanceof Scene_Shop)
on line 2 of your code
 

Joronjo

Veteran
Veteran
Joined
Sep 17, 2015
Messages
155
Reaction score
29
First Language
English Spanish
Primarily Uses
For some reason i'm getting these errors (even though i haven't even touched Window_MapName)

 
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
That means you are editing whole rpg_windows.js, and it has thrown an error.

Maybe it's because I forgot { sign?

Your code should look like :

Code:
Window_Help.prototype.initialize = function(numLines) {  if(SceneManager._scene instanceof Scene_Shop){     // your code here  } else {     // your other code here  }}
 

Joronjo

Veteran
Veteran
Joined
Sep 17, 2015
Messages
155
Reaction score
29
First Language
English Spanish
Primarily Uses
That worked! I also realized that i made the syntax error by trying to remove MP from the screen by using this (but followed the instructions wrong). 

Also i found a way to get the help window to only be cut off when not in the battle scene. Thanks Kocka!

=======

Is there a way to divide the actor commands into two columns?
 
Last edited by a moderator:

lolbriefcase

Warper
Member
Joined
Nov 14, 2015
Messages
4
Reaction score
2
First Language
English
@lolbriefcase

You should use $gameActors.actor(actor_id).states() to access his states.

And I'm not sure if .include? method exists in JS.

And it's strange that thing with $gameParty isn't working, did you try to log it to console?

EDIT : Use includes() instead of include?().

Looks like below certain point in script call list are listed only RGSS script calls...
Figured out what I was doing wrong with your information Kocka, thanks for the help.
 

Lakaroth

Veteran
Veteran
Joined
Dec 9, 2014
Messages
272
Reaction score
129
First Language
English
Primarily Uses
There's a way to turn ON/OFF plugin in game?
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
No.

Unless maker of the plugin provided that option.
 
Last edited by a moderator:

10theodie10

Villager
Member
Joined
Aug 14, 2012
Messages
8
Reaction score
0
First Language
English
Primarily Uses
So I checked out the script call collection and noticed they didn't have a script call for 'Set Movement Route.' From what I remembered with VX ACE, it was a bit long and somewhat complicated, so I can understand why it wasn't listed. Anywho, I'm using a common event to set the movement route of the event id that I passed through it and having it wait for 90 frames and was wondering how to do that and what it looks like.

Basically what I'm trying to do:

Using Script Call:

Set Movement Route (Event ID)

Wait 90 frames

Thanks for your time guys
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,282
Reaction score
106
First Language
Irish
Primarily Uses
N/A
I have a question about meta / note tag.

I want to detect the note tag on my maps. How can I do just that?

I tried $dataMap.meta.match("mapX") but somehow I know this is wrong.
 

matthew30903

Veteran
Veteran
Joined
Jun 29, 2014
Messages
82
Reaction score
31
First Language
English
Primarily Uses
Is there a way to round down the value of a variable to a multiple of 5?

I am taking the percentage value of the HP and trying to round it so say, at value 34 the variable will be changed to 30. I looked up methods and I found:

5*(Math.floor(Math.abs($gameVariable.value(3)/5)));But it does not seem to work.

5*(Math.round($gameVariables.value(3)/5));Does not seem to work either.

Help would be greatly appreciated.
 

TheGamedawg

Veteran
Veteran
Joined
Aug 29, 2014
Messages
350
Reaction score
133
First Language
English
Primarily Uses
I want to try making my first plugin.  It'd be simple.  My thinking is to make a plugin that makes it so whenever a character gets a critical hit, the screen will flash and play a big *crack* sound.  Simple parameters could be defining the color the screen flashes as well as which sound effect plays.

Maybe if I want to get more advanced, I could perhaps try and make it so you can have the color change depending on the element of the attack, or if it was a magical attack and such.  But those would come later.

I've found the "The Absolute Basics of Plugin making" topic, but I would like to know how to get a bit more advanced.  Learning things such as how to find what to put in the code if I want to change certain things.
 

HonestInnocence

Villager
Member
Joined
Sep 30, 2015
Messages
13
Reaction score
16
First Language
English
Primarily Uses
Hello, I believe this question belongs here, but I may be wrong:

I know I can use v to make the main actor walk in place

$gamePlayer._stepAnime = true;What I'm wanting to know is what line of script I can use to make an Event use the step animation as well; possible to do this as a blanket, instead of setting the script call for each individual event?
 

Thank you for your time :]

EDIT: Found a way to do what I wanted, sort of. Just involved setting a second event page and making a switch to transfer to that page. For those wanting to do the same, set up another event page with the following: stepping animation turned on for the actor's image + a switch assigned to stepping animations (enabled for this new page).

When you want events to switch over to their stepping animations, use the following script call: 

Code:
//Replace <Switch number> with say, 1. So it looks similar to example: (1, true);$gameSwitches.setValue(<Switch number>, true);
 
Last edited by a moderator:

gloopmaster

Villager
Member
Joined
Jan 2, 2014
Messages
16
Reaction score
9
First Language
English
Hello. How would I access the actor associated with the in-battle actor command window (Window_ActorCommand) while running a function inside of that window? this._actor is undefined whenever I try to access it.
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
Wow, nobody answered those...

 

@10theodie10

It's very complicated.

If you want to set move route you would use

Code:
$gameMap.refreshIfNeeded();
$gameMap._interpreter.character(character_id).forceMoveRoute(object)
where character_id is :

- lesser than 0 you want to move the player

- 0 if you want to move this event

- event iD of specific event if you want to move specific event

And example of an "object" is
Code:
{
  list : [  // This is list of actions
    {code: 1, indent: null},   // code is iD of an action
    {code: 2, indent: null},   // And I have no idea what indent is 
    {code: 0} // At the end, there should always be a code: 0
  ],
  repeat: true,  // If repeating the action
  skippable: true,  // "Skip If Cannot Move"
  wait: false, // You don't really need this.
}
If you want event to "Wait for Completion" you would do :
Code:
$gameMap._interpreter.setWaitMode('route');
@Milena

I think you already got your answer, but you should use $dataMap.meta.your_note_name

 

@matthew30903

I think
Code:
yournumber - (yournumber % 5)
should work.

 

@TheGamedawg

There is a simple way to do such things.

For example, you can find a method where critical is executed by searching "critical" through code.

First occurence should be (at least when searching through Zalerinian's DevKit) in TextManager, where the line is
Code:
criticalToEnemy : TextManager.getter('message', 'criticalToEnemy'),
And then search for TextManager.criticalToEnemy .

First occurence : Window_BattleLog.prototype.displayCritical

Hmmm... Window is not a good place to do thing you requested, especially if some plugins remove it.

So let's look where Window_BattleLog.prototype.displayCritical is called.

First occurence : Window_BattleLog.prototype.displayActionResults

Hmmm... again, that not a good place.

Let's search where is Window_BattleLog instantiated.

You do that by searching for "new Window_BattleLog()"

First occurence : Scene_Battle.prototype.createLogWindow, line
Code:
this._logWindow = new Window_BattleLog();
So, that means we should search for
Code:
this._logWindow.displayActionResults
It's called on three places : BattleManager.invokeNormalAction, BattleManager.invokeCounterAttack and BattleManager.invokeMagicReflection.

I suppose you'll need something else then, this is still not the place either.

Look at line above this._logWindow.displayActionResults in BattleManager.invokeNormalAction : it's
Code:
this._action.apply(realTarget);
So, what is this._action?

You don't need to guess, we'll search for "this._action =".

First occurence : this._action = null.

Nah, it's not that.

Second occurence : this._action = action in BattleManager.startAction

What is "action"?

Several lines above :
Code:
var action = subject.currentAction();
What is "subject"?

One line above :
Code:
var subject = this._subject;
What is this._subject?

Search for "this._subject =" will have 4 results : in BattleManager.processTurn, BattleManager.processForcedAction, BattleManager.initMembers and BattleManager.updateTurn

BattleManager.processForcedAction is called when action is forced, so you might not need that.

BattleManager.processTurn is called when turn starts.

BattleManager.updateTurn is called between two actions

BattleManager.initMember is called when battle starts.

In this case, you'll need BattleManager.processTurn and BattleManager.updateTurn

In both there is a line :
Code:
this._subject = this.getNextSubject();
And what does this.getNextSubject(); do?

 

...

 

Do you understand it now?

Let me shorted your time, you are searching what this._action is, right?

It's instance if Game_Action, and in Game_Action.prototype.apply first line is :
Code:
var result = target.result();
target.result() is instance of Game_ActionResult, and Game_ActionResult has a property named "critical", so you can alias Game_Action.prototype.apply and add at the end :
Code:
if(result.critical)
{
    // Do your things here
}
 

@gloopmaster

When are you accessing it?

Try to add console.log("something"); in Window_ActorCommand.prototype.setup and check if "something" is logged to console before you access it.
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
858
First Language
German
Primarily Uses
I'm currently struggling to find out how set a viewport in MV/Pixi. I have a container (extends Sprite_Base) with a certain width/height and several children inside of it, but i can still draw outside the container sprite.


How can i just not render everything that would be outside the container bounds without having to clear and blt a bitmap everytime something changes?
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Me: "Finally finished most of my game backlog. Probably time to do some gamedev" | Steam: *offer sales*
If I recorded while I created (what I think is) a small plugin, would you be interested enough in the process to watch it?
I keep trying to explain to clients that the huddle masses behind the old K-Mart are a Fallout Reenactment group. Somehow I don't think they believe me. :LZSskeptic:
Hey people! What do you think about a core plugin? This will save some lines of code that I repeatedly use in all my plugins...
Wondering if I should make my enemies scale in my non-linear rpg. I'm leaning towards yes, but I don't want to use Yanfly's plugin...

Forum statistics

Threads
94,594
Messages
922,169
Members
124,465
Latest member
Spielmister
Top