RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Resolved]Trouble changing a formula (Edit: and modules)

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 83
I'm currently in the process of rebuilding the combat system. I've sucessfully re-written EXP,HP, SP, Hit, Critical and the basic stats. I started to tinker with the atk substat when I this error. I can Start the game, open the menu but when I open the Status or Equip menu it crashes.


Error Code: Wrong Number of Arguments (1 for 0)

Original Code:
Spoiler for:
 
  #--------------------------------------------------------------------------
  # * Get Attack Power
  #--------------------------------------------------------------------------
  #def atk
  #  n = base_atk
  #  for i in @states
  #    n *= $data_states.atk_rate / 100.0
  #  end
  #  return Integer(n)
  #end

Override code: #>> marks the bad line
Spoiler for:
class Game_Battler
  #--------------------------------------------------------------------------
  # * Get Attack Power
  #--------------------------------------------------------------------------
  def atk
#>>    n = base_atk + Float(base_str +((base_str / 10) ** 2) + (base_dex / 5)).rounddown
    return Integer(n)
  end
end

rounddown code: in case you want to look at it.
Spoiler for:
class Numeric
  #Round Down
  def rounddown(nearest)
    self % nearest == 0 ? self : self - (self % nearest)
  end
  
end

I just can't see where im putting the offending argument, can anyone help?

Edit: issue with .rounddown is fixed but the 0 for 1 remains.


///////
///////

Since the problem above hasn't been resolved I started working on another area of scripts and ran into some trouble with using modules. I'm trying to use a series of methods in the module. I can go all the way to the status screen but when I press left or right to call the methods (as it should) i get :

NoMethodError. Undefined Method 'stat_allocate' for SKRen:module

Here's the offending code:
Spoiler for:
Code: [Select]

class Scene_Status

....

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @window_a2.update #menu
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(3)
      return
    end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different status screen
      $scene = Scene_Status.new(@actor_index)
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different status screen
      $scene = Scene_Status.new(@actor_index)
      return
    end
    if Input.trigger?(Input::LEFT)
      case @window_a2.index
      when 0  # add Str
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        SKRenSAS::stat_remove(@actor, 'STR')
        return

      when 1  # add Int
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        SKRenSAS::stat_remove(@actor, 'INT')
        return

      when 2  # add Dex
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        SKRenSAS::stat_remove(@actor, 'DEX')
        return
        
      when 3  # add Agi
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        SKRenSAS::stat_remove(@actor, 'AGI')
        return
      end
      return
    end
    if Input.trigger?(Input::RIGHT)
      case @window_a2.index
      when 0  # add Str
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        SKRenSAS::stat_allocate(@actor, 'STR')
        return

      when 1  # add Int
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        SKRenSAS::stat_allocate(@actor, 'INT')
        return

      when 2  # add Dex
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        SKRenSAS::stat_allocate(@actor, 'DEX')
        return
        
      when 3  # add Agi
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        SKRenSAS::stat_allocate(@actor, 'AGI')
        return
      end
      return
    end
    if Input.trigger?(Input::C)
      case @window_a2.index
      when 4  # Confirm
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        return
      end
    end
  end
end

And the module:
Code: [Select]
 #--------------------------------------------------------------------------
  # * Stat Allocation
  #--------------------------------------------------------------------------
module SKRenSAS
  
  #------------------------
  # * Show Stat Changes
  #------------------------
  STR_MAX_ALLOCATION = 255
  INT_MAX_ALLOCATION = 255
  DEX_MAX_ALLOCATION = 255
  AGI_MAX_ALLOCATION = 255
  STR_MIN_ALLOCATION = 1
  INT_MIN_ALLOCATION = 1
  DEX_MIN_ALLOCATION = 1
  AGI_MIN_ALLOCATION = 1
  
##############################
# #========================# #
# # * Temp Stat up         # #
# #========================# #
##############################
  def stat_allocate(actor, stat)
    if stat == 'STR'
      stat_allocate_process_str(actor)
      return
    end
    if stat == 'INT'
      stat_allocate_process_int(actor)
      return
    end
    if stat == 'DEX'
      stat_allocate_process_dex(actor)
      return
    end    
    if stat == 'AGI'
      stat_allocate_process_agi(actor)
      return
    end
  end
  
  
  #--------------------------------
  # * Determine if Strength Changes
  #--------------------------------
  def stat_allocate_process_str(actor)
    stat_cost = 1 + ((actor.base_str -1) / 10).rounddown
    if actor.all_pts < stat_cost
      $game_system.se_play($data_system.buzzer_se)
      return
    elsif actor.base_str >= STR_MAX_ALLOCATION
      $game_system.se_play($data_system.buzzer_se)
      return
    else
      $game_system.se_play($data_system.confirm_se)
      actor.all_pts -= stat_cost
      actor.str_tempall += 1
      return
    end
  end
  
  
  #------------------------------------
  # * Determine if Intelligence Changes
  #------------------------------------
  def stat_allocate_process_int(actor)
    stat_cost = 1+((actor.base_int -1) / 10).rounddown
    if actor.all_pts < stat_cost
      $game_system.se_play($data_system.buzzer_se)
      return
    elsif actor.base_int >= INT_MAX_ALLOCATION
      $game_system.se_play($data_system.buzzer_se)
      return
    else
      actor.all_pts -= stat_cost
      actor.int_tempall += 1
      return
    end
  end
  
  #---------------------------------
  # * Determine if Dexterity Changes
  #---------------------------------
  def stat_allocate_process_dex(actor)
    stat_cost = 1+((actor.base_dex -1) / 10).rounddown
    if actor.all_pts < stat_cost
      $game_system.se_play($data_system.buzzer_se)
      return
    elsif actor.base_dex == DEX_MAX_ALLOCATION
      $game_system.se_play($data_system.buzzer_se)
      return
    else
      actor.all_pts -= stat_cost
      actor.dex_tempall += 1
      return
    end
  end
  
  #--------------------------------
  # * Determine if Agility Changes
  #--------------------------------
  def stat_allocate_process_agi(actor)
    stat_cost = 1+((actor.base_agi -1) / 10).rounddown
    if actor.all_pts < stat_cost
      $game_system.se_play($data_system.buzzer_se)
      return
    elsif actor.base_agi == AGI_MAX_ALLOCATION
      $game_system.se_play($data_system.buzzer_se)
      return
    else
      actor.all_pts -= stat_cost
      actor.agi_tempall += 1
      return
    end
  end
  
