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.
[Resolved]How can I add windows in my Battle Scene?

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 86
I've been editing my script recently. I want to know how put two windows in the battle scene. The first is to the right which displays the characters' status, and I've got this solved. The other one is beside the first one which holds the monsters name and the number of monsters. Help me please.
« Last Edit: September 16, 2007, 10:17:32 AM by magusbrother »

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
1. Read the damn Rules, that's Strike 1 for you.
2. Give a meaningful topic title.

http://rmrk.net/index.php/topic,20694.0.html

**
Rep:
Level 88
I'm scared of my grandma. Wouldn't you be?
@Falcon: Are you ever gonna help anyone again or is this gonna become a regular thing?  :tpg:

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
I don't help those who break rules.

*
A Random Custom Title
Rep:
Level 96
wah
He may eat me, but he loves screwing noobs.

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
I don't screw n00bs, I perfer to tell them to go fuck themselves.

AND NOW SHUT UP AND STAY ON TOPIC.

**
Rep: +0/-0Level 86
I'm sorry to break the rules. ;9 I edited my topic and you moved it, I hope there's nothing wrong. I hope I can get  my help soon.

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
Don't worry about it, just do your best to make sure it doesn't happen again :)

I'll see what you would do about the window later, I think I know how it would work.

*
Rep:
Level 98
2010 Best Veteran2014 Best Use of Avatar and Signature Space2014 King of RMRK2014 Favorite Staff Member2014 Best Counsel2014 Best Writer2014 Most Mature Member2014 Best IRC Chatterbox2013 Favorite Staff MemberSecret Santa 2013 ParticipantFor the great victory in the Breakfast War.Secret Santa 2012 Participant2011 Best Counsel2011 Best Writer2010 Funniest Member2010 Best Writer
Don't worry about it, just do your best to make sure it doesn't happen again :)

I'll see what you would do about the window later, I think I know how it would work.

Schizophrenic.
you awoke in a burning paperhouse
from the infinite fields of dreamless sleep

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
No, I just pull the good cop/bad cop routine by myself.

*
Rep:
Level 102
2014 Best Non-RM Creator2014 Biggest Forum Potato2014 Biggest Narcissist Award2013 Best IRC Chatterbox2013 Best Game Creator (Non-RM)Participant - GIAW 112012 Most Successful Troll2012 Funniest Member2012 Best Use Of Avatar and Signature space2012 Best IRC ChatterboxSecret Santa 2012 ParticipantProject of the Month winner for November 2009For being a noted contributor to the RMRK Wiki2010 Most Successful Troll2010 Biggest Forum Couch Potato2010 Best IRC Chatterbox
He may eat me, but he loves screwing noobs.
I wonder why he didn't screw you then. :333

**
Rep: +0/-0Level 86
Please stay on the topic.

Get used to stuff like this happening in your topic, it happens all the time.
« Last Edit: September 11, 2007, 09:49:32 AM by Falcon »

**
Rep: +0/-0Level 86
Does anybody would like to help me?

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
I've been editing my script recently. I want to know how put two windows in the battle scene. The first is to the right which displays the characters' status, and I've got this solved. The other one is beside the first one which holds the monsters name and the number of monsters. Help me please.
The window that displays the character's status and what not is already made for you. If you wish to edit it, look at Window_BattleStatus. The second one is easy enough. All you need to do is pass off @troop_id as an argument to your new window. Below is an example.

Code: [Select]
class Window_MonsterName

  def initialize(troop_id)
    super(x, y, width, height)
    self.contents = Bitmap.new(width - 32, height - 32)
    @troop_id = troop_id
    refresh
  end

  def refresh
    self.contents.clear
    for e in $game_troop[@troop_id].enemies.size
      self.contents.draw_text(x, y*e, width, height, $game_troop[@troop_id].enemies[e].name)
    end
  end
end

That's an example and it is untested but that should point you in the right direction. If the $game_troop methods I called are off, then look around the Game_Troop class to find the right methods to call to make it work.

**
Rep: +0/-0Level 86
I'm sorry; I'm just a novice when it comes to scripting. I don't know what must happen next when I input the script.
« Last Edit: September 15, 2007, 04:09:04 AM by magusbrother »

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
My previous post was more or less a how-to set of instructions. I'm guessing that you're pretty much completely new to scripting. Okies. This post of mine breaks down the way a window works. That should teach you a good bit about windows.

I don't know what must happen next when I input the script.
Quite simple. You want to call a window so what do you do? If you don't know how to make a window appear, then look at the method called "main" inside the Scene scripts. You should see something like these examples.

Code: [Select]
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
Code: [Select]
@gold_window = Window_Gold.new
Code: [Select]
@help_window = Window_Help.new
Code: [Select]
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
Now...what does each of those examples have in common? The window being called is stored within a public variable aka @variable that can used through out the entire class. Another key thing they have in common is that all windows being stored in a variable has the .new method being called. This tells RGSS that you want to make a new window.

