- Joined
- Jul 22, 2014
- Messages
- 5,624
- Reaction score
- 5,107
- First Language
- English
- Primarily Uses
- RMVXA
Hi guys! I'm starting to make the jump from Ruby to JavaScript scripting, and while I think I'm grasping the language okay, I'm having a rough time making heads or tails of how everything is organized in the RPG Maker scripts. Hopefully someone that's already jumped these hurdles can give me a leg up here. 
I decided to start with a simple feature that's already been done a couple times - adding HP costs to skills. When I simply forced a 20HP cost onto each skill it went smoothly, but it fell apart when I tried to add different HP costs to each skill using notetags.
Below is the code I've written. The current, erroneous behavior of this script is that when I hit playtest, the game will say "Now Loading..." and freeze there forever at runtime. The title screen won't even appear. I have three Immediately Invoked Functions (which seem to the way RPG Maker does this stuff by default, so I followed suit):
While I'd greatly appreciate help cleaning up this code, I'd also really appreciate any tips you can offer me on creating new parameters for database items. Am I generally using the right approach to add an "HP Cost" parameter to skills, or should I be doing something entire different to add this parameter to each skill? This is certainly one of the most important parts of RPG Maker scripting and it's frustrating me that I can't get it right.
Thank you so much to whoever can help me break through this roadblock!!
I decided to start with a simple feature that's already been done a couple times - adding HP costs to skills. When I simply forced a 20HP cost onto each skill it went smoothly, but it fell apart when I tried to add different HP costs to each skill using notetags.
Below is the code I've written. The current, erroneous behavior of this script is that when I hit playtest, the game will say "Now Loading..." and freeze there forever at runtime. The title screen won't even appear. I have three Immediately Invoked Functions (which seem to the way RPG Maker does this stuff by default, so I followed suit):
- The first function is attempting to alias the paySkillCost method to make battlers using skills lose HP equal to the cost. I think this is correct, because when I replaced the "if" branch with a simple this._hp -= 20 command and removed the second and third functions, the script works fine.
- The second function is attempting to alias the isDatabaseLoaded function so that the third function will be called once when New Game is selected. I think I am doing something wrong here, because the "Now Loading..." problem won't happen if I comment out this second function.
- The third function is attempting to iterate through each Skill in $dataSkills (which I assume represents the skills in the database), create a new property called health_cost for the skill, see if the Skill's note contains "hp cost:", and if so, pull whatever integer comes after it as the skill's HP cost. I'm not sure whether anything is incorrect here, but when I added most of this code to an evented "Script..." command on the map, the integer did seem to be pulled out of a hard-coded string perfectly.
While I'd greatly appreciate help cleaning up this code, I'd also really appreciate any tips you can offer me on creating new parameters for database items. Am I generally using the right approach to add an "HP Cost" parameter to skills, or should I be doing something entire different to add this parameter to each skill? This is certainly one of the most important parts of RPG Maker scripting and it's frustrating me that I can't get it right.
Thank you so much to whoever can help me break through this roadblock!!
Last edited by a moderator:


