RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[RMXP] Trying to show item in status window for player only.

0 Members and 2 Guests are viewing this topic.

**
Rep: +0/-0Level 63
RMRK Junior
I'm using RMXP 1.02a
What i'm TRYING to do is have the player's race show beneath his sprite when he checks his status in the menu.

Code: [Select]
if $game_variables [1] == 0
          self.contents.draw_text (0, 124, 100, 32, "Human")
 else $game_variables [1] == 1
          self.contents.draw_text (0, 124, 100, 32, "Dwarf")
end

The code I made above shows up. The problem is, it shows the same variable for ALL party members. I attempted to change the code like so:

Code: [Select]
if $actor_id == 1
        if $game_variables [1] == 0
          self.contents.draw_text (0, 124, 100, 32, "Human")
        else $game_variables [1] == 1
          self.contents.draw_text (0, 124, 100, 32, "Dwarf")
        end
else
end

However, now none of it shows! Any help or advice is GREATLY appreciated, as while i'm quite good at Eventing... I suck at scripting.

*
Rep:
Level 82
The second code will likely fail (it will enter 'else')because $actor_id doesn't exist as a variable so it's value is nil by default (any variable yet to be assigned a value assumes the nil value when it is first referenced).

Try changing it to @actor_id instead.

Although, it depends entirely on where this code lives.
« Last Edit: December 03, 2011, 12:34:07 AM by LoganForrests »
(Why do I always feel like it's the end of the world and I'm the last man standing?)

**
Rep: +0/-0Level 63
RMRK Junior
By 'live' I assume you mean where and in which script it is. It's at the very bottom of 'def refresh' in the
Window_Status < Window_Base
class. I tried what you said, and it still didn't work. I'm wondering if it's not working because if @actor_id == 1 wasn't assigned. Basically, like you said, it isn't there for actor_id to find. I guess what I need to do it figure out some way to determine whether actor 1 is currently active... any suggestions?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
@actor.id then.

Code: [Select]
      if @actor.id == 1
        if $game_variables[1] == 0
          self.contents.draw_text (0, 124, 100, 32, "Human")
        else $game_variables[1] == 1
          self.contents.draw_text (0, 124, 100, 32, "Dwarf")
        end
      else
      end

Mind you, a better way to do this would be case branches and simply assigning the text to a variable, then drawing that. Also, it is not good practice to directly modify the default scripts, so it would be better to put it in a new slot and simply use aliasing. But the above should do that for which you are asking.

**
Rep: +0/-0Level 63
RMRK Junior
My issue isn't showing the variable, I can do that easily enough. My problem is showing it for specifically one character when I have others in my party.

Say Bob here is human.  :D

And Joe here is a dwarf. >:(

I want their status to say human for Bob, and dwarf for Joe.

@modern algebra
actor_id would work, except its always nil because its not set to anything else when the player is selected. I'm not really sure how to do this.
Again, any help is greatly appreciated! Thank you!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I didn't say actor_id, I said @actor.id

*
Rep:
Level 82
I probably should have noted I was writing my post blind.

Because I had no idea where this code was being written, it's was impossible for me to know if I was inside the Game_Actor class - in which case @actor_id would work - or somewhere else - in which case I need to access the right property from the right object; where @actor.id is what would work.

Code: [Select]
module LFQF
 
  ACTORRACE = { #Do Not Remove
  #Actor ID => Race of this actor in quotes
    0 => "Human", #default in cases where actor is not specified
   1 => "Human",
    2 => "Fairy",
    3 => "Elf",
    4 => "Dwarf",
  } #Do Not Remove
   
end
 

class Window_Status < Window_Base

  alias :lfqf_refresh_af3k :refresh
  def refresh(*args)
    #run original
    lfqf_refresh_af3k(*args)
    #do extra
    race = LFQF::ACTORRACE[0] #set variable as default race
    if LFQF::ACTORRACE.include?(@actor.id)
      #change race only if actor id is included in LFQF::ACTORRACE
      race = LFQF::ACTORRACE[@actor.id]
    end
    self.contents.draw_text (0, 124, 100, 32, race)
  end
 
end

Just copy/paste this into an empty slot above Main (and below Scene_Debug) where other custom scripts live.

That little bit of code will do the trick, as well as use a default value should an actor not be given a specific race. You may want to change this line:

Code: [Select]

self.contents.draw_text (0, 124, 100, 32, race) #line 27 in the editor

to draw the text in the correct place. You may also want to add a draw_text line to write "Race" as a label too. Do feel free to make those changes, or whatever changes you see fit.

It also gets rid of the need to use $game_variables which I think is part, if not all, of the reasons why you got problems in the first place.

I could have made it less repetitive (not having to set Human more than once) but considering it'll only take a minute to set up for all your actors - unless you have a lot of actors where it might take 5 minutes - I didn't figure it too much of a hassle. It can be done though if preferred.

Also, if there's a possibility of an actor changing their race, I will have to make changes to the code - having race actually part of the actor class would make this easier to do.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

**
Rep: +0/-0Level 63
RMRK Junior
Genius! I tried what you suggested Logan and it worked! Displayed for each character differently, however I do need to change race in the game, hence my earlier approach with a variable.

@modern algebra: My apologies, I must've forgotten the @ symbol  :)

**
Rep: +0/-0Level 63
RMRK Junior
Doe's anyone have any ideas on how to make the race change? Can i simply add a variable (defined before the class) that changes what is displayed? And how would I go about doing so?