Thanks for the correction.
$gamePlayer and events have a screenX() and screenY() method that should be what you're looking for.
Thanks for the correction.
$gamePlayer and events have a screenX() and screenY() method that should be what you're looking for.
Hi,no,that still gives me the distance in grids,grids are 48x48 pixels and i am using a pixel movement plugin,for example a map of 13x17 grids have 624x816 pixels and i want to know if there is a way to store in a variable,for example,that i am exactly in the pixel 60 of the X axis
In that case, I Googled "RPG Maker MV script pixel location" and found this thread which should be helpful.
Thanks,this is what i was looking for
pluginManager.registerCommand
var goods = []; var item_dupe = []; var weap_dupe = []; var gear_dupe = []; var scroll_dupe = []; var i = 0;
while (i < 4) { var id = 1 + Math.randomInt(14); var c = Math.round($dataItems[id].price / 3 * 2); var n = item_dupe.includes(id); n == true ? i = i : item_dupe.push(id) && goods.push([0,id,1,c]) && i++; }
while (i < 6) { var id = 1 + Math.randomInt(46); var c = Math.round($dataWeapons[id].price / 3 * 2); var m = weap_dupe.includes(id); m == true ? i = i : weap_dupe.push(id) && goods.push([1,id,1,c]) && i++; }
while (i < 8) { var id = 1 + Math.randomInt(49); var c = Math.round($dataArmors[id].price / 3 * 2); var o = gear_dupe.includes(id); o == true ? i = i : gear_dupe.push(id) && goods.push([2,id,1,c]) && i++; }
while (i < 10) { var id = 15 + Math.randomInt(18); var c = Math.round($dataItems[id].price / 3 * 2); var s = scroll_dupe.includes(id); s == true ? i = i : scroll_dupe.push(id) && goods.push([0,id,1,c]) && i++; }
$gameVariables.setValue(2,goods);
var goods = []; var item_dupe = []; var weap_dupe = []; var gear_dupe = []; var scroll_dupe = []; var i = 0;
while (i < 4) { var id = 1 + Math.randomInt(14); var c = Math.round($dataItems[id].price / 3 * 2); var n = item_dupe.includes(id); n == true ? i = i : item_dupe.push(id) && goods.push([0,id,1,c]) && i++; }
$gameVariables.setValue(2,goods);
var goods = [];
var dupes_i = []; var dupes_w = []; var dupes_a = [];
var i = 0;
while (i < 4) { var id = 1 + Math.randomInt(14); var c = Math.round($dataItems[id].price / 3 * 2); goods.push([0,id,1,c]) && dupes_i.push(id) && i++; }
while (i < 6) { var id = 1 + Math.randomInt(46); var c = Math.round($dataWeapons[id].price / 3 * 2); goods.push([1,id,1,c]) && dupes_w.push(id) && i++; }
while (i < 8) { var id = 1 + Math.randomInt(49); var c = Math.round($dataArmors[id].price / 3 * 2); goods.push([2,id,1,c]) && dupes_a.push(id) && i++; }
while (i < 10) { var id = 15 + Math.randomInt(18); var c = Math.round($dataItems[id].price / 3 * 2); goods.push([0,id,1,c]) && dupes_i.push(id) && i++; }
$gameVariables.setValue(2,goods);
You've made a conditional, a boolean operation, that's just sitting there. I don't see how the syntax would be responsible for your error, but I have no clue what you're trying to accomplish instead of using semicolons to make it three code statements.
var goods = [];
var dupes_i = []; var dupes_w = []; var dupes_a = [];
var i = 0;
while (i < 4)
{
var id = 1 + Math.randomInt(14);
var c = Math.round($dataItems[id].price / 3 * 2);
if( !dupes_i.includes(id) )
{
goods.push([0,id,1,c]);
dupes_i.push(id);
i++;
}
}
// Do the same with weapons, etc.
$gameVariables.setValue(2,goods);
Yeah, it's so weird because like I said, the code used to work with no issue back when I originally created the project which was around half a decade ago now. Haven't really done anything to it since but it just seems to have stopped working for no discernible reason.
TypeError: undefined is not a function
at Game_Interpreter.eval (eval at <anonymous> (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_objects.js:10500:10), <anonymous>:2:117)
at Game_Interpreter.command355 (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_objects.js:10500:5)
at Game_Interpreter.executeCommand (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_objects.js:8930:34)
at Game_Interpreter.update (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_objects.js:8838:19)
at Game_Map.updateInterpreter (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_objects.js:6115:27)
at Game_Map.update (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_objects.js:6022:14)
at Scene_Map.updateMain (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_scenes.js:608:14)
at Scene_Map.updateMainMultiply (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_scenes.js:600:10)
at Scene_Map.update (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_scenes.js:589:10)
at Function.SceneManager.updateScene (file:///E:/RPG%20Maker/RPGMaker%20MZ%20Projects/Code%20Test/js/rpg_managers.js:2024:25)
Yeah, I'm aware of some ABS plugins. I want more control over the gameplay mechanics than they currently give me, however. I have a simple, but very specific, system in mind. I'm also learning how to manage large projects while I bulk up my resume, so making it myself will be a good experience.
$gamePlayer and its methods, but I'm struggling to understand
Game_Interpreter.prototype.command285. ('Get Location info') How do I use it? It seems to return a boolean, not a table on info for the given map location.That is...really confusingly worded. The portion of code I quoted was notthe conditional portion of an if statement, nor was it part of a ternary conditional, it was just a statement of code.
if (d>1)
{
thing;
other thing;
}
That error stack doesn't seem to reference the includes function at all.
Do you mean MZ? Because your filepath up there is referencing MZ.
If you read through the rest of it, you can see where it's using elements of params (the argument(s) passed into the function) to set values in game variables.
Nah, I mean MV. I don't have an MV project folder anymore seems for the most part I just use MZ these days (and the project I'm trying to fix is from an old storage device). I just created a fresh project to test BurningOrca's suggested code snippet in MV that I created in the same folder I use for my MZ projects, if that makes sense. Which is where that error is from. But the error that comes up in the console on the original project is similar to that; I just tested the code in a fresh project second which is why that's the one I quoted.
No I know that, but the part of the code you quoted was the tail-end of the working code that I ended up with (the complete version of which does not include the duplication check), not the original code that was crashing the game. Basically I'm saying, my bad coding standards being hard to read aside perhaps, that nothing in the part of the code you quoted is causing any issues.
Once again, my understanding of these things is limited, but I was under the impression it doesn't reference the includes function because it doesn't think it exists? It just complains about an "undefined" right at the start, with "undefined" being the includes function; Then it's checking all those JS methods/files in the console lines and not finding it in any of them?
Well, that's easy to test. Play test your game, hit F8, go to the console, and type in:
var test=[1, 2, 3];
test.includes(2);
Ah, that makes sense. Rather than alter the information for that location, how can I just retrieve information? Like the events that are there, for instance? Eventually, command285 might be all I need, but only if that's all I have to work with.
I think you're misunderstanding something - that's all the function does, is retrieve information. It does not allow you to alter anything on the tile.
It's right there in the switch statement for params[1]:
case 1: // Event ID$gameMap._interpreter.command285(9, 1, 0, 56, 42); it would put the event ID present on tile 56, 42 into game variable 9.$gameParty.leader() to get the main player actor, lol. That will help.There's no need for anything involving JavaScript that I can see - if you have the player's X and Y in variables, just use event commands to subtract whatever amount from the Y variable to make it appear higher on the screen (0, 0 is the upper-left corner).
Original thread: https://forums.rpgmakerweb.com/threads/javascript-questions-that-dont-deserve-their-own-thread.46341/