Hey guys, i'm totally new to javascript and scripting in general. I use RPG Maker MV
I try to write my first plugin atm, i want to be able to place "decoration objects" out of my inventory on the map.
I'm sorry for my bad english and any spelling mistakes, but i'm not a native speaker. 😕
so far it looks like this:
if i use an item in the inventory i want to place, it calls a common event (trough the item effect thingy)
wich has only a plugin command to run my plugin. (Plugin Command: placeobjects)
the code then should read the notetag of the last used item (the one i selected to be placed). [SIDE QUESTION]: reading the notetag works fine as long as i put a number in there (example: $dataItems[1].note; would give me the notetag of item 1)
but i can only get the item Id with $gameParty.lastItem() when i selected the item through the Select Key Item option on the first event-editor page, not when i just clicked the item in the inventory. what syntax do i need to use for this?
after that i use the GDT.Core.parseTag to identify, if the notetag is meant for my plugin (if it has KS: placeobjects: in it)
when the notetag is split up and everything is stored in variables, i run a common event (wich one is specified in the plugin parameters), wich turns character 'through' ON and change speed to be faster. I do this with a common event because i couldn't figure out the right syntax to do it in the plugin, but hey, it works and don't require much setup, after all it's my first plugin.
then i change the character image to look like the object i want to place (what image and wich character on this picture to use is part of the notetag). this all works fine.
now we get to the real reason i write this post:
after the character image changes, i want my character to be able to walk around, and as soon as i press 'ok' aka enter-button,
i want the rest of the plugin to happen (create event with right image and size (i will try to examine Galv_EventSpawner and YEP_Event_Hitbox_Resize to learn how this could work), check if no other event is in the way and a few other things, but these are future problems). so basically i need the script to stop until a specific condition (Input.isTriggered('ok'))
is fulfilled.
i watched several tutorials on async / await, but i could'nt figure out how i can implement this in my plugin.
i also read in a thread that rpg maker mv couldn't handle async/await, but i don't know if that is true.
so what i actually ask for is: what code do i need to use to tell my script it should wait, until 'ok' is triggered?
it doesn't need to be async/await if there are other options, i'm happy with any solution that works for now.
thanks in advance for any suggestions!
here is the code i have so far:
I try to write my first plugin atm, i want to be able to place "decoration objects" out of my inventory on the map.
I'm sorry for my bad english and any spelling mistakes, but i'm not a native speaker. 😕
so far it looks like this:
if i use an item in the inventory i want to place, it calls a common event (trough the item effect thingy)
wich has only a plugin command to run my plugin. (Plugin Command: placeobjects)
the code then should read the notetag of the last used item (the one i selected to be placed). [SIDE QUESTION]: reading the notetag works fine as long as i put a number in there (example: $dataItems[1].note; would give me the notetag of item 1)
but i can only get the item Id with $gameParty.lastItem() when i selected the item through the Select Key Item option on the first event-editor page, not when i just clicked the item in the inventory. what syntax do i need to use for this?
after that i use the GDT.Core.parseTag to identify, if the notetag is meant for my plugin (if it has KS: placeobjects: in it)
when the notetag is split up and everything is stored in variables, i run a common event (wich one is specified in the plugin parameters), wich turns character 'through' ON and change speed to be faster. I do this with a common event because i couldn't figure out the right syntax to do it in the plugin, but hey, it works and don't require much setup, after all it's my first plugin.
then i change the character image to look like the object i want to place (what image and wich character on this picture to use is part of the notetag). this all works fine.
now we get to the real reason i write this post:
after the character image changes, i want my character to be able to walk around, and as soon as i press 'ok' aka enter-button,
i want the rest of the plugin to happen (create event with right image and size (i will try to examine Galv_EventSpawner and YEP_Event_Hitbox_Resize to learn how this could work), check if no other event is in the way and a few other things, but these are future problems). so basically i need the script to stop until a specific condition (Input.isTriggered('ok'))
is fulfilled.
i watched several tutorials on async / await, but i could'nt figure out how i can implement this in my plugin.
i also read in a thread that rpg maker mv couldn't handle async/await, but i don't know if that is true.
so what i actually ask for is: what code do i need to use to tell my script it should wait, until 'ok' is triggered?
it doesn't need to be async/await if there are other options, i'm happy with any solution that works for now.
thanks in advance for any suggestions!
here is the code i have so far:
JavaScript:
var _Game_Interpreter_pluginCommand =
Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command) {
_Game_Interpreter_pluginCommand.call(this, command);
if (command.toLowerCase() === 'placeobjects') {
var notetag = $dataItems[HELP: how do I get the Id of the last used item out of inventory?].note;
var value = GDT.Core.parseTag(notetag, "placeobjects");
var a = value.split(",");
var width = a[0]
var height = a[1]
var layer = a[2]
var img = a[3]
var char = a[4]
var ground = a[5]
var ground_txt = a[6]
$gameTemp.reserveCommonEvent(cevent)
$gameActors.actor(1).setCharacterImage(img, char);
$gamePlayer.refresh();