RPG Maker MV / MZ Script Call List

● ARCHIVED · READ-ONLY
Started by Archeia 569 posts Page 6 of 29 View original ↗
  1. NoInkling said:
    @metronome 

    $gameParty.numItems($dataItems[n])$gameParty.numItems($dataWeapons[n])$gameParty.numItems($dataArmors[n])// or$gameParty._items[n]$gameParty._weapons[n]$gameParty._armors[n]// Get a variable:$gameVariables.value(n)// Set a variable:$gameVariables.setValue(n, value)// Your example: add V[1] and V[10] and put the result in V[11]:$gameVariables.setValue(11, $gameVariables.value(1) + $gameVariables.value(10))// or if that's a bit tough to read and you're able to use multiple lines:var temp = $gameVariables.value(1) + $gameVariables.value(10);$gameVariables.setValue(11, temp);
    Ah....I think these codes are wrong:

    $gameParty.numItems($dataItems[n])$gameParty.numItems($dataWeapons[n])$gameParty.numItems($dataArmors[n])// or$gameParty._items[n]$gameParty._weapons[n]$gameParty._armors[n]I tried script calling:

    $gameVariables.setValue(100, $gameParty._items[1]) or $gameVariables.setValue(100, $gameParty.numItems($dataItems[1]))where item 01 is 10 in my party possession

    when I call the \V[100] it returns 0 instead of 0......
  2. metronome said:
    $gameVariables.setValue(101, $gameVariables._data.reduce(function(sum,val,i){return i>=1 && i<=100 ? sum+val : sum}, 0))Always returns me 0 no matter what.......
    metronome said:
    I tried script calling:

    $gameVariables.setValue(100, $gameParty._items[1]) or $gameVariables.setValue(100, $gameParty.numItems($dataItems[1]))where item 01 is 10 in my party possession

    when I call the \V[100] it returns 0 instead of 0......
    It's giving you 0 because it's outside your max variable number (20 by default). Increase it and it should work.

    metronome said:
    And btw,

    the codes you provided me comes with error: unexpected tokens.

    You are putting too many semicolons perhaps?
    I retested everything I posted and didn't get errors. Sometimes copy/pasting can introduce an "unexpected token" error, I don't know why, be careful that you're not selecting anything extra (other people have been having this issue with other scripts). It may just be to do with the way the forums format things.

    metronome said:
    Using the js function you provided, I did script call to -let's say- sum all the item from item 1 to item 100 in party possession using codes below:

    $gameVariables.setValue(101, $gameParty.numItems(function(val,i){return i>=1 && i<=100}).reduce(function(sum,val){return sum+val},0))And it returns with Syntax Error: undefined is not a function hmmmm.

    may be I should set all the variables to 0 first right when the game starts?

    EDIT:

    I think the code I provided is wrong, I forgot that after $gameParty.numItems it should be (dataSomething), not a (function).
    Yeah, you can't pass that function to .numItems, it's only for use with .filter.

    $gameParty._items is available, but it's an object, not an array, so filter/reduce aren't directly usable. I'd probably do this:

    $gameVariables.setValue(101, Object.keys($gameParty._items).filter(function(itemId){return itemId>=1 && itemId<=100}).reduce(function(sum,itemId){return sum+$gameParty._items[itemId]},0))I gotta warn you that at this point you're beyond specific engine stuff and well into general JavaScript, which I think is outside the purpose of this topic. Your questions would probably be better posted in one of the JS subforums.
  3. NoInkling said:
     

    It's giving you 0 because it's outside your max variable number (20 by default). Increase it and it should work.

    I retested everything I posted and didn't get errors. Sometimes copy/pasting can introduce an "unexpected token" error, I don't know why, be careful that you're not selecting anything extra (other people have been having this issue with other scripts).

    Yeah, you can't pass that function to .numItems, it's only for use with .filter.

    $gameParty._items is available, but it's an object, not an array, so filter/reduce aren't directly usable. I'd probably do this:

    $gameVariables.setValue(101, Object.keys($gameParty._items).filter(function(itemId){return itemId>=1 && itemId<=100}).reduce(function(sum,itemId){return sum+$gameParty._items[itemId]},0))I gotta warn you that at this point you're beyond specific engine stuff and well into general JavaScript, which I think is outside the purpose of this topic. Your questions would probably be better posted in one of the JS subforums.
    Hi,

    after checking, I found out what the problem is.

    the codes are not wrong.

    I had yanfly item core plugin installed. And then after I turn the plugin off, it works.

    I think there is something in his plugin that always returns 0 for every item possession check.

    I have reported the problem to him.

    agreed. I think by now, my question has turned into something closer to Javascript than to RMMV itself lol

    I really missed the days where you could easily do SUM function script call easily back in RPGVXA....

    and btw you are right about the token error.

    checked it by typing them directly without copy paste and it works too

    You are awesome!~~

    Thanks a lot

    I feel bad annoying you >.<~~
  4. ($gameVariables.value(16) != 43 && $gameVariables.value(17) != 33)

    Ok, so I am using these two variables to check the players coordinates.  As long as they are not standing on that tile.  For some reason it is reading the &&

    like it is an or symbol.  Am I missing something?
  5. krizmn said:
    ($gameVariables.value(16) != 43 && $gameVariables.value(17) != 33)

    Ok, so I am using these two variables to check the players coordinates.  As long as they are not standing on that tile.  For some reason it is reading the &&

    like it is an or symbol.  Am I missing something?
    Let's call V[16] "x" and V[17] "y".

    If x = 40 and y = 30, the statement evaluates to true, so far so good.

    However if x = 43 and y = 30, the JS is gonna come along and evaluate the first part as 43 != 43 which is obviously false. After that, "false && anything" will always be false, because && specifies that both expressions have to be true for the whole condition to be true.

    To put it simply, you actually want an OR (||) in there when the conditions are exclusionary (!==). It's kind of the opposite to when you're doing inclusionary/positive conditions (===), in which you'd use AND. So yeah, it isn't very intuitive sometimes, but it can make sense if you work through the logic.
  6. Ok wait.  Is it != or !== or either?  You don't have to answer, I can just google it.  I am just being lazy and not spending time going through a quick day of brushing up on learning JS.  
  7. krizmn said:
    Ok wait.  Is it != or !== or either?  You don't have to answer, I can just google it.  I am just being lazy and not spending time going through a quick day of brushing up on learning JS.  
    != means "Not Equal"

    !== means "Not Equal value or Not Equal type"

    That means it must be the same "type" , it's mostly useful in cases where you might be checking if something is an Object, String, or null itself. When comparing two objects of the same type, both do the same thing. 

    === itself is described here.
  8. Have another question:

    Is there any script call in RMMV that's similar to this?

    SceneManager.call(Scene_Item)useful to call item menu when you want to show player what they have now in his/her inventory without going all the way from menu screen >.<~~

    is it:

    SceneManager.push(Scene_Item)
    not in front of my working computer right now sadly
  9. krizmn said:
    Ok wait.  Is it != or !== or either?  You don't have to answer, I can just google it.  I am just being lazy and not spending time going through a quick day of brushing up on learning JS.  
    To add to what KisaiTenshi said, it's recommended you always use the === and !== versions in order to prevent unexpected behavior due to dumb JS quirks around type coercion. Basically any reliable source will recommend this as a best practice. That's not to say that the == and != versions don't have legitimate uses in some contexts, but those are a very very small minority and until you know where they would be useful it's best to avoid them.

    http://stackoverflow.com/a/359509/2277117
  10. metronome said:
    Have another question:

    Is there any script call in RMMV that's similar to this?

    SceneManager.call(Scene_Item)useful to call item menu when you want to show player what they have now in his/her inventory without going all the way from menu screen >.<~~

    is it:

    SceneManager.push(Scene_Item)not in front of my working computer right now sadly
    Technically... all you need to do is invoke SceneManager.push(Scene_Item); because that's what rpg_scenes.js does.
  11. NoInkling said:
    @skyshadow235 You appear you be trying to use Ruby/RGSS, while MV uses JavaScript. Your syntax is completely off.

    @Blithe You can just call the same method on an actor object:

    // For a specific character:$gameActors.actor(id).startAnimation(animationId, mirror, delay) // Where mirror is true/false as you mentioned// For all characters in battle:this.iterateActorIndex(-1, function(actor) { actor.startAnimation(animationId, mirror, delay);});For a character in a certain position, see my post further up the page.
    Oh ... thank you o.o I guess the script list isn't complete then because I copied it off the RMMV Script Calls as best as I could. Thank you and I'll just use the regular message boxes then since I'm still not good at making my own or understanding the different languages yet ^-^
  12. Bookmarked this. This is awesome!
  13. Archeia said:
    Link here to see the entire list.

    Have fun eventing~
    Good I come to see if I can lend a hand with a question "grademente small" ...

    What is the call script to close the game in rpg maker MV?

    I am creating my own title and just do not give this code as do I need ...

    I've gotten the "SceneManager.exit" but this is not working.

    Help me plz: 3
  14. $gameSelfSwitches.setValue($gameVariables.value(7), 13, "A", true)

    Am I missing something?  I am trying to set another event's self switch.  

    Edit:  Just for additional information, variable 7 is the Map Id.  13 is the event.
  15. This is how a self switch is set by the Game_Interpreter (good to look at if you want to see how the engine does things by default):

    Code:
    Game_Interpreter.prototype.command123 = function() {    if (this._eventId > 0) {        var key = [this._mapId, this._eventId, this._params[0]];        $gameSelfSwitches.setValue(key, this._params[1] === 0);    }    return true;};
  16. Yeah I found that before.  I am not getting any errors, but I can't seem to switch an event's self switch on or off.....

    I must be missing something.  I'll keep trying.

    Edit:

    var key = [$gameVariables.value(7), 13, 'A'];

    $gameSelfSwitches.setValue(key, 1);

    Ok that works.  Thanks for making me look at that script more.  I thought I could just replace "key" with the variables all on one line.  I didn't think I needed to set it up like this.  Still getting used to JS.
  17. I updated the script call list with Call event :)
  18. Archeia said:
    I updated the script call list with Call event :)
    Thanks Archeia :)
  19. I'm trying to do a self switch in the movement aspect of an event.  The only time I need to do this is when I need the self triggers to wait a few seconds.  If I place it after the movement section it triggers to quick.  If I set a wait command in between the set of movement and the trigger, it causes my the character to wait  unless I set it as a parallel.  

    So anyways, does anyone know off hand how to self switch through script?  I could make an extra switch and do that, but I am trying to cut down on as many extra switches as possible to keep it organized and clean.  
  20. Hey guys,

    how do i use the

    AudioManager.playSe();I have     AudioManager.playSe('Fire2', 100,100, 0  )    but nothing happens :/

    Sound Object: { name: filename, volume: n, pitch: n, pan: n }

    pls help, I'm lost when my menu doesn't make sounds.