If you're still unclear on how to do something involving windows, you know where to find me.  :blizj:

**
Rep: +0/-0Level 86
I'm getting an error in @monster_name = Window_MonsterName.new. I might have missed something or I got it wrong. It says that it has wrong number argument.
    # Make other windows
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    @monster_name = Window_MonsterName.new
« Last Edit: September 15, 2007, 12:31:09 PM by magusbrother »

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Now I'll get to go a little more indepth with windows. Look at the first and last examples in my last post. Those two have something AFTER the .new syntax. These are called "arguments". An argument is basically information passed on. In this case, you will want to pass on the argument @troop_id. Why are we using @troop_id? Scene_Battle stores the monsters you are going to fight inside @troop_id and you're wanting to have a window list the monster names so it makes sense that you'd pass off the information of the monsters you're fighting as an argument to the window.

This is a window being called with a single argument.
Code: [Select]
@window_status = Window_Status.new(actor.id)

This is a window being called with two arguments.
Code: [Select]
@window_status = Window_Status.new(actor.id, @window_command.index)

If you're going to pass off an argument in the calling of a window, scene, or class method then you'll also need to have the same number of arguments. I'll use Window_MonsterName as an example. Lets look at the initialize method of WIndow_MonsterName.

Code: [Select]
def initialize(troop_id)
Hmmm...I see an argument called troop_id. Remember that error you posted about? Well that's what happens when you supply the wrong number of arguments when you call something regardless of it being a window, scene, OR class method. In this case, you tried calling a window that has an argument in the initialize method without supplying something as that argument when you called the window.

Code: [Select]
@monster_name = Window_MonsterName.new(@troop_id)
This is what you should have used when you tried calling Window_MonsterName. We now have an argument supplied to the window when it's called.

**
Rep: +0/-0Level 86
I've got the rest resolved. I changed something in the script you gave me. I'm still getting errors.
  def refresh
    self.contents.clear
    for e in $data_troops[@troop_id].members.size
      self.contents.draw_text(x, y * e, width, height, $game_troop[@troop_id].enemies.name)
    end
  end
end

(for e in $data_troops[@troop_id].members.size) I'm getting an error in this line. It says that undefined method 'each' for 3:FixNum

I'm sorry; I'm asking to much... ;9

*
Rep:
Level 87
You made some errors in your modifications.


Code: [Select]
class Window_MonsterName

  def initialize(troop_id)
    super(x, y, width, height)
    self.contents = Bitmap.new(width - 32, height - 32)
    @troop_id = troop_id
    refresh
  end

  def refresh
    self.contents.clear
    for e in $game_troop[@troop_id].enemies.size
      self.contents.draw_text(x, y*e, width, height, $game_troop[@troop_id].enemies[e].name)
    end
  end
end


You could try
Code: [Select]
for e in $game_troop.enemies.size
  self.contents.draw_text(x, y*e, width, height, $game_troop.enemies[e].name)
end
and see if it makes a difference.
« Last Edit: September 16, 2007, 04:06:36 AM by shaz »
Always remember you're unique.
Just like everybody else.

**
Rep: +0/-0Level 86
It doesn't make any difference. There is something wrong in the line I posted.

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
EDIT:This is a LONG post.

LOL You can NEVER ask me too many questions. I learned scripting by jumping in feet first while asking questions when I didn't understand something. I tried to recreate the error and did. I think it's time we take a look at the class Arrow_Enemy. I'm sure you're baffled by this. I'm going to look at Arrow_Enemy because it is what passes off the enemy's information so that the help window can display an enemy's name in battle when you're trying to select which enemy you want to attack. This is what I do when my initial attempts at something fails. I look at the other scripts that do something similar to what I want to do and see what they did to make it work.

This is the line we want to pay attention to in Arrow_Enemy.
Code: [Select]
  def enemy
    return $game_troop.enemies[@index]
  end
Hrmmm...$game_troop.enemies? It's returning the method enemies in Game_Troop while using the index of the arrow to point to the right enemy but that's not important at this time. What matters is we now have an idea on what method to use but how do we use it? We don't know the contents of $game_troop.enemies so here's what we'll do. We'll output it using a built in RGSS function called p. What does p do? It prints just about anything you could tell it to print! Even class methods like $game_troop.enemies. We'll just change our Window_MonsterName a slight bit and use it to output $game_troop.enemies.

Spoiler for Window_MonsterName:
Code: [Select]
class Window_MonsterName < Window_Base

  def initialize(troop_id)
    super(0, 0, 100, 100)
    self.contents = Bitmap.new(width - 32, height - 32)
    @troop_id = troop_id
    p $game_troop.enemies[0]
    #refresh
    # The # denotes the start of a comment. Comments are not used by RGSS to run scripts.
    #Comments are useful for leaving behind notes on what something does.
    #A good programmer will note out everything so that even a retarded monkey
    #can understand what the programmer did.
  end
 
  def refresh
    self.contents.clear
    for e in 0...$data_troops[@troop_id].members.size
      self.contents.draw_text(0, 20 * e, 100, 32, $game_troop[@troop_id].enemies[e].name)
    end
  end
