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.

[SOLVED]Script help (mostly menu related)

Ok so what started out as pretty simple and something ive been able to figure out how to do on my own with my limited scripting knowledge, and i mean very limited, is starting to snowball into something im going to need a little pointer here and there about.

ok what ive been doing so far is this, making a script for each menu scene, like scene_item for example that puts an image one z axis higher than the windowskin. and ill have some scrolling panoramic images for the backgrounds on some of them, like status screen and on the main menu screen.

Ok now where ive run into problems trying to figure things out

problem 1: i changed the text color of the item list to a faded black ink like color and that looks fine, my problem here is, it also changes the item list text color in battles, which makes it hard to read on the windowskin while im fighting. id also like to change the menu item list's font to somethign a little more handwritten looking so as to make it look like an inventory list (the background i have for my item screen is like an inventory log book kind of theme)

id like to know how to change only the menu text color while leaving the color of text in battle white

problem 2: not really a problem yet as i havent started the status screen yet, but i want to use a different background for status based on the character, so say i look at the status of the main character, i want his status screen to show an image of him (that i will draw for each caracter) basicly i want make a script like mine that has i guess a variable or something that when character A's status screen is accessed their background has their image and when Character B is accessed theirs is shown etc

thats pretty much it for now, as any further questions come up ill be adding to it in this thread to keep things tidy
 
Go to the class Window_Item,
to the method draw_item, and change this line:
self.contents.font.color = normal_color
with:
battle_color = normal_color # or any color you want. This is white.
menu_color = Color.new(0, 0, 0, 255) # or any color you want. This is black.
self.contents.font.color = $game_temp.in_battle ? battle_color : menu_color
 
ahh cool, what i ended up doing to change it initially was change the self.contents.font.color = normal_color line with = Color.new(40, 40, 40, 255) and thats when i realized it changed battle too

thanks for the timely reply
 
try this for the status screen:

first, make a global variable (i named mine $backs),
and have it be an array with 4 cells. Each cell should
contain the name of the background you want for
the corresponding actor.

then, in your Scene_Status, put in under 'def main':

back = $backs[@actor_index]
(replace $backs with the name of your variable)

this declares a new instance variable, that holds the
name of the background to display.

then :
@bsprite = Sprite.new
@bsprite.bitmap = RPG::Cache.picture(back)

this creates a new sprite, that will hold and display your
background. The second line set the background to
display. You can replace 'picture' with the folder
you want your backgrounds in. ('picture', 'icon', 'character',
all those)

the only other modification would be the opacity of the status
window, and you should know how to change that.
 
hmmm, well im half way grasping what to do, im not really sure how to make a global variable, ill have 10 characters that youll have access to, one of them as a temporary companion but an important character to the story. so im assuming that this global variable will need an array with 10 cells correct.

would it be like:
$backs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
where the #'s = character ID or something?
and how do i make them correspond to a character ID

also what id like to know is where do i put the global variable, does it go in Scene_Status or do i make a new script? i have my scripts for menu and item (so far) in a script called menu edit where i just did

class Scene_Status
def whatever_i_put main
etc
etc

im really amateur at this but im trying to learn as i go

so if im grasping this

i need liek the $backs = [1, 2, 3] stuff

then i need
Code:
 

class scene_status

  alias status_backs main

  def main

   if $backs = 2

   @bsprite = Sprite.new

   @bsprite.bitmap = RPG::Cache.picture "back2"

   @bsprite.z = 2 #i set the windowskin to layer 0

   status_backs

   @bsptite.dispose

end

   alias status_backs update

   def update

   @bsprite.update

   status_backs

 end

end

 
for each character correct?
 
You have the global variable initialized correctly, but the way I did it makes the background depend on which place the actor is in your party.

I didn't realize you wanted it to correspond to the actor id in the database...

I'm not sure but for that, you might be better off using a hash ( {} ).

Like this:

