is it possible to show a variable on screen at all time? (RPGMXP)

● ARCHIVED · READ-ONLY
Started by prince of mars 9 posts View original ↗
  1. hello there I was hopping someone could help me is there a script to show a variable on screen at all times I am using Syn's Ammo script a script which takes one item for example a bullet every time the player attacks of course the problem being there is no ammo counter and when you start to carry 50+ items and you want to know how many shots you have left it can become very irritating here is a copy of syns ammo but you don't really need to look at that all I need is the ability to show a variable on screen I can simply set the variable to represent how many of a certain item you have in inventory  

    Code:
    #============================================================================#                            Syn's Ammo Requirements  #----------------------------------------------------------------------------# Written by Synthesize# Version 1.00# August 15, 2007# Tested with SDK 2.1#============================================================================#----------------------------------------------------------------------------# Customization Section#----------------------------------------------------------------------------module Ammo  # Format = {weapon_id => Ammo_cost}  Range_weapons_id = {33 => 1, 34 => 3, 35 => 3, 36 => 2, 37 => 1, 38 => 1}  # Format = {weapon_id => Item_id  Range_ammo_id = {33 => 48, 34 => 50, 35 => 50, 36 => 48, 37 => 50, 38 => 50}  # Format = {skill_id => Ammo_cost}  Skill_ammo = {92 => 1, 93 => 1}  # Note on Skills: When using Skills the Current Ammo for the equipped  # weapon will be used. So if Skill 73 is used and Weapon 17 is equipped  # then Ammo #33 will be used.end#----------------------------------------------------------------------------# Begin Scene_Battle#----------------------------------------------------------------------------class Scene_Battle  # Alias Methods  alias syn_scene_battle_range make_basic_action_result  alias syn_scene_battle_skill make_skill_action_result  #----------------------------------------------------  # Alias the Attacking method  #----------------------------------------------------  def make_basic_action_result    # Gather the current Ammo Cost    gather_ammo_cost = Ammo::Range_weapons_id[@active_battler.weapon_id]    # Gather the Current Ammo    gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]    # Check if the Active Battler is attacking and if they are using a ranged weapon    if @active_battler.current_action.basic == 0 and Ammo::Range_weapons_id.has_key?(@active_battler.weapon_id)      # Check the Ammo Count      if $game_party.item_number(gather_ammo) >= gather_ammo_cost        # Sufficient Ammo, remove item        $game_party.lose_item(gather_ammo,gather_ammo_cost)        syn_scene_battle_range      else        # Insufficient Ammo        @help_window.set_text("#{@active_battler.name} cannot attack due to insufficient Ammo", 1)      end      # Call Default Code    else      syn_scene_battle_range    end  end  #----------------------------------------------------  # Alias the Skill method  #----------------------------------------------------  def make_skill_action_result    # Gather the current Ammo Cost    gather_ammo_cost = Ammo::Skill_ammo[@active_battler.current_action.skill_id]    # Gather Ammo    gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]    # Check if the Actor is using a defiend skill    if Ammo::Skill_ammo.has_key?(@active_battler.current_action.skill_id)      # Check if Ammo is present      if $game_party.item_number(gather_ammo) >= gather_ammo_cost        # Sufficient Ammo, remove item        $game_party.lose_item(gather_ammo,gather_ammo_cost)        # Call Default Code        syn_scene_battle_skill      else        # Set Window; Do Nothing        @help_window.set_text("#{@active_battler.name} cannot attack due to insufficient Ammo", 1)      end      # Otherwise SKip the check and call default code    else      syn_scene_battle_skill    end  endend#============================================================================# Written by Synthesize# Special Thanks: ~Emo~ for the request#----------------------------------------------------------------------------#                            Ammo Requirements#============================================================================ 
  2. Wouldn't it be better for the script to just show how many items you have left, than for the script to show a variable and for you to have to update that variable? You would have to do a parallel process common event to have it ALWAYS up to date - unless you can pinpoint every place when the number might change and update the variable immediately afterwards.


    And is this in battle screens or on the map?
  3. I figured it would be better to show a variable because that way when you player changes weapon I have a parallel event which changes what weapon the player has on screen well I could allso change what the variable represents so if the player has the pistol equipped it will show bullets but if he has the shotgun equipped it will show shotgun shells 

    I was hoping it would appear in both the combat and world map but the updating will be tricky since I would ideally want to update after every turn is that possible? 
  4. ahhh, I get you. Would it also show the name of the item?
  5. no not really since I show a picture of the gun with it's name on screen at all times when it is equipped
  6. I am using a script which shows the players stats on screen at all time called your hud is there no way to add a few lines which also tell it to display a variable

    Code:
    class Window_YourHUD < Window_Base  def initialize    super(0, 0, 640, 64)    self.opacity = 0    self.contents = Bitmap.new(640 - 32, 64 - 32)    refresh  end  def refresh    self.contents.clear    reset_variables    return if !@actor    draw_actor_hp(@actor, 0, 0)    draw_actor_sp(@actor, 200, 0)    draw_actor_exp(@actor, 400, 0)  end  def reset_variables    @actor = $game_party.actors[0]    @old_hp = @actor ? @actor.hp : 0    @old_maxhp = @actor ? @actor.maxhp : 0    @old_sp = @actor ? @actor.sp : 0    @old_maxsp = @actor ? @actor.maxsp : 0  end  def update    super    refresh if (@actor = $game_party.actors[0] or                @old_hp = @actor ? @actor.hp : 0 or                @old_maxhp = @actor ? @actor.maxhp : 0 or                @old_sp = @actor ? @actor.sp : 0 or                @old_maxsp = @actor ? @actor.maxsp : 0)  endendclass Scene_Map  alias yourhud_main main  alias yourhud_update update  def main    @yourhud = Window_YourHUD.new    yourhud_main    @yourhud.dispose  end  def update    @yourhud.update    yourhud_update  endend
  7. Try this (copy your existing script first, so you can replace it if this doesn't work). There are some issues with that script ... including the test for refreshing - it's saying to refresh all the time - it's not doing any comparisons to see if any details have changed. I've commented out that code, and put in what I THINK it should be. If it's not refreshing, just put that bit back the way it originally was. In addition, you might not like where the variable is being displayed. Logically, if your picture of the weapon is not a part of the hud, then the display of the variable should not be either. You should be updating them in the same place. But if it works ...

    Where I have 18, put in the id of the variable you want to use.

    Spoiler
    Code:
    AMMO_VARIABLE = 18class Window_YourHUD < Window_Base  def initialize    super(0, 0, 640, 64)    self.opacity = 0    self.contents = Bitmap.new(640 - 32, 64 - 32)    refresh  end  def refresh    self.contents.clear    reset_variables    return if !@actor    draw_actor_hp(@actor, 0, 0)    draw_actor_sp(@actor, 200, 0)    draw_actor_exp(@actor, 400, 0)    draw_text(550, 0, 90, line_height, $game_variables[AMMO_VARIABLE].to_s)  end  def reset_variables    @actor = $game_party.actors[0]    @old_hp = @actor ? @actor.hp : 0    @old_maxhp = @actor ? @actor.maxhp : 0    @old_sp = @actor ? @actor.sp : 0    @old_maxsp = @actor ? @actor.maxsp : 0    @old_ammo = $game_variables[AMMO_VARIABLE]  end  def update    super#    refresh if (@actor = $game_party.actors[0] or#                @old_hp = @actor ? @actor.hp : 0 or#                @old_maxhp = @actor ? @actor.maxhp : 0 or#                @old_sp = @actor ? @actor.sp : 0 or#                @old_maxsp = @actor ? @actor.maxsp : 0)    refresh if (@actor != $game_party.actors[0] or                (@actor and (@old_hp != @actor.hp or                            @old_maxhp != @actor.maxhp or                            @old_sp != @actor.sp or                            @old_maxsp != @actor.maxsp)) or                @old_ammo != $game_variables[AMMO_VARIABLE])  endendclass Scene_Map  alias yourhud_main main  alias yourhud_update update  def main    @yourhud = Window_YourHUD.new    yourhud_main    @yourhud.dispose  end  def update    @yourhud.update    yourhud_update  endend
  8. thank you so much for trying but I get the error message 

    script 'your hud' line 17:NameError occurred.

    undefined local variable or method 'line_height' for #<Window_YourHUD:0x3a15e38>
  9. alright - just change line_height to 24.


    How can it not be there? You must have actually REMOVED it from Window_Base.