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.

I need to use actor_id as a variable in the menus

Hi,
I need to use actor_id as a variable in the status menu. I've been trying for hours in the past and I could figure out what to do but I really need it. (I'm basically trying to make a conditional inside the window, so it would select something different according to the actor's number.)
If I try to use the variable @actor, it either crashes or doesn't function, depending on how I made the code.

I'd also like to know with what script do you display pictures with RGSS.

Someone, please help.
 

khmp

Sponsor

Alright getting the ids of the active party members.

Code:
$data_system.party_members

That is the array holding the current party's ids.

Second displaying a picture. RPG::Sprite or the Sprite classes are the interfaces for loading, moving and displaying an image.

Code:
@sp_face = Sprite.new
@sp_face.bitmap = RPG::Cache.picture(NAME_OF_FILE_IN_PICTURE_FOLDER)

The difference between RPG::Sprite & Sprite is that RPG::Sprite has some additional functionality built in. Check the RMXPs readme for clarification of it.

If you are trying to include a face picture with your message window. I'd recommend that you look into ccoa's UMS(Universal Message Script) rather than reinvent the wheel. Then you could use the message code:

Code:
\face[name] - changes the face graphic to name.png (leave empty [] for no face)
 
Now let's see...

The actor.id was indeed what I needed... I couldn't use the array $data_system.party_members in the status window because I had no index(although it's good to know, it will come in handy later).

However, it appears that the sprite thing doesn't work where I want it. If I use the code you gave me in an event, the sprite will appear as it should. If, however, I try to use it inside the scripts -specifically, in the window_status- nothing appears.

Also, to answer your question, I'm not trying to do the faces thing. I'm actually trying to put the alignment bar from knights of the old republic inside the status menu. Also, the reason I was asking about displaying variables and selecting actor ids was because I added "alignment modifiers" to the character status :) What do you think of the idea, really?


CORRECTION: Actually, the sprite does appear UNDER the menu... but again, what do I do?
 

khmp

Sponsor

Well if you're trying to find out who's in the party and develop options based off of it that's your guy. Some quick code to do what I think you are trying to do is:

Code:
def get_options
  a_options = []
  for i in $data_systems.party_members
    # The string that will hold the command choice
    sz_option
    # Decide based on actor id what command choice to add.
    case i
      when 0
        sz_option = 'Party leader option'
      when 1
        sz_option = 'Second member option'
      else
        sz_option = 'Whatever else!'
    end
    # Continue if the option is already there. Remove if want duplicates.
    next if a_options.include?(str_option)
    # Append the choice into the options array.
    a_options << str_option
  end
  # Return the unique choices.
  return a_options
end

The reason a sprite might not show are the following:
1. The image was never loaded properly.
2. The coordinates for where its drawing are offscreen.
3. The viewport is not valid.
4. You are drawing the sprite behind something.

The third is only a problem if you defined a viewport for the sprite. The last one you can correct by giving it a large z value. If your custom sprite was created before the main background sprite the later sprite will have drawing precedence. Hope that helps grecias! :thumb:

You edited and the answer would be:
Code:
@sp_greciassprite.z = 2
 
The z value did the trick. Thanks again!
But... I've got a new problem... I wanted to put it in the menu, and the sprite will not dissapear for a while after I've closed of the status menu...

Btw, I got confused about the first part of your message. (To clear this up first, actor.id did my job.) If I got this right Does that code opens up a command choice for each party member? I did not ask for this... but, again, it will definitely be an asset in the future.

Also, I came up with another problem due to customizing fonts and the text is hidden behind the window edge. I don't want to be more trouble, but could you tell me how to resize the text window(I hope I'm becoming a pest...)
 

khmp

Sponsor

grecias;311875 said:
The z value did the trick. Thanks again!

Btw, I got confused about the first part of your message. (To clear this up first, actor.id did my job.) If I got this right Does that code opens up a command choice for each party member? I did not ask for this... but, again, it will definitely be an asset in the future.

Also, I came up with another problem due to customizing fonts and the text is hidden behind the window edge. I don't want to be more trouble, but could you tell me how to resize the text window(I hope I'm becoming a pest...)

(To clear this up first, actor.id did my job.)
Alright so you have solved it?

Hmm I don't know how to resolve that font problem though... Resizing the window will not fix your problem. You could try changing the size of the font:

Code:
Font.default_size = something_less_than_22

And that line could be placed right below begin in Main. If that doesn't work you'll need the help of someone much wiser than I. Sorry I couldn't be of more help.
 
That problem was because I also resized the fonts, that's why I wanted to resize the window, but it doesn't really matter... I guess I'll eventually give up the aesthetics in the name of functionality.

My problem is that the sprite doesn't dispose, I guess I edited that after you read the message, sorry.

EDIT: If I use it as a bitmap and make a definition at window_base, everything is all right! The only drawback is that I can't stretch the picture. No need to bother anymore, I'm all right. Once again, thanks.
 

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