Well, for once Poryg needs help too :D
I want to save coordinates on screen through javascript.
In rpg_objects I found this function, which corresponds to Game data inside Variable operations.
Game_Interpreter.prototype.gameDataOperand
However, when I try to use it, it always throws 0. I noticed that $gameMap has its own interpreter, but doesn't help...
I wouldn't wonder if it couldn't be used as a function though, because there is only one function calling to it, and that is Variable operations, which would mean this function would be accessed only by the engine itself.
How to get events' screen coords through javascript?
● ARCHIVED · READ-ONLY
-
-
rephrase your question, it is not understandable.
and I do not see any script here, you seem are in wrong forum.
add your code and i will try to help you -
Code:
$gameMap.event(ID).x $gameMap.event(ID).y
Edit: Sorry, misread that. :rswt -
That's the map coordinates, not the screen coordinates.
Do you NEED to do it via script? The Control Variables command will let you do it, through Game Data.
If you are doing it via a script call, you can use this.character(n).screenX() and this.character(n).screenY(), where n is the event id (no leading zeros).
If you are making a plugin, use $gameMap.event(n).screenX() and $gameMap.event(n).screenY() -
@waynee95 that is map x and map y, not screen x/y :D
@Jonforum I'm trying to get x and y screen coordinates of an event. But not through default rpg maker commands, but through javascript instead.
The function I provided was found inside rpg_objects.
It is this one.Code:Game_Interpreter.prototype.gameDataOperand = function(type, param1, param2) { switch (type) { case 0: // Item return $gameParty.numItems($dataItems[param1]); case 1: // Weapon return $gameParty.numItems($dataWeapons[param1]); case 2: // Armor return $gameParty.numItems($dataArmors[param1]); case 3: // Actor var actor = $gameActors.actor(param1); if (actor) { switch (param2) { case 0: // Level return actor.level; case 1: // EXP return actor.currentExp(); case 2: // HP return actor.hp; case 3: // MP return actor.mp; default: // Parameter if (param2 >= 4 && param2 <= 11) { return actor.param(param2 - 4); } } } break; case 4: // Enemy var enemy = $gameTroop.members()[param1]; if (enemy) { switch (param2) { case 0: // HP return enemy.hp; case 1: // MP return enemy.mp; default: // Parameter if (param2 >= 2 && param2 <= 9) { return enemy.param(param2 - 2); } } } break; case 5: // Character var character = this.character(param1); if (character) { switch (param2) { case 0: // Map X return character.x; case 1: // Map Y return character.y; case 2: // Direction return character.direction(); case 3: // Screen X return character.screenX(); case 4: // Screen Y return character.screenY(); } } break; case 6: // Party actor = $gameParty.members()[param1]; return actor ? actor.actorId() : 0; case 7: // Other switch (param1) { case 0: // Map ID return $gameMap.mapId(); case 1: // Party Members return $gameParty.size(); case 2: // Gold return $gameParty.gold(); case 3: // Steps return $gameParty.steps(); case 4: // Play Time return $gameSystem.playtime(); case 5: // Timer return $gameTimer.seconds(); case 6: // Save Count return $gameSystem.saveCount(); case 7: // Battle Count return $gameSystem.battleCount(); case 8: // Win Count return $gameSystem.winCount(); case 9: // Escape Count return $gameSystem.escapeCount(); } break; } return 0; };
However, when I try to use it (which would in this case be something like Game_interpreter.prototype.gameDataOperand(5, 2, 3) for event 2 and screen x, the code throws me 0 every time. -
i think he talk about the
DataManager.
for save
am not shure !??? -
@pory
look at
PHP:am not shure but experimente and study thisvar myScreenEvent = ($gameMap.event(1).x*48); // screen var myReelScreenMapEvent = $gameMap._displayX * (myScreenEvent); // bindToMap -
@Jonforum I don't think datamanager would hide the screen coords, but will look there just for clarification.
@Shaz Thanks :D Completely forgot about these!
Btw. Since I was building a PIXI based dialog system, where I'm centering dialogs over events, it could do with the variables, but through the script it is much cleaner. Because I already have to take care of 2-5 events (depending on dialogues) and having to use 10 variables to save event locations plus 5 variables to know the event Ids... This way it's just cleaner, having only to save the event IDs. -
The reason your first attempt didn't work is that it's a function of the Game_Interpreter object. If you're building a plugin, unless you put the code in the Game_Interpreter class, it doesn't have access to that object. You were running it out of scope, so there was no this to get the character (event) from. But you could have looked further into that function and seen that, once it has the character (event), it calls exactly the same functions that I gave you :)
-
I looked further than that, just not at the right place :D
Well, that was overlooking forest through a tree. Thanks a bunch, you have definitely saved my nerves for a couple of weeks :)