qPicture variables handler

● ARCHIVED · READ-ONLY
Started by SHDWRCK 1 posts View original ↗
  1. Hi there,

    I use the qPicture plugin which allows me to activate switches and common event when mouse clicking or entering a picture. I use this plugin because it allows no-alpha clicking, which is a plus for my game.

    If someone knows how could I add a handler which could let me set a game variable when clicking and stuff, it would be soooo nice !

    Here is the specific place of the qPicture code which allows to add a handler.
    In red my "idea" to add game variables in the code, but without knowing anything about coding.
    What I do is just replicate the "Switch" part of the code renaming it "variable"

    Game_Interpreter.prototype.qPictureCommand = function(args) {
    var picId = args.shift();
    var pic = $gameScreen.picture(Number(picId));
    if (!pic) return;
    var cmd = args.shift().toLowerCase();
    if (/^on/.test(cmd)) {
    if (args[0].toLowerCase() === 'clear') {
    pic.setMouseHandler(cmd, null);
    return;
    }
    var switchId = /^switch(\d+)/.exec(args[0]);
    var ceId = /^ce(\d+)/.exec(args[0]);
    var varId = /^var(\d+)/.exec(args[0]);
    if (switchId) {
    pic.setMouseHandler(cmd, function(id, value) {
    if (value === 'toggle') {
    var curr = $gameSwitches.value(id);
    $gameSwitches.setValue(id, !curr);
    } else {
    $gameSwitches.setValue(id, value === 'true');
    }
    }.bind(pic, Number(switchId[1]), args[1].toLowerCase()));
    } else if varId) {
    pic.setMouseHandler(cmd, function(id, value) {
    if (value === 'toggle') {
    var curr = $gameSwitches.value(id);
    $gameSwitches.setValue(id, !curr);
    } else {
    $gameSwitches.setValue(id, value === 'true');
    }
    }.bind(pic, Number(switchId[1]), args[1].toLowerCase()));

    } else if (ceId) {
    pic.setMouseHandler(cmd, function(id) {
    $gameTemp.reserveCommonEvent(id);
    }.bind(pic, Number(ceId[1])));
    }
    return;
    }
    if (cmd === 'ease') {
    var type = args[0].toLowerCase();
    var mode = args[1].toLowerCase();
    pic.setEase(type, mode);
    }
    if (cmd === 'alpha') {
    pic.setThroughAlpha(args[0].toLowerCase() === 'true');
    }
    };

    Here is a link to the code itself.

    Any help would be appreciate, it may help a lot of makers I think !

    Else, I was wondering if anybody knows the script call for the qPicture onMouseOver and stuff, which will let me do the variable stuff without changing the code.

    For exemple, with the script line for "the mouse is over picture 1 alpha only", I could do a conditionnal branch which will change my variable when the condition is ok !

    Hope someone has some answers !

    Best regards,

    ShdwRCK