RMMV - is there a way to dynamically change the icon for an active state applied on a battler based on a property added to the battler? At some point i thought of a more efficient way to handle a set of states in my game. It would condense 8 states for each element into 1, but i want to be able to communicate to the player which element is active through the icon if i do this.
JavaScript questions that don't deserve their own thread
● ARCHIVED · READ-ONLY
-
-
The way would be to write a plugin that changes how the icon is drawn. By default, it references the database entry for the state, so you'd have to modify that to look at, say, a notetag.RMMV - is there a way to dynamically change the icon for an active state applied on a battler based on a property added to the battler?
If you're not sure how to do that, I think it definitely deserve its own thread. -
Is there a way to make the code wait for the animation?
JavaScript:if (attackInstructions.CasterAnimID > 0) { $gameTemp.requestAnimation([$gamePlayer], attackInstructions.CasterAnimID); } if (attackInstructions.TargetAnimID > 0) { $gameTemp.requestAnimation([$gameMap.event(EnemyArray[target - 1].enemyEventId)], attackInstructions.TargetAnimID); }
Or at least show one after another even without the code waiting for them to be done -
Ok, I need help converting a notetag with multiple values into an array, i.e. <drops: 4, 5, 6>. I modified a ChronoEngine item spawning script to spawn 1-3 loot items within a 0.5 radius of the enemy, except it spawns the same item 1-3 times because I don't know how to convert a multivalue notetag to an array to run scripts on.
JavaScript://Restart ChronoEngine Enemy Treasure Spawn (modded) Game_CharacterBase.prototype.makeTreasure = function(char,battler) { var treasures = battler.makeDropItems(); if (treasures.length > 0) { var rt = Math.randomInt(treasures.length); var item = treasures[rt] if (item.id == 50) { var randomCount = Math.floor(Math.random() * 3) + 1; //randomly spawn between 1 and 3 items for (var i = 0; i < randomCount; i++) { //spawn items in random location in .5 radius from death Ritter.spawnEvent(39, $dataEnemies[char.battler()._enemyId].meta.drops, char.x +Math.random()-0.5, char.y +Math.random()-0.5, false); } }else { char._user.treasure = [item,false,0,0,20]; char._characterName = 'treasurebattlertool' $gameMap._treasureEvents.push(char); } char._user.collapse = [true,0]; }; }; -
var drops = whatever_object.meta.drops.split(',') ?
P.S. may want to use .trim afterwards as you iterate through the array to get rid of white spaces around. -
Nice, it worked. Thanks for the quick reply.var drops = whatever_object.meta.drops.split(',') ?
P.S. may want to use .trim afterwards as you iterate through the array to get rid of white spaces around.
Edit: Added the trim()
Modded scriptCode://Restart ChronoEngine Enemy Treasure Spawn (modded) Game_CharacterBase.prototype.makeTreasure = function(char,battler) { var treasures = battler.makeDropItems(); if (treasures.length > 0) { var rt = Math.randomInt(treasures.length); var item = treasures[rt]; if (item.id == 50) { var randomCount = Math.floor(Math.random() * 3) + 1; //randomly spawn between 1 and 3 items var dropArray = $dataEnemies[char.battler()._enemyId].meta.drops.split(','); for (var i = 0; i < randomCount; i++) { var rd = Math.randomInt(dropArray.length); var drop = dropArray[rd].trim(); //spawn items in random location in .5 radius from death Ritter.spawnEvent(39, drop, char.x +Math.random()-0.5, char.y +Math.random()-0.5, false); } }else { char._user.treasure = [item,false,0,0,20]; char._characterName = 'treasurebattlertool' $gameMap._treasureEvents.push(char); } char._user.collapse = [true,0]; }; }; -
Sorry for the basic question. I'm trying to make a conditional branch for a character repairing bridges and other devices on every map but needs a specific amount of items for it at the same time. I tried to make control variables but I'm not sure how to add several to a single branch.
Say the party needs Logs x5 being game id 2; Nails x10 game id 3 and Hammer x1 game id 4. How can I type this in an If Script branch?
Thanks again for the help. -
If: Script: ($gameVariables.value(2)>=5 && $gameVariables.value(3)>=10 && $gameVariables.value(4)>=1)Sorry for the basic question. I'm trying to make a conditional branch for a character repairing bridges and other devices on every map but needs a specific amount of items for it at the same time. I tried to make control variables but I'm not sure how to add several to a single branch.
Say the party needs Logs x5 being game id 2; Nails x10 game id 3 and Hammer x1 game id 4. How can I type this in an If Script branch?
Thanks again for the help. -
Aside from making it shorter to read, there's really no reason to script this. You can simply set the three variables and then nest three conditional branches.Say the party needs Logs x5 being game id 2; Nails x10 game id 3 and Hammer x1 game id 4. How can I type this in an If Script branch?
If you are going to script it, I don't see any reason for you to be using any game variables at all. Just directly check whether the party has the items by item ID.
Conditional Branch -> Script ->$gameParty.numItems($dataItems[X])>=5 && $gameParty.numItems($dataItems[Y])>=10 && $gameParty.numItems($dataItems[Z])>=1
where X, Y, and Z are the database IDs of your three items. -
Hello, hoping someone can help with this.
I'm trying to add a check if the target is an actor or not which will adjust the tick damage of the state. It works if I simply say "
var damage = stacks * caster.mhp * 0.5", but when I add the if statement it doesn't work anymore.
Code:var caster = target.stateOrigin(); var damage = stacks * if (caster.isActor()) { caster.mhp * 0.5 } else { caster.mhp * 0.01 } ; target.gainHp(-damage); -
Code:
var caster = target.stateOrigin(); var damage = stacks * (caster.isActor() ? caster.mhp * 0.5 : caster.mhp * 0.01); target.gainHp(-damage); -
If statements are their own code statement - you can't embed them inline another. To use them, you'd have to do:I'm trying to add a check if the target is an actor...but when I add the if statement it doesn't work anymore.
Code:let damage=stacks; if (caster.isActor()) damage*=caster.mhp*.5; else damage*=caster.mhp.01;
One little efficiency note is that conditionals automatically apply to the next single statement. So if you're only doing one thing there's no need to create a code block with braces.
Or you can use the ternary operator that @TESTOSTERONE demonstrated above. That, like all operators, can be used inline in the middle of a code statement (and technically doesn't even need the parentheses). -
Anyway to substitute 'down' with $gamePlayer.direction() in
Input.isLongPressed('down')
I want to check if the player has been holding down the button of the direction they're currently facing
Edit: I ended up doing this although I can't help but feel there was a better way
JavaScript:switch($gamePlayer.direction()){ case 2: if(Input.isLongPressed('up')){$gameTemp.reserveCommonEvent(27);}break; case 4: if(Input.isLongPressed('left')){$gameTemp.reserveCommonEvent(27);}break; case 6: if(Input.isLongPressed('right')){$gameTemp.reserveCommonEvent(27);}break; case 8: if(Input.isLongPressed('down')){$gameTemp.reserveCommonEvent(27);}break; } -
Not really, because the game has no need to reverse engineer from the numeric direction to the button label.I ended up doing this although I can't help but feel there was a better way
You could make it fewer lines of code this way:
Code:[0, 1, 'down', 0, 'left', 0, 'right', 0, 'up'][$gamePlayer.direction()] -
im having this problem where upon opening the text box window/choice windows, the animation displays white(?) squares and its really annoying
ill attach a gif, but does anyone have an idea on how to fix that? asking here because i do have GALV VN style choices and Visus message core plugins installed . ..
id appreciate any help, thank you in advance
-
im having this problem where upon opening the text box window/choice windows, the animation displays white(?) squares and its really annoying
ill attach a gif, but does anyone have an idea on how to fix that? asking here because i do have GALV VN style choices and Visus message core plugins installed . ..
id appreciate any help, thank you in advance
I don't think this is a javascript issue so much as a plugin issue (compatibility). Does it still happen if you turn VisuStella off? -
it sadly both does - neither turning off VisuStella or the Galv plugins works :kaoeh:I don't think this is a javascript issue so much as a plugin issue (compatibility). Does it still happen if you turn VisuStella off?
-
If this is happening when no plugins are active, it could be an outdated driver issue.
-
As @AquaEcho says, you're not really asking anything specific about JavaScript - from the first post of this thread, it's not for issues with plugins.im having this problem where upon opening the text box window/choice windows, the animation displays white(?) squares
You'll get better answers starting your own thread asking about this. Please include links to the plugins you're using and full details. For example, when I look up the Galv plugin you mention, it's for MV not MZ - if you're not modifying it in any way, that could cause problems by itself.
Also include whether it happens in a brand new project, not using that customized windowskin in your GIF. -
Okay I need some handholding... what exactly is being done here?You could make it fewer lines of code this way:
Code:[0, 'down', 0, 'left', 0, 'right', 0, 'up'][$gamePlayer.direction()]