I stand corrected on both counts.
JavaScript questions that don't deserve their own thread
● ARCHIVED · READ-ONLY
-
-
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.
-
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.hmm i wonder...
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 thisWhat 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.
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 :( -
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:sorry but i dont know how to reach the mod and i thought posting here probably had a chance of them reading this
-
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> -
Well...a couple of things, not all that small.i bet it is something small but what am i doing wrong?
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.if (user.isStateAffected(22) && $gameActors.actor(1).isEquipped($dataWeapons[2]))
Secondly, the format of a conditional statement isif (condition) stuff
You're closing out the parentheses in the statement above, which means the only part of this that's actually getting evaluated isif state and weapon- because theif state and switchis in an entire separate set of parentheses, it doesn't mean anything.
So if you want to doif ((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 askingif (thing && (thing || thing))
It's not anything wrong, but a couple of tips to make your code a bit cleaner here.visible = true;
} else {
visible = false;
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. -
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? -
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: -
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.Is it possible to get the events/number of events on a map that the player is not currently on?
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.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 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. -
Thank you so much once more, it's working perfectly now :D
-
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.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.
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). -
Hi,
Where can I find the function to edit the location of faceset in a dialog box? -
@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.@Chaos17
you may mean
JavaScript:Game_Message.prototype.setFaceImage = function(faceName, faceIndex)
-
Ah okay.No, I really meant to move it out and not to call it separately like in this picture featuring an MZ plugin.
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. -
Obviously it's possible, or the games couldn't be played :stickytongue:You are quite correct as there is no variables to access this values....But this is also the answer: It has to be possible
But that is substantially more complicated than "a script call" that the OP was asking about. -
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.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)
-
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); }; };