Hello, can anyone help me edit a plugin? MBS - Visual Equipment uses notetags on a event to call a equipment and show the graphic above the event, it can call many equipments. But it would be a immense help if the notetag could read a variable, any help?
MV Event Notetag that reads Variables
JS Plugin Requeststhere seems to be one already that reads in the helpfile:
Code:
If you want, you can also use the following tag on an event's notes to make
the script draw equipments on it:
<equips:a id1, w id2, a id3...>
The equipments are specified by using the first letter of the equipment
type (that is, a for Armor and w for Weapon) followed by its ID. Ex.:
<equips: a 1, w 2>
ye but I didn't managed to make it read a variable :/
it returns a number, so a number needs to be set, in that case,
you can try 2 things here on line 297 you read this bit.
the 2nd return what you set, the bottom with eval return the output.
I think the 2nd should work, but it should return a number to be readed.
you can try 2 things here on line 297 you read this bit.
JavaScript:
if (t[0] === 'a') {
equip = $dataArmors[Number(t[t.length - 1])];
} else if (t[0] === 'w') {
equip = $dataWeapons[Number(t[t.length - 1])];
}
// make it read
if (t[0] === 'a') {
equip = $dataArmors[(t[t.length - 1])];
} else if (t[0] === 'w') {
equip = $dataWeapons[(t[t.length - 1])];
}
// or try
if (t[0] === 'a') {
equip = $dataArmors[eval(t[t.length - 1])];
} else if (t[0] === 'w') {
equip = $dataWeapons[eval(t[t.length - 1])];
}
the 2nd return what you set, the bottom with eval return the output.
I think the 2nd should work, but it should return a number to be readed.
Eval gives a incorrect token, the middle one doesn't give any errors, but I couldn't make it work, what should I add in the notetag? I tried replacing ID with $gameVariables, \v, inside a (), [], '' and nothing works.
the normal tag is <equips: a ID>
and the variable I'm using has a numeric value (1)
the normal tag is <equips: a ID>
and the variable I'm using has a numeric value (1)
than I don't know, Number(t[t.length - 1]) checks the index.
eval it should return a number, but I don't know how to change it
at this point effectively or alter it.
it does use this._character which you might try to eval there, but I have
no clue at the moment to study or alter it.
advanced coders might be able, or try rexal or the better one if able
AnimaX by pheonix KageDesu if that can do that, but I have no clue, sorry.
eval it should return a number, but I don't know how to change it
at this point effectively or alter it.
it does use this._character which you might try to eval there, but I have
no clue at the moment to study or alter it.
advanced coders might be able, or try rexal or the better one if able
AnimaX by pheonix KageDesu if that can do that, but I have no clue, sorry.
i would have figured that would have worked
but what precisely have you tried? each one of those as-is could cause errors for different reasons. for example, have you tried <equips: a $gameVariables.value(1)>, or was it <equips: a $gameVariables> that you tried? cause only one of those will return the value of a variable
hmm I tried <equips: a $gameVariables.value(1), \v[1] and v1>, and all of them inside (), [] or '', example <equips: a '\v[1]'>, tons and tons of combinations and nothing gave me a result (only the default <equips: a 1> wich is not a variable)
It could be because of a plugin conflict bcz I have some installed, I would have to test a clean project to see (but unlike since the plugin works fine besides all the plugins)
Edit: I tested on a clean game...
each of them has a diferent combination and I got nothing :/
but for now I'm trying to set up the event using AnimaX by pheonix KageDesu, what ShadowDragon suggested, so I'll use VisibleEquips for the player and AnimaX for events
Edit: AnimaX didn't worked for events either, I couldn't find any way to set up the event layers without manually having to select a option ingame to do it, and when switching pages the main image dissapears (I tested in their demo just to be sure), Idk about the Pro version since I can't use paid stuff.
Edit 2: I got something! replacing the code in line294 and just [v], but I have to refresh the map (opening the menu or leaving and coming back, $gameMap.Refresh() did nothing)for the sprite to show up, Ill do some more testing.
can someone help me corret this issue? (not having to refresh)
The player does refresh instantly, the events don't
It could be because of a plugin conflict bcz I have some installed, I would have to test a clean project to see (but unlike since the plugin works fine besides all the plugins)
Edit: I tested on a clean game...
each of them has a diferent combination and I got nothing :/
but for now I'm trying to set up the event using AnimaX by pheonix KageDesu, what ShadowDragon suggested, so I'll use VisibleEquips for the player and AnimaX for events
Edit: AnimaX didn't worked for events either, I couldn't find any way to set up the event layers without manually having to select a option ingame to do it, and when switching pages the main image dissapears (I tested in their demo just to be sure), Idk about the Pro version since I can't use paid stuff.
Edit 2: I got something! replacing the code in line294 and just [v], but I have to refresh the map (opening the menu or leaving and coming back, $gameMap.Refresh() did nothing)for the sprite to show up, Ill do some more testing.
JavaScript:
} else if (this._character instanceof Game_Event) {
this.refreshEventEquipments();
}
};
Sprite_Character.prototype.refreshEventEquipments = function() {
const eventMeta = this._character.event().meta.equips;
if (eventMeta) {
eventMeta.split(',').forEach(function (id) {
let t = id.trim().split(' ');
let equip;
let type = t[0];
let value = t[t.length - 1];
// Check if the value contains a variable reference (e.g., [1])
const variableMatch = value.match(/\[(\d+)\]/);
if (variableMatch) {
const variableId = Number(variableMatch[1]);
value = $gameVariables.value(variableId); // Replace with game variable value
}
// Determine whether the item is an armor or weapon
if (type === 'a') {
equip = $dataArmors[Number(value)];
} else if (type === 'w') {
equip = $dataWeapons[Number(value)];
}
if (equip)
this._equipments.push(new Sprite_Equipment(this, equip));
}, this);
}
};
can someone help me corret this issue? (not having to refresh)
The player does refresh instantly, the events don't
a cleaner approach should be this one
if you replace the last block with "v" for variables to use v[number]
you can try to see if this works, but eval should work, even with
$gameVariables.value(x) as input.
JavaScript:
} else if (this._character instanceof Game_Event) {
if (this._character.event().meta.equips) {
this._character.event().meta.equips.split(',').forEach(function (id) {
var t = id.trim().split(' ');
var v = $gameVariables._data;
var equip;
if (t[0] === 'a') {
equip = $dataArmors[eval(t[t.length - 1])];
} else if (t[0] === 'w') {
equip = $dataWeapons[eval(t[t.length - 1])];
}
if (equip)
this._equipments.push(new Sprite_Equipment(this, equip));
}, this);
}
}
};
if you replace the last block with "v" for variables to use v[number]
you can try to see if this works, but eval should work, even with
$gameVariables.value(x) as input.
PKD plugins are only free for non-commercial use. If you plan on making any money off your game you have to eventually give him his cut.
It works! with both v[x] and $gameVariables, the sprites appears as soon as I enter in the map. Just that If I change the variable I have to refresh the same way I described earlier
Sorry, I worded it wrong, I can't pay for stuff, no matter if is cheap or not. My games are fully non-commercial 😀
you can do if you change inside the event, a $gameMap.requestRefresh()
but I need to find if it was the correct one, so it should chnage directly.
I add that function to a new plugin which isn't released for simple mapRefresh()
scriptcall, so it would refresh faster without to much hassle.
as I think it can be useful later as for some mechanics or on map change, it is
required to do that, sometimes its the motionRefresh you required (for player).
but I need to find if it was the correct one, so it should chnage directly.
I add that function to a new plugin which isn't released for simple mapRefresh()
scriptcall, so it would refresh faster without to much hassle.
as I think it can be useful later as for some mechanics or on map change, it is
required to do that, sometimes its the motionRefresh you required (for player).
Plugin command to refresh either event or ator (using RefreshSprite Actor/Event X)
JavaScript:
//-----------------------------------------------------------------------------
// Plugin Command: RefreshSprite (for Actor or Event)
//-----------------------------------------------------------------------------
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command === "RefreshSprite") {
var type = args[0]; // First argument: "Actor" or "Event"
var id = Number(args[1]); // Second argument: ID of actor or event
if (type === "Actor") {
refreshActorSprite(id);
} else if (type === "Event") {
refreshEventSprite(id);
}
}
};
//-----------------------------------------------------------------------------
// Refresh Actor Sprite
//-----------------------------------------------------------------------------
function refreshActorSprite(actorId) {
var actor = $gameActors.actor(actorId);
if (actor) {
var sceneSprites = SceneManager._scene._spriteset._characterSprites;
sceneSprites.forEach(function(sprite) {
if (sprite._character instanceof Game_Player && actorId === $gameParty.leader().actorId()) {
clearEquipmentSprites(sprite);
sprite.setCharacter($gamePlayer);
} else if (sprite._character instanceof Game_Follower) {
if (sprite._character.actor() && sprite._character.actor().actorId() === actorId) {
clearEquipmentSprites(sprite);
sprite.setCharacter(sprite._character);
}
}
});
}
}
//-----------------------------------------------------------------------------
// Refresh Event Sprite
//-----------------------------------------------------------------------------
function refreshEventSprite(eventId) {
var event = $gameMap.event(eventId);
if (event) {
var sceneSprites = SceneManager._scene._spriteset._characterSprites;
sceneSprites.forEach(function(sprite) {
if (sprite._character === event) {
clearEquipmentSprites(sprite);
sprite.setCharacter(event);
}
});
}
}
//-----------------------------------------------------------------------------
// Helper Function: Clear Equipment Sprites
//-----------------------------------------------------------------------------
function clearEquipmentSprites(sprite) {
if (sprite._equipments) {
sprite._equipments.forEach(function(equipSprite) {
sprite.removeChild(equipSprite);
});
sprite._equipments = [];
}
}
why plugin commands if you could use the scriptcall instead?
scriptcalls are often bit faster than plugin commands, but both works.
if this only works for MBS_VisualEquipment as patch/mod,
you can wrap it to check if its installed or not, or placed it inside the plugin 🙂
but if it works how you want it to be, happy game making 🙂
scriptcalls are often bit faster than plugin commands, but both works.
if this only works for MBS_VisualEquipment as patch/mod,
you can wrap it to check if its installed or not, or placed it inside the plugin 🙂
but if it works how you want it to be, happy game making 🙂
Really? I didn't knew it had differences, good to know!
Yes I added to the end of the plugin, I mostly wanted to edit events dinamically, so yes, it fill all my needs atm!
This thread is solved and can be closed 😀
Yes I added to the end of the plugin, I mostly wanted to edit events dinamically, so yes, it fill all my needs atm!
This thread is solved and can be closed 😀
This thread is closed due to being indicated as solved. Report the next one so it can easily be found! If you need this thread reopened, report it to let us know. Thank you!
Original thread: https://forums.rpgmakerweb.com/threads/event-notetag-that-reads-variables.174633/