JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 95 of 171 View original ↗
  1. I stand corrected on both counts.
  2. hmm i wonder why the mod moved my thread when i clearly said the author who originally posted it is not responding. I even already posted there, the last comment was mine. I posted in javascript support so somebody here could help me. Now I'm back with no help.
  3. shukrin said:
    hmm i wonder...
    What are you talking about? You just wrote this in a thread for basic JavaScript questions. Any questions about moderator actions have nothing to do with that. And if you had a question about a plugin, that also wouldn't have anything to do with this thread.

    I don't see any thread of yours that was moved anyplace, unless it was completely deleted which they don't normally do.
  4. ATT_Turan said:
    What are you talking about? You just wrote this in a thread for basic JavaScript questions. Any questions about moderator actions have nothing to do with that. And if you had a question about a plugin, that also wouldn't have anything to do with this thread.

    I don't see any thread of yours that was moved anyplace, unless it was completely deleted which they don't normally do.
    sorry but i dont know how to reach the mod and i thought posting here probably had a chance of them reading this

    yes they do moved my thread, it was just a small request hoping somebody look at my edits on a script that has a bug, it was turned into a comment (called "merge'") and placed in the original post from the author, which are already gone quiet and probably abandoned :(
  5. shukrin said:
    sorry but i dont know how to reach the mod and i thought posting here probably had a chance of them reading this
    If you click the word "Help" in the first row of words you see on the page, it will take you to the forum rules, which include what to do when you disagree with moderator action. Of all the things you might do, randomly posting your question in an existing thread makes the least sense :guffaw:
  6. i'm trying to make a skill , using skill core, only visible under two conditions
    actor has state and specific weapon equipped
    or
    actor has state and specific switch is on

    i bet it is something small but what am i doing wrong?

    <Custom Show Eval>

    if (user.isStateAffected(22) && $gameActors.actor(1).isEquipped($dataWeapons[2]))

    || (user.isStateAffected(22) && $gameSwitches.value(1) == true) {

    visible = true;

    } else {

    visible = false;

    }

    </Custom Show Eval>
  7. cubeking1 said:
    i bet it is something small but what am i doing wrong?
    Well...a couple of things, not all that small.
    cubeking1 said:
    if (user.isStateAffected(22) && $gameActors.actor(1).isEquipped($dataWeapons[2]))
    There are two things wrong here. First, you're referencing user and $gameActors.actor(1), which means you may well be checking someone else's weapon. You should use user again.

    Secondly, the format of a conditional statement is if (condition) stuff
    You're closing out the parentheses in the statement above, which means the only part of this that's actually getting evaluated is if state and weapon - because the if state and switch is in an entire separate set of parentheses, it doesn't mean anything.

    So if you want to do if ((thing && thing) || (thing && thing)) they all need to be inside one set of parentheses, like that. However, the entire construct is unnecessary, as boolean AND has a higher precedence than OR in the order of operations, so you don't need those extra parentheses at all.

    In this specific case, because you're starting with the same thing both times (having a specific state), you can make it even shorter by asking if (thing && (thing || thing))
    cubeking1 said:
    visible = true;

    } else {

    visible = false;
    It's not anything wrong, but a couple of tips to make your code a bit cleaner here.
    1) A conditional (if/else) automatically applies to the next single statement. You only need braces if you have multiple code statements that you want included in that condition. So you can simply do:
    Code:
    if (condition)
        thing
    else
        thing

    2) Any time you find yourself making an if/else where the only thing you do is say one thing is true or false, you can always get rid of that and just set it in the original condition. You also don't need to check if things == true or false, you can just ask if thing or if !thing (which you did in most of it, except for the switch for some reason). So a more efficient version, with the correct syntax for your condition, is:
    Code:
    <Custom Show Eval>
    visible = user.isStateAffected(22) && (user.isEquipped($dataWeapons[2]) || $gameSwitches.value(1));
    </Custom Show Eval>

    P.S. You should always use the code tags in your forum posts (the </> icon), so that it preserves your indents and brackets.
  8. Is it possible to get the events/number of events on a map that the player is not currently on?

    $gameMap.events() returns the events on the map where the player is, but say e.g. I'm on map 3 and want to find the number of events on map 5. Is that possible with a script call?
  9. Hey everyone, in rpg maker mv, is there a script call for when an item is used?

    I have a fishing pole as a normal non consumable item (so i cant make a variable to check for quantity changes) and whenever I use it from a hotbar my fishing minigame starts, I'm using region ids to determine the fishing nodes and I just want to make it so if the fishing pole is used in region 30, the minigame starts.

    So something like
    if : script : $gamePlayer.regionId()==30 && (the item "fishing pole" was used) = run common event

    Thanks for reading :LZSsmile:
  10. LadyBaskerville said:
    Is it possible to get the events/number of events on a map that the player is not currently on?
    I'll be interested to see if anyone else says differently, but from what I can see, no. It looks like the entirety of map data is loaded from disk when they're accessed, then purged when left. Even self-switches, which can be set externally, aren't actually kept inside the map events, but in an external list.
    raffle said:
    Hey everyone, in rpg maker mv, is there a script call for when an item is used?
    if : script : $gamePlayer.regionId()==30 && (the item "fishing pole" was used) = run common event
    You're approaching this slightly backwards - you would attach a common event to your fishing pole in the Effects list, so that gets called every time you use the pole.

    You can actually do this without scripting: you'd use event commands to Control Variable twice and store the X and Y value of the player's current position, then use the Get Location Info on tab 3 to store the region ID into a third variable. Then you do a Conditional Branch checking the value of that variable.

    If you want to use a script call to make that more efficient, then it's Conditional Branch -> Script -> $gamePlayer.regionId()==30

    Either way, you'd use that conditional, then just call your fishing game event from that.
  11. Thank you so much once more, it's working perfectly now :D
  12. ATT_Turan said:
    I'll be interested to see if anyone else says differently, but from what I can see, no. It looks like the entirety of map data is loaded from disk when they're accessed, then purged when left. Even self-switches, which can be set externally, aren't actually kept inside the map events, but in an external list.
    You are quite correct as there is no variables to access this values. They are indeed generated dynamically on map load. But this is also the answer: It has to be possible, because the game itself does this on every map load.

    So i pulled all related functions together and endet up with a (somehow) functioning way:

    1.) Put this code in a plugin
    JavaScript:
    var _myRequestedMapData = {};
    function loadMyMapData (mapId) {
        if (mapId > 0) {
            const filename = "Map%1.json".format(mapId.padZero(3));
            console.log(filename);
            loadDataFile("$dataMap", filename);
        } else {
            //this.makeEmptyMap();
        }
    }
    
    function loadDataFile (name, src) {
        const xhr = new XMLHttpRequest();
        const url = "data/" + src;
        xhr.open("GET", url);
        xhr.overrideMimeType("application/json");
        xhr.onload = () => onXhrLoad(xhr, name, src, url);
        xhr.onerror = () => onXhrError(name, src, url);
        xhr.send();
    }
    
    function onXhrError (name, src, url) {
        const error = { name: name, src: src, url: url };
        console.log(error);
    }
    
    function onXhrLoad (xhr, name, src, url) {
        if (xhr.status < 400) {
            _myRequestedMapData = JSON.parse(xhr.responseText);
        }
    }

    2.) Call this from as a script call ingame
    JavaScript:
    let mapId = 3;
    loadMyMapData(mapId);

    Then the reqired values are obtained as:
    _myRequestedMapData to gain all Map data
    _myRequestedMapData.events.length to gain the event count on that map

    The only problem is the asynchronous callback function that handles the file load. So in most times that value is obtained directly, but it may also still be the old value of a former map data request (or undefined).
  13. Hi,

    Where can I find the function to edit the location of faceset in a dialog box?
  14. @Chaos17

    you may mean
    JavaScript:
    Game_Message.prototype.setFaceImage = function(faceName, faceIndex)
  15. ST0RMTiger said:
    @Chaos17

    you may mean
    JavaScript:
    Game_Message.prototype.setFaceImage = function(faceName, faceIndex)
    No, I really meant to move it out and not to call it separately like in this picture featuring an MZ plugin.
    firefox_MEI4qMu4wu.png
  16. Chaos17 said:
    No, I really meant to move it out and not to call it separately like in this picture featuring an MZ plugin.
    Ah okay.

    The Face Image is drawn here:
    JavaScript:
    Window_Message.prototype.drawMessageFace = function() {
        const faceName = $gameMessage.faceName();
        const faceIndex = $gameMessage.faceIndex();
        const rtl = $gameMessage.isRTL();
        const width = ImageManager.faceWidth;
        const height = this.innerHeight;
        const x = rtl ? this.innerWidth - width - 4 : 4;
        this.drawFace(faceName, faceIndex, x, 0, width, height);
    };

    You have to change this function to drawFace on other X/Y positions
    this.drawFace(faceName, faceIndex, YOUR_X, YOUR_Y, width, height);

    This plugin that you mentioned seems to make a new window to draw on beforehand.
  17. ST0RMTiger said:
    You are quite correct as there is no variables to access this values....But this is also the answer: It has to be possible
    Obviously it's possible, or the games couldn't be played :stickytongue:

    But that is substantially more complicated than "a script call" that the OP was asking about.
  18. How can I get events/enemies that are at x/y tile relative to the main actor? (Example; I press 'a' to slash my sword left. I want to damage enemies on the tile directly left of me)
  19. Sethorion said:
    How can I get events/enemies that are at x/y tile relative to the main actor? (Example; I press 'a' to slash my sword left. I want to damage enemies on the tile directly left of me)
    So you can do that with a few lines of code, but before going through that - you do know there are existing plugins to give you an on-map battle system? If you look for ABS you'll find plenty of stuff already written, which may save you considerable time.
  20. If I use:

    this.addState(VAR);

    to apply a state to an actor, do I need to take some action to refresh the actor's data structure?

    I am writing a gender plugin that sets gender and applies states automatically to male and female actors. You can set gender either by notetag or by plugin command. (The idea of the plugin commands is for games that allow the player to customise their character at the start of a new game.)

    When testing with an event that uses the plugin commands to change the gender of an actor, I found that the first change of gender for an actor always applies the state selected in the parameters after setting gender. Rlepeated changes of gender without moving the party don't. If I change an actor's gender, move the party a very short distance and return to the event, then change an actor's gender again, the state is applied as intended.

    It seems to me that some kind of update or refresh happens whenever the party is moved. Is there anything that I could include to make adding the state more reliable?

    The bit that I use to do the gender change is below:

    Game_Actor.prototype.changeGender = function (newGender) { this.removeState(maleActorState); this.removeState(femaleActorState); this.gender = newGender; if (this.gender == 2) { this.addState(maleActorState); }; if (this.gender == 3) { this.addState(femaleActorState); }; };