##############################
# #========================# #
# # * Temp Stat down       # #
# #========================# #
##############################
 
 
  def stat_remove(actor, stat)
    if stat == 'STR'
      stat_remove_process_str(actor)
      return
    end
    if stat == 'INT'
      stat_remove_process_int(actor)
      return
    end
    if stat == 'DEX'
      stat_remove_process_dex(actor)
      return
    end    
    if stat == 'AGI'
      stat_remove_process_agi(actor)
      return
    end
  end
  
  
  #--------------------------------
  # * Determine if Strength Changes
  #--------------------------------
  def stat_remove_process_str(actor)
    stat_cost_old = 1 + ((actor.base_str - 2) / 10).rounddown
    if actor.base_str <= STR_MIN_ALLOCATION
      $game_system.se_play($data_system.buzzer_se)
      return
    elsif actor.str_tempall <= 0
      $game_system.se_play($data_system.buzzer_se)
      return
    else
      $game_system.se_play($data_system.confirm_se)
      actor.all_pts += stat_cost_old
      actor.str_tempall -= 1
      return
    end
  end
  
  
  #------------------------------------
  # * Determine if Intelligence Changes
  #------------------------------------
  def stat_remove_process_int(actor)
    stat_cost_old = 1 + ((actor.base_int - 2) / 10).rounddown
    if actor.base_int <= INT_MIN_ALLOCATION
      $game_system.se_play($data_system.buzzer_se)
      return
    elsif actor.int_tempall <= 0
      $game_system.se_play($data_system.buzzer_se)
      return
    else
      $game_system.se_play($data_system.confirm_se)
      actor.all_pts += stat_cost_old
      actor.int_tempall -= 1
      return
    end
  end
  
  
  #---------------------------------
  # * Determine if Dexterity Changes
  #---------------------------------
  def stat_remove_process_dex(actor)
    stat_cost_old = 1 + ((actor.base_dex - 2) / 10).rounddown
    if actor.base_dex <= DEX_MIN_ALLOCATION
      $game_system.se_play($data_system.buzzer_se)
      return
    elsif actor.dex_tempall <= 0
      $game_system.se_play($data_system.buzzer_se)
      return
    else
      $game_system.se_play($data_system.confirm_se)
      actor.all_pts += stat_cost_old
      actor.dex_tempall -= 1
      return
    end
  end
  
  #--------------------------------
  # * Determine if Agility Changes
  #--------------------------------
  def stat_remove_process_agi(actor)
    stat_cost_old = 1 + ((actor.base_agi - 2) / 10).rounddown
    if actor.base_agi <= AGI_MIN_ALLOCATION
      $game_system.se_play($data_system.buzzer_se)
      return
    elsif actor.agi_tempall <= 0
      $game_system.se_play($data_system.buzzer_se)
      return
    else
      $game_system.se_play($data_system.confirm_se)
      actor.all_pts += stat_cost_old
      actor.agi_tempall -= 1
      return
    end
  end
  
  
    
  #------------------------
  # * Reset Stat Changes
  #------------------------
  def reset
    actor.str_tempall = 0
    actor.int_tempall = 0
    actor.dex_tempall = 0
    actor.agi_tempall = 0
  end
  
  
  #------------------------
  # * Finalize Stat Changes
  #------------------------
    
  def stat_allocate_final(actor)
    actor.str_all += actor.str_tempall
    actor.int_all += actor.int_tempall
    actor.dex_all += actor.dex_tempall
    actor.agi_all += actor.agi_tempall
    actor.str_tempall = 0
    actor.int_tempall = 0
    actor.dex_tempall = 0
    actor.agi_tempall = 0
  end
end

and if I put

include SKRenSAS

I get this error:

NameError Occurred. Uninitialized Constant Scene_Status::SKRenSAS

Can anyone help, I'm tired of reading the same useless tutorials online and getting no where.


EDIT: Thanks NAMKCOR for your help in the IRC
« Last Edit: September 29, 2009, 01:55:11 PM by S.K. Ren »
My life is like every script I write: It runs great except for the f*cked up bits.

*
Rep:
Level 87
rounddown needs a parameter, and you're not passing it one.

Why are you converting the calculation to a float and then back to an integer again?  Unless there's some gotcha here that I'm not seeing at a quick glance, you could achieve the same thing by:
(base_str +((base_str / 10) ** 2) + (base_dex / 5)).to_i
or
(base_str +((base_str / 10) ** 2) + (base_dex / 5)).floor

« Last Edit: September 28, 2009, 10:14:03 PM by shaz »
Always remember you're unique.
Just like everybody else.

**
Rep:
Level 83
it's a 1 for 0 not a 0 for 1. The error is occurring before it even get 's to the .rounddown

also i set nearest to default at 1 so that's no longer an issue  :D
My life is like every script I write: It runs great except for the f*cked up bits.