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.

[Resolved] Cannot convert nil into string

Status
Not open for further replies.

MDC123

Member

I'm really no good at scripting, and this error is really starting to annoy me.

I am using a script which gives custom Battle Backgrounds and at first it worked fine, then the next time i tried it i get the error

Script 'Cache' line 75: TypeError occured.

cannot convert nil into String


Any way of fixing this?  :cry:
 
Post your scripts.

What it is doing is trying to load from the cache, but something is sending a nil argument. My best guess it's sending an instance of an object, but the instance is undefined and sending nil instead.
 

MDC123

Member

The script is

#==============================================================================
# â–  VX-RGSS2-7 Change Battle Background [Ver.1.0.0]     by Claimh
#------------------------------------------------------------------------------
# English Translation By: Elemental Crisis [http://www.rpgcrisis.net]
#------------------------------------------------------------------------------
# Changes the battle background.
#==============================================================================


module BattleBack
  #   Select Battle Background Type
  #   0:Current map with wave effect for battle background (Default VX Style).
  #   1:Current map used as battle background.
  #   2:Uses a picture for battle background.
  BB_TYPE = 2
 
  # Display Battle Floor
  BT_FLOOR = false

  # Picture (Only required if BB_TYPE = 2)
  M_B_BACK = {
    # Map ID => "Picture File Name(Graphics/System)"
    1 => "Mountains"
  }
end


#==============================================================================
# â–  Spriteset_Battle
#==============================================================================
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # â—
 
Seems like you have to modify this part with your map-battleback associations:
Code:
  # Picture (Only required if BB_TYPE = 2)
  M_B_BACK = {
    # Map ID => "Picture File Name(Graphics/System)"
    1 => "Mountains"
  }

1. Put your battle backdrop files in the Graphics/System/ folder.
2. For each map, add a key => value pair to that part of the script I highlighted. For example, if map with ID 1 uses a background file called Mountains.png, map 2 uses a background file called Forest.png, and 3 uses Grasslands.png, you'd have something like:
Code:
  # Picture (Only required if BB_TYPE = 2)
  M_B_BACK = {
    # Map ID => "Picture File Name(Graphics/System)"
    1 => "Mountains"
    2 => "Forest"
    3 => "Grasslands"
#... and so on
  }

Right now it probably looks for battle backdrop for a certain map (say number 3) and can't find any associated backdrop because you didn't define it; so it gives you an error.
 

MDC123

Member

Ok, tried that, but now i get

Script 'Battleback' line 24: SyntaxError occured.

as soon as i start the game  :crazy:

Line 24 would be   2 => "Forest" in the example, but in my case it is 2 => "Goblin"

Sorry to be such a pain  :sad:
 
Make sure you have:
Code:
  M_B_BACK = {
    # Map ID => "Picture File Name(Graphics/System)"
    1 => "Mountains",
    2 => "Goblin"
  }
Not
Code:
  M_B_BACK = {
    # Map ID => "Picture File Name(Graphics/System)"
    1 => "Mountains"
    2 => "Goblin"
  }
 
Oh, sorry, add commas between each pair... like this:
Code:
  # Picture (Only required if BB_TYPE = 2)
  M_B_BACK = {
    # Map ID => "Picture File Name(Graphics/System)"
    1 => "Mountains",
    2 => "Forest",
    3 => "Grasslands"
#... and so on
  }

Edit: SephirothSpawn beat me to it. :)
 

MDC123

Member

Thanks a lot guys it works fine now  :lol:

Can't believe it was something so simple i feel like a fool  :dead:

Thanks again for the help, now i can get on with my game!  :straightthumb:
 
Status
Not open for further replies.

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