Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

System Development - Coders-Block

Tdata

Sponsor

I recently found the settings script for a bit of code I'd been messing with a while back.  My problem is that while I have the settings, I need to rewrite the script.  I forget how...  :tongue:

I was wondering if someone could point me in the right direction...  Here is what I have:
Code:
#=================================
#****Settings****
#=================================
module Soul
  
  Word = 'Soul'
  Word_Plural = 'Souls'
  
  SClass = {} #Class of Soul
  SClass_Name = {} #Name for the Class of Soul by ID
  
  Increase_HP = {} #(Class ID) => (Number to increase Max HP) 
  Increase_MP = {} #(Class ID) => (Number to increase Max MP) 
  
  
  
  SClass.default = 1
  SClass_Name.default = 'Basic'
  Increase_HP.default = 1
  Increase_MP.default = 1
  
  
end

class RPG::Enemy
  Enemies_That_Have_Souls = {}
  Enemies_That_Have_Souls.default = true
  
  def have_soul?
    return Enemies_That_Have_Souls[@id]
  end
end

class RPG::Actor
  Actors_That_Use_Souls = {}
  Actors_That_Use_Souls.default = false
  
  def uses_souls?
    return Actors_That_Use_Souls[@id]
  end
end

Any help would be appreciated.
 
First of all, I have no clue what the 'script' you're trying to write is supposed to do, this doesn't tell me anything.

Second of all, if you're defining RPG::Enemy, etc, you have to write it in a module

Code:
#===============================================================================
# ** Module RPG
#===============================================================================
module RPG
  #--------------
  # * Enemy Class
  #--------------
  class Enemy
    alias_method :rpg_enemy_souls_initialize, :initialize
    def initialize
      rpg_enemy_souls_initialize
      @souls
    end
    attr_accessor :souls
  end
  #--------------
  # * Actor Class
  #--------------
  class Actor
    alias_method :rpg_actor_souls_initialize, :initialize
    def initialize
      rpg_actor_souls_initialize
      @souls
    end
    attr_accessor :souls
  end
end
#===============================================================================

Third of all, defining methods other than initialize in a 'module' class doesn't do anything, you're going to have to add it (or alias it if adding to a current method) into Game_Enemy and Game_Actor.
 

Tdata

Sponsor

Oh, sorry, i knew i forgot something.

What this version of the script did is everytime you killed an enemy you aquire it's soul and it makes you stronger depending on the class of Soul... 

Also,
Code:
class RPG::Enemy
  Enemies_That_Have_Souls = {}
  Enemies_That_Have_Souls.default = true
  
  def have_soul?
    return Enemies_That_Have_Souls[@id]
  end
end

class RPG::Actor
  Actors_That_Use_Souls = {}
  Actors_That_Use_Souls.default = false
  
  def uses_souls?
    return Actors_That_Use_Souls[@id]
  end
end
Works just fine. 
 
Kain Nobel":2l1ninj6 said:
Second of all, if you're defining RPG::Enemy, etc, you have to write it in a module
no he doesn't..
writing
Code:
class RPG::Actor
  def lol
    p "lol"
  end
end
would work the same as if he wrote
Code:
module RPG
  class Actor
    def lol
      p "lol"
    end
  end
end
 

Tdata

Sponsor

Okay, Let me change my question since i seem to remember a bit.

How would i 'access' the settings? I'm thinking it would be something like:
Code:
Soul::(Constant Name)
But I'm not perfectly sure...

Also, How would I use something like:
Code:
class RPG::Enemy
  Enemies_That_Have_Souls = {}
  Enemies_That_Have_Souls.default = true
  
  def have_soul?
    return Enemies_That_Have_Souls[@id]
  end
end

I know that I'm asking a lot of questions for someone who has done this before, but it was quite some time ago and I did it the hard way...
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top