JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 9 of 171 View original ↗
  1. Iavra said:
    I'm currently struggling to find out how set a viewport in MV/Pixi. I have a container (extends Sprite_Base) with a certain width/height and several children inside of it, but i can still draw outside the container sprite.

    How can i just not render everything that would be outside the container bounds without having to clear and blt a bitmap everytime something changes?
    You should be able to cut them off by using the setFrame)(x, y, width, height) function on the container. I just tested it on a window's frame and it seems to have worked nicely.
  2. Thanks KockaAdmiralac! I'll spend some time studying the code and making it work :D

    Edit:

    @KockaAdmiralac

    So I've pretty much understand the most of how the set movement route works now. However, I can't figure out how to pass parameters. For example, code 15 is the wait command, and so I need to pass the parameter of how many frames to wait for. I've been wracking my brain for the past two hours now trying different variations of how to possibly pass it.
  3. Zalerinian said:
    You should be able to cut them off by using the setFrame)(x, y, width, height) function on the container. I just tested it on a window's frame and it seems to have worked nicely.
    Doesn't seem to work for me:

    Code:
    $.prototype.update = function() {    Sprite_Base.prototype.update.call(this);    this.updateMinimap();    this.updateFrame();};        $.prototype.updateMinimap = function() {    var s = _params.tileSize, p = $gamePlayer;    var x = (_params.frame.w - s) / 2 - p._realX * s, y = (_params.frame.h - s) / 2 - p._realY * s;    this._minimapSprite.move(x, y);};        $.prototype.updateFrame = function() {    this.setFrame(0, 0, _params.frame.w, _params.frame.h);};
    _minimapSprite still can be rendered outside the container.
  4. Iavra said:
    Doesn't seem to work for me:

    $.prototype.update = function() { Sprite_Base.prototype.update.call(this); this.updateMinimap(); this.updateFrame();}; $.prototype.updateMinimap = function() { var s = _params.tileSize, p = $gamePlayer; var x = (_params.frame.w - s) / 2 - p._realX * s, y = (_params.frame.h - s) / 2 - p._realY * s; this._minimapSprite.move(x, y);}; $.prototype.updateFrame = function() { this.setFrame(0, 0, _params.frame.w, _params.frame.h);};_minimapSprite still can be rendered outside the container.
    Ahhh, I see. It seems you'll have to update the frame of everything inside your container, when you change the container itself. It seems setting the frame of one sprite only applies to that sprite. It it rather unfortunate, I suppose, That makes it very difficult to handle animations and such, since the frame would have to be updated in quite a few situations.

    I haven't tried anything, but I've been looking at the PIXI code to see if there is another way. Try setting "crop" directly. It's the same as Frame, a Rectangle object, or just a object with {x, y, width, height}. Seeing the base code, I'd just go with new Rectangle, as that's what they do.
  5. I see. crop seems to be applied to the local coordinates, which is bad, because i need to calculate everything depending on the container and child position :( But i guess, this will work.
  6. @10theodie10

    You have all constants in the beginning of Game_Character.

    It'll look like this :

    Spoiler
    Game_Character.ROUTE_END               = 0;Game_Character.ROUTE_MOVE_DOWN         = 1;Game_Character.ROUTE_MOVE_LEFT         = 2;Game_Character.ROUTE_MOVE_RIGHT        = 3;Game_Character.ROUTE_MOVE_UP           = 4;Game_Character.ROUTE_MOVE_LOWER_L      = 5;Game_Character.ROUTE_MOVE_LOWER_R      = 6;Game_Character.ROUTE_MOVE_UPPER_L      = 7;Game_Character.ROUTE_MOVE_UPPER_R      = 8;Game_Character.ROUTE_MOVE_RANDOM       = 9;Game_Character.ROUTE_MOVE_TOWARD       = 10;Game_Character.ROUTE_MOVE_AWAY         = 11;Game_Character.ROUTE_MOVE_FORWARD      = 12;Game_Character.ROUTE_MOVE_BACKWARD     = 13;Game_Character.ROUTE_JUMP              = 14;Game_Character.ROUTE_WAIT              = 15;Game_Character.ROUTE_TURN_DOWN         = 16;Game_Character.ROUTE_TURN_LEFT         = 17;Game_Character.ROUTE_TURN_RIGHT        = 18;Game_Character.ROUTE_TURN_UP           = 19;Game_Character.ROUTE_TURN_90D_R        = 20;Game_Character.ROUTE_TURN_90D_L        = 21;Game_Character.ROUTE_TURN_180D         = 22;Game_Character.ROUTE_TURN_90D_R_L      = 23;Game_Character.ROUTE_TURN_RANDOM       = 24;Game_Character.ROUTE_TURN_TOWARD       = 25;Game_Character.ROUTE_TURN_AWAY         = 26;Game_Character.ROUTE_SWITCH_ON         = 27;Game_Character.ROUTE_SWITCH_OFF        = 28;Game_Character.ROUTE_CHANGE_SPEED      = 29;Game_Character.ROUTE_CHANGE_FREQ       = 30;Game_Character.ROUTE_WALK_ANIME_ON     = 31;Game_Character.ROUTE_WALK_ANIME_OFF    = 32;Game_Character.ROUTE_STEP_ANIME_ON     = 33;Game_Character.ROUTE_STEP_ANIME_OFF    = 34;Game_Character.ROUTE_DIR_FIX_ON        = 35;Game_Character.ROUTE_DIR_FIX_OFF       = 36;Game_Character.ROUTE_THROUGH_ON        = 37;Game_Character.ROUTE_THROUGH_OFF       = 38;Game_Character.ROUTE_TRANSPARENT_ON    = 39;Game_Character.ROUTE_TRANSPARENT_OFF   = 40;Game_Character.ROUTE_CHANGE_IMAGE      = 41;Game_Character.ROUTE_CHANGE_OPACITY    = 42;Game_Character.ROUTE_CHANGE_BLEND_MODE = 43;Game_Character.ROUTE_PLAY_SE           = 44;Game_Character.ROUTE_SCRIPT            = 45;
    There is no reference on which arguments to pass, but I suppose you can figure out on your own.Parameters are passed along with object that has code, so instead of

    Code:
    {code:123, indent:null}
    you would write
    Code:
    {code:123, indent:null, parameters: [param1, param2, param3]}
    So, if you had "Change Opacity" to 23 it would look like :
    Code:
    {code:42, indent: null, parameters: [23]}
    Sorry I forgot to mention parameters earlier.
  7. I'm working on modifying Window_SkillList.prototype.drawMpCost to display different information based on certain conditions, such as active states. For example, if skill #30 acted as a stance and its correlating state was active, I'd like to display a string instead of the MP cost.

    Is it possible to detect specific skills? E.g.

    if (this._actor.skillId(skill) == 30 && this._actor.isStateAffected(3)) { this.drawText('Active', wx, wy, dw, 'right'); }isStateAffected works, but I know that the first bit isn't valid.
  8. @KockaAdmiralac
    I understood the constants with the code values, but it was passing the parameters that had me stuck. The amount of variations I've tried to pass it is somewhat laughable now. Anyways, 
    thanks for all the help; I really appreciate it! 
  9. Kenen said:
    I'm working on modifying Window_SkillList.prototype.drawMpCost to display different information based on certain conditions, such as active states. For example, if skill #30 acted as a stance and its correlating state was active, I'd like to display a string instead of the MP cost.

    Is it possible to detect specific skills? E.g.

    if (this._actor.skillId(skill) == 30 && this._actor.isStateAffected(3)) { this.drawText('Active', wx, wy, dw, 'right'); }isStateAffected works, but I know that the first bit isn't valid.
    You can detect whether the character has learned a skill or not with

    this._actor.isLearnedSkill(30)

    in your case.

    But I wouldn't check that for what you're trying.

    You're skill has a state, probably unique to it.

    Just checking the isStateAffected would be enough.
  10. kiriseo said:
    You can detect whether the character has learned a skill or not with

    this._actor.isLearnedSkill(30)

    in your case.

    But I wouldn't check that for what you're trying.

    You're skill has a state, probably unique to it.

    Just checking the isStateAffected would be enough.
    isStateAffected is only half; I also want to evaluate if it's a certain skill. Example:

    Code:
    Window_SkillList.prototype.drawMpCost = function(skill, wx, wy, dw) {  if (this._actor.isStateAffected(2) && [something to evaluate if this skill ID = 30])    { this.drawText('Active', wx, wy, dw, 'right'); }  else  // default drawMpCost function content goes here};
  11. Kenen said:
    isStateAffected is only half; I also want to evaluate if it's a certain skill. Example:

    Window_SkillList.prototype.drawMpCost = function(skill, wx, wy, dw) { if (this._actor.isStateAffected(2) && [something to evaluate if this skill ID = 30]) { this.drawText('Active', wx, wy, dw, 'right'); } else // default drawMpCost function content goes here};
    Alright, then try

    Code:
    if (this._actor.isStateAffected(2) && skill === $dataSkills[30])
  12. kiriseo said:
    Alright, then try

    if (this._actor.isStateAffected(2) && skill === $dataSkills[30])
    That did it. Thanks kiriseo!
  13. How do I check if a skill is usable or not?
  14. Is there a script call for an event to shift its graphic on the x or y axis? 
  15. @Lowell

    Where do you want to check that?

    There is a method Game_BattlerBase.prototype.canUse that checks if skill/item can be used.
  16. Lowell said:
    How do I check if a skill is usable or not?
    There are two functions you could use.

    We take Herold (first actor in the database by default) as an example

    Code:
    if($gameActors[1].canUse(SKILLID)) {// do stuff here}// or use this one. This function gets called from the above one as well.if($gameActors[1].meetsSkillConditions(SKILLID)) {// do stuff here}
  17. Trying to check if a skill is usable in battle, I'll see if these work and reply later on. Thanks for the help.
  18. Where in the game engine's JavaScript are the functions that are called when one selects an item from the Item Menu outside of battle? I essentially want to create a specific event handler for my own item category I created.
  19. I would look in Scene_Item