Hello again.
I'm at a loss of what's best to do. I need to call my functions that use game objects, and I need them to start when the game loads after the title screen. I can't seem to find a function to use to put my calls inside where this works.
An example would be using:
if (Input.isPressed('ok')) { console.log('space bar pressed');}I need this to work while the player is walking around, right after the new game, or continue, loads. I just have no idea what to throw it in, or if there is another way to hook a function to an already existing function so it executes on call, only after the game objects load. I've been looking and trying some for a while (nearly 2 days off and on), but without API or documentation it's increasingly difficult.
Everything I try returns null or doesn't start initially on the game load. Example:
(function() { // test key battle if (Input.isPressed('ok')) { console.log('space bar pressed'); }})();...returns null object with error.
I'd imagine an explanation and example would help a lot of newcomers to MV as well, so if anyone answers if they could explain a bit on why, etc. that'd be great.
P.S.
Forgive me on the deleted posts, my questions were redundant to things already answered, some by my own post from some help I got recently. I'll be a bit more careful and clear on my questions as best I can.
Well, I'm going to assume you want this to be active on the map, right? Just alias Game_Map's update function, and have it call your own function to check is a key is pressed. Keep in mind, however, there are 3 keys that are mapped to 'ok'. Enter, Space, and X.
I edited my post probably right as you were posting yours, but putting 'var' in front gives me an error:
Uncaught SyntaxError: Unexpected token .
if I take var out, then nothing happens when hitting enter/space in the console. Both ways the level does load now though...
this is my entire code, I'd imagine I'm setting up the 'eSystem' wrong (ignore the params, I'm just learning how to use them)?
//=============================================================================// Eilios - System// Eilios_System.js// Version: 1.0.0//=============================================================================var eSystem = eSystem || {};//=============================================================================/*: * @plugindesc v1.0.0 Used for all basic system management in the game. * @author Eilios * * @param Critical Multiplier * @desc critical hit dmg = base damage * this multiplier * Default: 3 * @default 3 * * @param Min Initial TP * @desc Minimum amount of TP a character may have at the start of battle. * Default: 0 * @default 0 * * @param Max Initial TP * @desc Maximum amount of TP a character may have at the start of battle. * Default: 25 * @default 25 * * @help More when it comes */(function() { // set up the paramaters eSystem.Parameters = PluginManager.parameters('Eilios_System'); eSystem.Param = eSystem.Param || {}; eSystem.Param.CriticalMultiplier = Number(eSystem.Parameters['Critical Multiplier']); eSystem.Param.MaxInitialTP = Number(eSystem.Parameters['Max Initial TP']); eSystem.Param.MinInitialTP = Number(eSystem.Parameters['Min Initial TP']); (function() { var eSystem.Initialize = Game_Map.prototype.update; Game_Map.prototype.update = function() { eSystem.Initialize.call(this); // test key battle if (Input.isPressed('ok')) { console.log('space bar pressed'); } } });})();Added eSystem.Initialize = eSystem.Initialize || {}; after eSystem.Param = eSystem.Param || {}; in the code, but still no response from the console when hitting the key.
1. I thought it was meant to wrap it inside of what was already there. xD I was wondering lol.
2. Now the link to the next map won't load. this was the problem I kept having when removing var before the eSystem.Initialize.
Sorry for the double post, but another related problem came up.
Links to other maps don't work now. See above.
Ahh, I hadn't noticed you already had them in an anonymous function, my mistake. Turns out I made several mistakes when writing that, sorry.
What do you mean the link to the next map won't load?
I have an event placed on the map that warps the player to another map, with the code like is in the last post with code for this thread, it just doesn't warp to the next map, it just freezes the player. Key press does work, however. if I comment out the alias and game_map parts, the event works fine.
var eSystem = eSystem || {};(function() { // set up the paramaters eSystem.Parameters = PluginManager.parameters('Eilios_System'); eSystem.Param = eSystem.Param || {}; eSystem.Param.CriticalMultiplier = Number(eSystem.Parameters['Critical Multiplier']); eSystem.Param.MaxInitialTP = Number(eSystem.Parameters['Max Initial TP']); eSystem.Param.MinInitialTP = Number(eSystem.Parameters['Min Initial TP']); eSystem.Initialize = Game_Map.prototype.update; Game_Map.prototype.update = function() { eSystem.Initialize.call(this); // test key battle if (Input.isPressed('ok')) { console.log('space bar pressed'); } } })();I'm using YED's plugin for tiled, could that have anything to do with it? I wouldn't see how, since if it's using it it's aliased, and if it isn't it shouldn't matter and I don't see anything in it for the game map update function specifically, but I'm still new so who knows? Just to add as well, no errors, it just freezes the player.
It was because I wasn't including sceneActive like it had in the original function.
Game_Map.prototype.update = function(sceneActive) { eSystem.Initialize.call(this, sceneActive);Works now.