$backs = {0 => "<actor1's background>", 1 => "<actor2's background }

And so on and so forth.

And also, for the Scene_Status, there doesn't need to be an if statement.
The basic code would be:
[rgss] 
$backs = ["BG1","BG2","BG3","BG4"] # makes your global variable
class Scene_Status # class
  if !@aliased # to make it F12 proof
    alias gulch_scene_status_main main
    alias gulch_scene_status_update update # the aliases
    @aliased = true
  end
  def main
    @back = $backs[@actor_index] # gets the background name from your global variable
    @bsprite = Sprite.new # creates the sprite to hold your background
    @bsprite.bitmap = RPG::Cache.picture(@back) # makes the bitmap for your backgroud
    gulch_scene_status_main # uses your alias of 'def main'
    @bsprite.dispose # disposes your sprite when you change scenes
  end
  def update
    @bsprite.update # updates your background
    gulch_scene_status_update # uses your alias of 'def update'
  end
end
 
[/rgss]

But it won't make the background according to the database, it'll
do it according to the party position of the actor.

Mess around with that and see what happens.
 
EDIT:(had a syntax error, which was my error not yours) you know what im retarded, i copy/pasted your example and modified it a bit for image names, and what i failed to notice was that it copied the line numbers with the script. and its working. but now im wondering, lets say the character that was at slot 2 in the party later is in slot 3, will it show slot 3's character for the character that was in slot 2?
also had to add the @bsprite.z = 2, at first once i figured out i had 1., 2., 3. in front of all the lines of code and fixed that i thought it wasnt doing anything but i forgot about it having to be above the windowskin...things i forget

i appreciate the time youre taking to help me, if theres anything you need help with be it visual or music lemme know.


what would you recommend personally for the best way to go about this, i have 10 characters that need a status screen with their image on it and linking it to a character ID seemed like the cleanest and most compatible way of going about it to me. but, what would i know im an amateur. also what comes to mind is making the BG pics names something like "Fighter001_BG.png" or whatever and then making it chose the backs for the characters using some kind of actor.name + _BG or something maybe?
 
could i do that with a hash for the character name?

like $backs = { 0 => actor.character_name + '_BG', 1 => actor.character_name + '_BG', and so on}

?? or something, i dunno what im doing lol
 
omfg i figured it out lol, heres what i came up with and its working without a hitch

thank you both so much, this would have taken me heaps longer without your pointers in the right direction

Code:
#Individual Character Status Screens. kinda by me, Gulch

#With mucho mucho mucho help from Near and Silver Wind

 

#to use simply make take a screenshot of the status screen. crop it

#toss it in photoshop and make a it a layer, set the opacity way down and 

#use it as a template to make a custom one peice window skin for status

# -use it as a non working layer over the top of the other layers so you

#can line everything up right

#name your finished image the corrisponding character's name with _BG added and

#it uses that image for your background

 

 @back = {0 => RPG::Actor.name + '_BG'}

 class Scene_Status # class

   if !@aliased # to make it F12 proof

     alias gulch_scene_status_main main

     alias gulch_scene_status_update update # the aliases

     @aliased = true

   end

   def main

     @actor = $game_party.actors[@actor_index]

     @back = [@actor.name] # gets the background name from your global variable

     @bsprite = Sprite.new # creates the sprite to hold your background

     @bsprite.bitmap = RPG::Cache.picture(@actor.name + '_BG') # makes the bitmap for your backgroud

     @bsprite.z = 2

     gulch_scene_status_main # uses your alias of 'def main'

     @bsprite.dispose # disposes your sprite when you change scenes

   end

   def update

     @bsprite.update # updates your background

     gulch_scene_status_update # uses your alias of 'def update'

   end

 end

  

 
 
That's pretty sick, glad I could help.

Also, that code is functional, but not as clean as it could be,
why not do something like this:

[rgss] 
# Individual Character Status Screens. kinda by me, Gulch
# With mucho mucho mucho help from Near and Silver Wind
 
# to use simply make take a screenshot of the status screen. crop it
# toss it in photoshop and make a it a layer, set the opacity way down and
# use it as a template to make a custom one peice window skin for status
#  -use it as a non working layer over the top of the other layers so you
# can line everything up right name your finished image the corrisponding
# character's name with the suffix you set in the config section added and
# it uses that image for your background
 
module GConfig
 
  # Added a config module
  Suffix = '' # The suffix of the image name. Leave it '' for no suffix.
  Opac = 160  # The opacity (alpha/translucency) of the status window.
 
end
 
 # deleted '$back = ' it was unneeded.
 class Scene_Status
   if !@aliased # to make it F12 proof
     alias gulch_scene_status_main main
     alias gulch_scene_status_update update
     # the aliases
     @aliased = true
   end
   def main
     @actor = $game_party.actors[@actor_index]
     # Deleted the unneeded '@back =' and [email='@bsprite.z]'@bsprite.z[/email] =' lines.
     @bsprite = Sprite.new
     # creates the sprite to hold your background
     @bsprite.bitmap = RPG::Cache.picture(@actor.name + GConfig::Suffix)
     # makes the bitmap for your backgroud
     gulch_scene_status_main
     # calls the original method
     @bsprite.dispose
     # disposes your sprite when you change scenes
   end
   def update
     @bsprite.update
     # updates your background
     gulch_scene_status_update
     # calls the original method
   end
 end
 
# fixed the opacity of the status window.
class Window_Status < Window_Base
  alias wstatus_init initialize
  def initialize(actor)
    wstatus_init(actor)
    self.opacity = GConfig::Opac
  end
end
 
 
[/rgss]

Study that a little, and it should become clear to you.
 
thats really cool how theres so many ways you can go about doing the same thing.

now i have questions about the new cleaner one you posted.

are there performance gains to doing it that way?

i had a sprite.z = in mine that set the picture to draw one layer above the windowskin thus eliminating the need for an opacity change (well at least in my working project, i moved the windowskin to the lowest layer for the base windows in the menu) with the way you did it im assuming to make the windowskin hide completely you'd set the opac to 0 correct? cause if you didnt it would draw over the top of the image.
 
Yes, the window is drawn a layer above the image, so 0 would
be just the image being drawn. Also, there may be performance
speed ups, but probably not that much since it's only like 3 lines
of unnecessary code.

But also, i'd suggest not drawing the image over the window,
as it would, more likely than not, hide the stats and you may decide
later that you want to display the window and the image.
 
it doesnt hide any stats, im not sure what layer the text is on but its higher than 120, and my whole reason for not showing the windowskin is that my image is a full screen windowskin replacement, im doing all pages of the menu with custom backgrounds, like my item screen is an inventory log book, and all the text and bars and everything are above the image with the windowskin hidden below it, im not just doing the image of the character on the default windowskins, im making my own custom per page windowskins via images. it doesnt hide the highlighted little selection box that goes around text and everything works as it should. ive also done the title screen in this way but with a scrolling panoramic image under 2 layers of static images with transparencies and the new game, continue, end and selection thingy show above them

but , i see how the script you posted would be more efficient and compatible with other scripts that change stuff in scene_status and whatnot and im going to go with it because it is cleaner and i probably wont run into any incompatibilities down the road as i may add other scripts to my game.

one thing id like to do later is make a world map option from the main menu, where it basicly transfers the player to a hand drawn world map i have yet to make, changes the character graphic to a cursor that you walk around the world map with and use a button press like you would opening a door or chest to go to the selected area, but id want the areas to only be on the map after you visit them and id also want it so that if you cancel out of the world map it takes you back to the menu and restores the walking graphic to the default main character and leaves you were you were before you opened the map screen. this, i have no idea how to do, but it might be easier to do like a waystone system so that way if you change your mind you would just select the waystone you entered from and then i would have to deal with the problem of it remembering where you were when you opened the map. sorry ranting about future endeavors.

i thank you again for your time and support
 
For a world map, you don't don't need player coordinates, just use something
like this:

[rgss] 
if Input.trigger?(Input::Left) && @index >= 0
  @index -= 1
  @cursor.x -= 50
end
if Input.trigger?(Input::Right) && @index <= 4
  @index += 1
  @cursor.x += 50
end
if Input.trigger?(Input::C)
  case @index
  when 0
    # Option 1
  when 1
    # Option 2
  when 2
    # Option 3
  when 3
    # Option 4
  when 4
    # Option 5
  end
end
 
[/rgss]

That's basically how command windows are coded.
 
ok but lets say i do it with events rather than a menu option and use a teleport from select save points like in ff12, that i beleive i could do without a script right?

make a show choice, save, teleport, exit. selecting teleport would bring me to a map that looks like a paper map, and changes the character graphic to a cursor, youd then transfer player to locations youve discovered by walking to them as the cursor and slecting them while standing on them, that way i dont have to worry about remembering player locations cause if you change your mind you just go back to the one you openned the map from.

but if i wanted to do it with a script theres just too much that i have no idea about as far as scripting i want it to work a similar way, where it shows a world map and you transfer places in the same way as you would in the above stated method but from the menu or it makes a new menu window at the save points where theres a list on the side, and when you scroll through the list it moves a cursor on the map to the corresponding location. i think im better off doing this with events actually cause a script to do what i want specificly would be a bit too complex i think. but it would be an interesting and useful script to share with people who wanted a cool teleport/world map/transfer script instead of using the standard "exit town, walk to cave dungeon in the 3 foot tall mountain range" type world map. cause i dont really like the standard oldschool 2d rpg world maps.

what i was thinking was something like this
mapscreenexamplecopy.png
i could probably figure out how to make the scene and window portions of the script to make it take you to said window but i have no idea how to make it function, main things would be, how do i make it update the list/locations as you discover them. and id probably prefer it only be accessed from a save point or a teleport spot etc, have it use a call script in the event or something i guess
 
You know, doing it with events might actually be easier, but a script
would be much more efficient.

And for having only visited locations available, I suggest switches, and
a configuration module, like this:
[rgss] 
module GConfig
  Picture = "example" # replace with the name of your world map pic
  Local1Name = "Location 1"
  Local1Map = 1
  Local1Switch = 1
  Local2Name = "Location 2"
  Local2Map = 2
  Local2Switch = 2
  List = [Local1Name, Local2Name]
  # To add a location, put in 2 new lines:
  # Local<location number>Name = "<location name>"
  # Local<location number>Switch = <location visited switch>
  # Local<location number>Map = <map number>
  # and then edit 'List =' :
  # List = [Local1Name, Local2Name, Local3Name, etc.]
  # and then edit 'case @cwindow.index'
  # and add:
  # when <location number - 1>
  #  if $game_switches[Local<number>Switch]
  #    $game_map.setup(Local<number>Map)
  #  end
end
class Scene_WorldMap
  def main
    @map = Sprite.new
    @map.bitmap = RPG::Cache.picture(GConfig::Picture)
    @cwindow = Window_Command(192, GConfig::List)
    @cwindow.height = 480
    loop do
      Graphics.update
      Input.update
      update
      break if != self
    end
    @map.dispose
    @cwindow.dispose
  end
  def update
    @map.update
    @cwindow.update
    update_cwindow
  end
  def update_cwindow
    if Input.trigger?(Input::B)
      $scene = Scene_Menu.new
    end
    if Input.trigger?(Input::C)
      case @cwindow.index
      when 0
        if $game_switches[Local1Switch]
          $game_map.setup(Local1Map)
        end
      when 1
        if $game_switches[Local2Switch]
          $game_map.setup(Local2Map)
        end
      end
      $scene = Scene_Map.new
    end
  end
end
 
[/rgss]

That's just what I would do, you might do it differently though.
 
ok, im starting to understand what scripts do by looking at them now which is getting easier by the day messing with this stuff. what that does is make a new scene that pulls up the world map, i see the part that makes the window for the list, input triggers and stuff, this makes sense to me.

but now im wondering, is it possible, to have it so the map has no text except the location you have selected on the list, and as you scroll down the list the text on the map changes to correspond to the location you have selected on the list, or just make a cursor move to the location on the map where the location on the list is located.

for example, in my reference pic, ignore all the text on the map part, and look at how "list a" is selected in the list area, then it would draw the little red arrow where its at, but when you go down to b, c, d etc the arrow moves to the other locations on the map. get what im saying? the map istelf wouldnt have any text on it, its only visual, and as you scroll down the list the cursor on the map moves to where that location is
 

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