JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 41 of 171 View original ↗
  1. @ramza
    Can u show an example?
  2. sure can. here's an event:
    upload_2017-5-22_17-4-31.png

    Here's the text scroll:
    upload_2017-5-22_17-5-13.png

    And a message window for good measure:
    upload_2017-5-22_17-5-33.png
  3. @ramza
    Code:
    Window_ScrollText.prototype.refresh = function () {
       var textState = { index: 0 };
       textState.text = this.convertEscapeCharacters(this._text);
       this.resetFontSettings();
       this._allTextHeight = this.calcTextHeight(textState, true);
       this.createContents();
       this.origin.y = -this.height;
       var text = this._text;
       var tw = this.textWidthEx(text);
       var textX = (Graphics.boxWidth / 2) - (tw / 2);
       this.drawTextEx(text, textX, 1);
    };

    With that the text in the textbox should not go further than the "grey line", otherwise it get's cut off.
  4. It does work as advertised:
    upload_2017-5-22_17-51-38.png
    upload_2017-5-22_17-48-21.png

    But I would like for the origin to be at 168 pixels, which is what the message window ends up at when I make it 816 pixels wide. When I changed your script to draw at exactly 168 pixels, the text continued until the edge of the screen again, instead of where the grey bar was.
    Code:
    Window_ScrollText.prototype.refresh = function () {
       var textState = { index: 0 };
       textState.text = this.convertEscapeCharacters(this._text);
       this.resetFontSettings();
       this._allTextHeight = this.calcTextHeight(textState, true);
       this.createContents();
       this.origin.y = -this.height;
       var text = this._text;
       var tw = this.textWidthEx(text);
       var textX = 168 // (Graphics.boxWidth / 2) - (tw / 2);
       this.drawTextEx(text, textX, 1);
    };

    upload_2017-5-22_17-51-8.png
    If I'm understanding this correctly, can we not just draw the textscroll in a window box that is 816 wide by screenheight high? or does that not work? I mean, I can dow ithout the cutoff on the grey line, as I had to deal with that already due to the change of font size, (note that the top box shows the line on the word 'of', but the cutoff is actually several words later).
  5. You could modify the x position and width of the scroll window instead.
    Code:
    Scene_Map.prototype.createScrollTextWindow = function() {
        this._scrollTextWindow = new Window_ScrollText();
        this._scrollTextWindow.x = 168;
        this._scrollTextWindow.width = 816;
        this.addWindow(this._scrollTextWindow);
    };
  6. There we go, that's exactly what I was looking for. Thanks.
  7. So, here's an incredibly stupid question.



    I'm trying to resize the command window to fit inside of the orange borders, more or less. However, I couldn't get the commands to appear horizontally using MOGs BattleHUD, so I modified the visible rows/columns using a custom plugin. But, I can't adjust the height of the window in order to make it less "click these words" and more "click this button." Adjusting the height does.. well, nothing, really. I've made it 500, I've made it 100.. Doesn't really do anything. The only thing that I can think of is that the height command isn't the literal WxH type of Height, but X/Y/Z height. Am I on the right track, or is there some sort of conflicting plugin shenanigans occurring here?
  8. Height command works fine. But there's a difference between
    Command window height
    and Command height
    You can modify the command window height as much as you like, but it has no influence on the height of commands.
    If you want to modify Command height, you'll need to modify the scripts responsible for showing the commands (so rpg_windows.js, if I'm not wrong).
  9. This is where the question becomes stupid. If I adjust the width, then the commands become smaller, as expected. But, adjusting the height does nothing past a certain point. For example, should I make the height 1, then the options virtually disappear-- but the difference between 100/1000 isn't noticeable. Is there perhaps some sort of cull that refuses to let the height go past a maximum amount?
  10. By default the command height is equal to this.fittingHeight(1), which in translation means height of up to 1 line.
  11. Unfortunately, using this snippet:
    Code:
    Window_Command.prototype.windowHeight = function() {
        return 3000;
    };

    Does nothing except cause a longer boot time. I'm going to just assume I'm stupid, and put this problem to the side for now.
  12. hi guys,

    I want to switch off a common event once a state expires, I'm thinking of using Yanfly's Buffs and States Core:

    <Custom Leave Effect>
    code
    code
    </Custom Leave Effect>

    I just don't know what to put inside the code. Can you please help me?
    Thank you in advance...
  13. @ZServ I looked through the game code and found that
    1. you're dumb, because Window_Command.prototype.WindowHeight influences the basic height of a command window (which again has nothing to do with command height), but
    2. you're not dumb, because:
    The functions that take direct care of battle command window are prototypes of Window_ActorCommand. However, looking through the code I found that it's actually way more complicated than to solve it through change of command height, because it's apparently hidden somewhere in the core scripts and has to do with text rendering, so it's very difficult to enhance command height. I also looked at MOG_Battlecommands for some clues,but there I found that I don't understand it, so I gave up on it.
    @worshipme $gameSwitches.value(switchId, true/false) switches off a common event switch.
  14. @Poryg thank you very much sir. I finally made it to work. I just adjusted it to my need:
    $gameSwitches.setValue(1,false)
  15. Sorry, that was autocorrect :)
  16. Just a quick question. I've put this in my damage formula box and its not working. I'm sure I'm doing something simple wrong but can't put my finger on it.

    if b.isStateAffected(12){(a.atk * 4 + a.mat *2 - b.def * 2)} else {a.atk * 4 - b.def * 2}
  17. If statement conditions have to be enclosed in brackets.
  18. Trihan said:
    If statement conditions have to be enclosed in brackets.

    Knew it was something silly, lol, wouldn't mind but I was staring at the code for about half an hour like an eejit and not seeing anything wrong. Never entered my head to check the most obvious thing which is usually the correct thing. Thanks dude.
  19. I made a plugin to produce a simple window that's specific for an event. The problem is, the window is always up there. I tried to create a plugin command to toggle the window but it doesn't work.

    This is the parameter I want to change:
    * @param Control Switch
    * @desc true = on, false = off
    * Default false
    * @Default false

    This is what I have at the top of the main function:
    var parameters = PluginManager.parameters('BPE Lock Pick Window');
    var BPEwindowX = Number(parameters['Window X']);
    var BPEwindowY = Number(parameters['Window Y']);
    var BPEcontrol = String(parameters['Control Switch']).trim() == "true";
    var _Game_Interpreter_pluginCommand =
    Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
    _Game_Interpreter_pluginCommand.call(this, command, args);
    if(command === 'LP_On'){parameters.BPEcontrol = String("true")};

    if(command === 'LP_Off'){parameters.BPEcontrol = String("false")};
    };

    I've tried
    if(command === 'LP_On'){BPEcontrol = String("true")};

    if(command === 'LP_Off'){BPEcontrol = String("false")};
    but nothing changes and the window stays on the screen. Any suggestions would be helpful. The full plugin is here.
  20. @cyberchronomage Here's a plugin to demonstrate.

    Source
    Code:
    /*
    * clockoutLockPickWindow.js
    * 2017-06-01
    * Copyright (c) 2017 Dominic Herrera
    * License: Do anything you want.
    * Disclaimer: NO WARRANTY.
    */
    
    /*:
     * @plugindesc Show lock pick count window via plugin command.
     * @author Clock Out
     *
     * @help
     * SYNOPSIS
     *     Toggle the lock pick count window.
     *
     * SYNTAX
     *     LP <ON|OFF>
     *
     * EXAMPLE
     *     LP ON
     */
    
    var clockout = clockout || {};
    
    clockout.window = clockout.window || {};
    
    /**
     * Create a window to track a $gameVariable value.
     * @returns {object} The new window.
     */
    clockout.window.lockPickWindow = function () {
        "use strict";
    
        var config = {
            name: "Lock Pick",
            numLines: 1,
            variableId: 94,
            width: 220,
            x: 530,
            y: 0
        };
        var window = Object.create(Window_Base.prototype);
    
        window.refresh = function () {
            var x;
    
            window.contents.clear();
    
            x = window.drawTextEx(
                config.name,
                0,
                0,
                window.windowWidth(),
                "left"
            );
    
            window.drawText(
                ":" + $gameVariables.value(config.variableId),
                x + 15,
                0,
                window.textWidth("000"),
                "right"
            );
        };
    
        window.initialize = (function (alias) {
            return function () {
                alias.apply(this, arguments);
    
                this.openness = 0;
            };
        }(window.initialize));
    
        window.update = (function (alias) {
            return function () {
                alias.call(this);
            
                if (this.isOpen()) {
                    window.refresh();
                }
            };
        }(window.update));
    
        window.windowHeight = function () {
            return window.fittingHeight(config.numLines);
        };
    
        window.windowWidth = function () {
            return config.width;
        };
    
    // Setup the window.
    
        window.initialize(
                config.x,
                config.y,
                window.windowWidth(),
                window.windowHeight()
            );
    
        window.refresh();
    
        return window;
    };
    
    // Alias pluginCommand.
    
    (function (alias) {
        "use strict";
    
        function pluginCommand(command, args) {
            var isLoaded = SceneManager._scene.hasOwnProperty("lockPickWindow");
            var window;
    
            alias.call(this, command, args);
    
            if (command !== "LP") {
                return;
            }
    
            if (isLoaded === false) {
                window = clockout.window.lockPickWindow();
    
                SceneManager._scene.addWindow(window);
                SceneManager._scene.lockPickWindow = window;
            }
    
            switch (args[0]) {
            case "ON":
                SceneManager._scene.lockPickWindow.open();
                break;
            case "OFF":
                SceneManager._scene.lockPickWindow.close();
                break;
            }
        }
    
        Game_Interpreter.prototype.pluginCommand = pluginCommand;
    }(Game_Interpreter.prototype.pluginCommand));