RPG Maker Forums

hi i have question.


Example if i call my function


1:ID 2:operator


StatsControl(322,'-=');  // Is do a decrease


if i do this


StatsControl(322,'+=');  // Is do a increase


i read Eval can make me do this easy,


I know well the long method, but I would like to find a shortcut to call this function and be, Decrement or increase, without duplicating my code once.
Thank you for your suggestion.


if i try this i get Uncaught ReferenceError: Invalid left-hand side in assignment


op='+=';
eval($dataActors[1].meta.MaxBag + op + 10);




Here my function. Existe a very fast way without duplicate the code for assigned dinamyque operator (+=) or (-=)


function StatsControl(PID,Operator) {
//MaxBag // add point MaxBag (10) // Store MaxBag Adder (/10) pour le reset
if (PID==322) { $dataActors[1].meta.MaxBag+=10, StoreMaxBag+=10; } else
//HP // add point HP (5) // Store HP Adder (/5) pour le reset
if (PID==326) { $gameActors.actor(1).mhp+=5, StoreHP+=5; } else
//MP // add point MP (5) // Store MP Adder (/5) pour le reset
if (PID==330) { $gameActors.actor(1).mmp+=5, StoreMP+=5; } else
//ATT // add point ATT (5) // Store ATT Adder (1) pour le reset
if (PID==334) { $gameActors.actor(1).atk+=1, StoreATT+=1; } else
//Def // add point Def (5) // Store StoreDef Adder (1) pour le reset
if (PID==338) { $gameActors.actor(1).def+=1, StoreDef+=1; } else
//LUK // add point LUK (5) // Store StoreLUK Adder (1) pour le reset
if (PID==342) { $gameActors.actor(1).luk+=1, StoreLUK+=1; } else
//STA // add point STA (5) // Store StoreSTA Adder (1) pour le reset
if (PID==346) { $gameActors.actor(1).agi+=1, StoreSTA+=1; } else
//INT // add point INT (5) // Store StoreINT Adder (1) pour le reset
if (PID==350) { $gameActors.actor(1).mat+=1, StoreINT+=1; }

}




If someone knows a trick, thanks

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top