Ruby/RGSSx questions that don't deserve their own thread

Ah, so it literally updates once per second then? I assumed it updated according the clock speed.

Cool, that's helpful thank you.

EDIT: 60x a second, I mean. curse you, maths.
Yeah, update is called once per frame unless you use a plugin that changes the cycle.
Of course.... it's 60 FPS..... I feel stupid now.

Thanks again.
Another question for you good folks.

I'm trying to write something that will extend the basic item types that show in the item menu. So normally you just get normal items, weapons, armour, key items. I'd like to have other stuff in there like crafting ingredients and other things.

I'm doing this by way of putting note tags in the items that can be read by the script and then sort them into more categories. So I've extended class RPG::BaseItem with a method that will return true if a certain regex is found.

Code:
class RPG::BaseItem
 
  def item_type?(arg)
    # Evaluate if true
  end
 
end

class Window_ItemList < Window_Selectable

  def include?(item)
    case @category
    when :foo
      item.item_type?(bar)
    else
      false
    end
  end

end

But no matter what I try, it throws an NoMethodError/undefined method error. It just can't see item_type? and I've no idea why. I've tried moving them around (I would have thought that RPG:BaseItem would need to be above Window_ItemList but it doesn't make a difference either way). I've tried calling the methods different things, as if that would make difference(!)

I've looked at other scripts and they seem to do it this way so I'm pretty stumped. Any help appreciated.

Thanks
Can you show me your exact implementation rather than some similar-looking pseudocode? It's hard to debug an actual script based on a stripped-down example.
Sure thing, here's literally what I've got:

Code:
class RPG::BaseItem
 
  def item_type?(key)
    case key
      when :heal
        true if @note =~/<itemtype:healing>/i
      when :ingredient
        true if @note =~/<itemtype:ingredient>/i
      when :misc
        true if @note =~/<itemtype:misc>/i
      else
        false
    end
  end
 
end

class Window_ItemList < Window_Selectable

  def include?(item)
    case @category
    when :all
      item.is_a?(RPG::Item)
    when :healing
      item.item_type?(:heal)
    when :weapons
      item.is_a?(RPG::Weapon)
    when :armour
      item.is_a?(RPG::Armor)
    when :ingredients
      item.item_type?(:ingredient)
    when :other
      item.item_type?(:misc)
    when :quest
      item.is_a?(RPG::Item) && item.key_item?
    else
      false
    end
  end

end

And the full error is

Scipt 'Custom Menu' line 299: NoMethodError occured.
undefined method 'item_type?' for nil:NilClass

What's weird is it's throwing it against nil Class despite the fact I know there's items there for it to look at. If I comment out my custom lines of code, but leave the base RPG Maker lines in there, it works fine.
It sounds like at some point a nil item is being passed in to include? for some reason. Your item_type? method doesn't check whether item exists, which isn't an issue for is_a? because it's a method of the Object class from which everything else derives, and "nil" although denoting the absence of an object is actually an object itself.
Super! I just added a
return false if item == nil

and it works perfectly.

Thanks for your swift and spot-on reply, Trihan! 😀
No worries! It's what I'm here for. 🙂
Edit: deleted (I worked it out)
Hmmm...

I've wondered about this.

Okay, so there are ways to scroll the map using script calls (which I intend to use to allow the player free camera panning).

Is there a way to reset the camera back to the player instantly?

@Trihan , mayhaps you would know?
Yes. I'll help you with that when I get on my laptop.

@Reapergurl Do you want it to scroll smoothly or "snap" when panning?
@Trihan Either way works.

Though honestly, my inquiry was on the script call itself (if one exists).
$game_map.scroll_up(distance), $game_map.scroll_down(distance), $game_map.scroll_left(distance), $game_map.scroll_right(distance) or $game_map.set_display_pos(x, y)
@Trihan Can $game_map.set_display_pos(x,y) be $game_map.set_display_pos(v[#],v[#])

???
It can be $game_variables[id], yes.
@Trihan Of course, it throws an error.
Show me the line you're trying to use.
The error it threw was in Game Interpreter, line 450.

PHP:
$game_map.scroll_up(1)
$game_map.scroll_right(1)
$game_map.scroll_down(1)
$game_map.scroll_left(1)

$game_map.set_display_pos($game_variables[141], $game_variables[142])

The Error was thrown because
PHP:
input.press?(:Z)

This is the correct syntax, silly me.
PHP:
Input.press?(:Z)
You're not using this in the script part of a conditional branch, are you? That's what interpreter line 450 is.

Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/