end
As you can see, I used a comment # to keep RGSS from running the refresh method. Now we can get our output data without the game crashing on us immediately after. Run the above window over yours and lets look at the output.

Errr...what the hell?

Just kidding! It's common to see an output like that. I can tell you what almost everything is. #<Game_Enemy is the class name that the information you're looking at came from. The information you are look at are class METHODS that we can call through $game_troop.enemies. This means we could use $game_troop.enemies[0].enemy_id to return the first enemy's ID number in the database. Catching on to what I have in mind yet? Heh heh...

Now that we know what methods are stored inside $game_troop.enemies, we have a new idea on how to do what we want to do. We can try using the methods to solve our problem.

Spoiler for The solution is here if you want it.:
Here is what I tried with $game_troop.enemies.
Code: [Select]
class Window_MonsterName < Window_Base

  def initialize(troop_id)
    super(0, 0, 100, 100)
    self.contents = Bitmap.new(width - 32, height - 32)
    @troop_id = troop_id
    #p $game_troop.enemies[0]
    refresh
  end
 
  def refresh
    self.contents.clear
    for e in 0..$data_troops[@troop_id].members.size
      id = $game_troop.enemies[e].id
      self.contents.draw_text(0, 20 * e, 100, 32, $game_enemies[id].name)
    end
  end
end
Now to explain my attempts.

Code: [Select]
id = $game_troop.enemies[e].enemy_id
I stored the enemy's ID number in the local variable id.

I got this error when I tried running the game in a battle.
Code: [Select]
undefined method "enemy_id" for <#Game_Enemy:

I'm sure you're a little puzzled now. "We saw it listed in the method output we did! It has to work! Grrr...this makes no sense?!" Am I right? Well, since my initial attempt failed I'm going to look at the Game_Enemy class methods to see if there is a method that'll return the enemy's ID and if there isn't one, then I'm boned.

Code: [Select]
  def id
    return @enemy_id
  end
Hey~ what's this little beauty? Strange...it's returning @enemy_id? Isn't that the method name I tried to use for the enemy ID in the window? Yes it is. Public variables can also be used in a way similar to class methods when you use  attr_accessor but that's another lesson for another time. Needless to say, @enemy_id doesn't work like that or else I wouldn't have gotten an error. Lets try using $game_troop.enemies[e].id and see if it works.

Code: [Select]
class Window_MonsterName < Window_Base

  def initialize(troop_id)
    super(0, 0, 100, 100)
    self.contents = Bitmap.new(width - 32, height - 32)
    @troop_id = troop_id
    #p $game_troop.enemies[0]
    refresh
  end
 
  def refresh
    self.contents.clear
    for e in 0..$data_troops[@troop_id].members.size-1
      id = $game_troop.enemies[e].id
      self.contents.draw_text(0, 20 * e, 100, 32, $game_enemies[id].name)
    end
  end
end
There. Now lets try it...error...*mimics a famous comedian* Dont. You. Crash. On. Me. You...BASTARD! Programming takes a LOT of patience. I don't know about the godly scripters like Blizzard, Near Fantastica, and SephirothSpawn but I rarely get things right the first time so yea, programming teaches you a little bit about patience. Anywho, back to our error that we got.

Code: [Select]
undefined method for nil:NilClass
Okies...something isn't right. Lets output the local variable id and comment our self.contents.draw_text method. Well, the variable outputed the monster's id so we know that's not to blame. I'll try using $data_enemies instead. When a $game_variable fails, the $data_variable usually works.

Code: [Select]
class Window_MonsterName < Window_Base

  def initialize(troop_id)
    super(0, 0, 100, 100)
    self.contents = Bitmap.new(width - 32, height - 32)
    @troop_id = troop_id
    refresh
  end
 
  def refresh
    self.contents.clear
    for e in 0..$data_troops[@troop_id].members.size-1
      id = $game_troop.enemies[e].id
      self.contents.draw_text(0, 20 * e, 100, 32, $data_enemies[id].name)
    end
  end
end
It worked! YEY! ^-^ Perseverance(sp?) and patience pays off.
« Last Edit: September 16, 2007, 05:46:39 AM by Shinami »

**
Rep: +0/-0Level 86
Thank you for the help and the lessons I learned. I will try to improve myself in scripting.

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Always a pleasure. Never a chore. Also, don't try. Just do it.  :blizj:

*
A Random Custom Title
Rep:
Level 96
wah
Wow, super good post and it doesn't teach just how to add windows in the Battle Scene. XD :P

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Thank you moo! Rather than just give the answer away, I like to teach new scripters a little about what they want to do and THEN give them their answer.