Help with modding Todd's Difficulty Select script

● ARCHIVED · READ-ONLY
Started by Kes 9 posts View original ↗
  1. I am using Todd's difficulty select script, found here: http://forums.rpgmakerweb.com/index.php?/topic/2789-difficulty-selection/

    Todd, however, is no longer working with Ruby or RM, and so is not supporting his script.

    What I would like to do is to be able to identify what difficulty level a player has chosen so as to display the mode selected in the Menu.  I can do this using Yanfly's menu scripts if I have a variable switch which picks this up.

    However, I cannot see how Todd's script identifies the level selected, so cannot use it to activate a variable.

    Can anyone explain to me how this could be done?  Please bear in mind that I'm a scripting idiot, so the explanation needs to be in clear, baby steps for me to understand.

    Thanks.
  2. Well, it looks to me like Todd has added to the $game_system for storing his difficulty value.

    On line 88 he does a case statement check of $game_system.todd_difficulty and expects to find 0,1,2, or 3 so that he can use his own constants.  He then does a calculation based on what difficulty it is and multiplies it by his own constants (EASYM, HEROICM, HARDM, or just 1 which is for normal).  If you are just wanting to display a piece of text in the menu you can identify that 0=Easy, 1=Normal, 2=Heroic, 3=Hard.

    If you look at line 106 - 119 that is where he is defining todd_difficulty accessor and the initialize method required to set it up in the Game_System class.

    class Game_System #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :todd_difficulty # save forbidden #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- alias todd_difficulty_gamesystem_init initialize def initialize @todd_difficulty = 0 todd_difficulty_gamesystem_init end end
    So, I believe you should just be able check the difficulty by using something like this (I've just made up the @difficultySetting variable for this example):

    @difficultySetting = $game_system.todd_difficulty
    And like I mentioned further up, if you aren't trying to do anything other than show a piece of text then you can just match the number to the difficulty text: 0="Easy", 1="Normal", 2="Heroic", 3="Hard".

    Hope that helps.
  3. Being a scripting noob, I've not understood exactly what I need to do.

    How do I use the $game_system.todd_difficulty to activate a variable switch so that 1 = easy, 2 = normal etc.

    Sorry to be so dumb, but as I said, I need baby steps to work through this.
  4. Just so I can get it through my head what you are wanting to do:

    What I would like to do is to be able to identify what difficulty level a player has chosen so as to display the mode selected in the Menu.  I can do this using Yanfly's menu scripts if I have a variable switch which picks this up.
    What exactly would be displayed on this menu?  Is it just the text "Easy", "Normal", "Hard", etc?  Is this meant to be an option on a menu that does something based on what difficulty you have set, or is it just visual?

    Also, what menu are we talking about here? Is it the one that already has "Difficulty" on it once the script is installed? Is it just that you want "Difficulty" to now include the current setting on the menu?

    If it's just visual text and if you need to use a variable, then I would actually just suggest doing the following:

    Add this line to the Module TODDDIFFICULTY section (just below SWITCH = 5) at about line 72

      #Variable to be used for storing the currently selected difficulty text  VARIABLE_TEXT = 1and make the number whatever variable id you want to use to store the text.Then change the following methods to add the storing of the text to the variable:

    def command_easy  $game_system.todd_difficulty = 0  $game_variables[TODDDIFFICULTY::VARIABLE_TEXT] = TODDDIFFICULTY::EASYT  Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)  return_sceneend#--------------------------------------------------------------------------# * [normal] Command#--------------------------------------------------------------------------def command_normal  $game_system.todd_difficulty = 1  $game_variables[TODDDIFFICULTY::VARIABLE_TEXT] = TODDDIFFICULTY::NORMALT  Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)  return_sceneend#--------------------------------------------------------------------------# * [heroic] Command#--------------------------------------------------------------------------def command_heroic  $game_system.todd_difficulty = 2  $game_variables[TODDDIFFICULTY::VARIABLE_TEXT] = TODDDIFFICULTY::HEROICT  Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)  return_sceneend#--------------------------------------------------------------------------# * [hard] Command#--------------------------------------------------------------------------def command_hard  $game_system.todd_difficulty = 3  $game_variables[TODDDIFFICULTY::VARIABLE_TEXT] = TODDDIFFICULTY::HARDT  Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)  return_sceneendYou could check that the variable is being updated with the correct text but running a playtest, hit Esc for the menu, selecting a Difficulty and then when you are back on your map press F9 and scroll down to find the variable with the Id you gave to VARIABLE_TEXT.  The value of the variable should be the text for whatever difficulty you selected.
    Hope that is the sort of thing you are looking for.  If not, just let me know and we'll see if we can work this out more.
  5. So that you can fully understand what I'm trying to do, it's this.

    In Yanfly's Save Engine it is possible to set a variable at line 102 which displays data on the save screen.  The script can be found here: https://github.com/Archeia/YEARepo/blob/master/Menu/Ace_Save_Engine.rb

    The idea is to use the variable created which identifies which difficulty level has been chosen so as to display Easy, Normal etc.

    I made the script adjustments you suggested, and started a New Game.  The first time I tried to save, I got the following error message

    Script 'Yanfly Save Engine' line 459: NoMethodError

    undefine method 'group' for "Normal" : String

    line 459 in Yanfly's script reads:

     value = @header[:variables][variable_id].group

    Do you know what this means?

    Thanks.
  6. I've had a quick look (admittedly I'm not at my VX Ace pc at the moment so can't confirm this) but I think the script is wanting the contents of the variables to always be a number.  But we're trying to display text.

    Can you make the following changes to these methods in Todds Difficulty script and then try again?

    def command_easy  $game_system.todd_difficulty = 0  $game_variables[TODDDIFFICULTY::VARIABLE_TEXT] = $game_system.todd_difficulty  Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)  return_sceneend#--------------------------------------------------------------------------# * [normal] Command#--------------------------------------------------------------------------def command_normal  $game_system.todd_difficulty = 1  $game_variables[TODDDIFFICULTY::VARIABLE_TEXT] = $game_system.todd_difficulty  Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)  return_sceneend#--------------------------------------------------------------------------# * [heroic] Command#--------------------------------------------------------------------------def command_heroic  $game_system.todd_difficulty = 2  $game_variables[TODDDIFFICULTY::VARIABLE_TEXT] = $game_system.todd_difficulty  Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)  return_sceneend#--------------------------------------------------------------------------# * [hard] Command#--------------------------------------------------------------------------def command_hard  $game_system.todd_difficulty = 3  $game_variables[TODDDIFFICULTY::VARIABLE_TEXT] = $game_system.todd_difficulty  Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)  return_sceneend
    These changes will make it so that the number value of the difficulty selected is what is stored in the variable instead.  If you then start a new game, select a difficulty, and try saving do you still get the same error?

    Hopefully what should happen is that the number (0,1,2, or 3) should be appearing on your save file.  If that works, then we just need to change these methods back to what they were and then find out how to fix the save script - I should be able to look at that once I get home from work.
  7. Success!  I put in the new version, chose 'Normal' and in the save screen I had

    Mode       1

    As the numbering goes from 0 - 3, that is correct.

    So now to get text instead of numbers.  
  8. Right-o. This should do it, with any luck.

    If you could change the four instances of this line back to what they were in post #4 of this topic:

    $game_variables[TODDDIFFICULTY::VARIABLE_TEXT] = $game_system.todd_difficulty
    and then change this one line:

    value = @header[:variables][variable_id].groupto be:

    if (@header[:variables][variable_id].is_a?(Numeric))  value = @header[:variables][variable_id].groupelse  value = @header[:variables][variable_id]endI think that should do it.  If you could give it a go and we'll see.
  9. Sheer perfection!  You are a wonder!

    Thank you so very much.  I couldn't even have contemplated doing this without your help.  I am very grateful.