General RGSS/RGSS2/RGSS3 Help

Started by G_G, March 04, 2009, 12:14:28 am

Previous topic - Next topic

nathmatt

January 18, 2010, 12:35:33 pm #380 Last Edit: January 23, 2010, 08:41:23 am by nathmatt
redo post: ok i have a question i see how you can windows visible depending on a command windows index
like this @item_window1.visible = (@equip.index == 0) (so now @item_window1 is only visible when @equip.index == 0) can you use this to change @help_window.set_text depending on the command window or do i just need to use the case branch
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Ryex

is
x = Sprite.src_rect.x

the same thing as
x = Sprite.ox


and is
Sprite.src_rect.x = x

the same as
Sprite.ox = x
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

G_G

Having some troubles with this sprite class. Here's the code I have for the update method.
    self.bitmap.clear
    width = self.bitmap.width
    height = self.bitmap.width
    twidth = self.bitmap.text_size(@text).width
    self.bitmap.font.color.set(255, 255, 255)
    self.bitmap.fill_rect(self.x, self.y, width, height, Color.new(0, 0, 0))
    if @over
      color = Color.new(0, 0, 200)
      self.bitmap.fill_rect(self.x+1, self.y+1, width, height, color)
    else
      color = Color.new(255, 255, 255)
      self.bitmap.fill_rect(self.x+1, self.y+1, width, height, color)
    end
    self.bitmap.font.color = Color.new(0, 0, 0)
    self.bitmap.draw_text(0, 16, width, height, @text, 0)

It draws the blue rectangle if @over is true. And a white rectangle if @over is false. It does what its supposed to do. The only problem is it doesn't draw the text. Any ideas?

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

SorceressKyrsty

Quote from: Jackolas on November 21, 2009, 09:38:04 am
out the top of my head
can be wrong tough because I'm no scripter :P

class Window_Battlernames < Window_Base

 def initialize
   super(0, 320, 640, 160)
   self.contents = Bitmap.new(width - 32, height - 32)  
   refresh
 end

 def refresh
   self.contents.clear
   @item_max = $game_party.actors.size
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     actor_y = i * 32 + 4
     draw_actor_name(actor, 0, actor_y)
   end
end



make sure that in "Scene_Battle 1" you add where you call out the windows:
@Name_window = Window_Battlernames.new


and under "# Dispose of windows" add
@Name_window.dispose


and under "# Update windows" add
@Name_window.update



I asked for this code a long time ago but I couldn't get this to work. I got a syntax error, and the game started up when I added another end to the code, but no window showed up.
This is the LAST thing I need to finish the coding for my game. Other than Limit Break but I can't get that to work at all. Oh well.
The sound of a bubble popping.

Trainer Zydragon

Horizontal menus?

How would I go about making one? (I'm getting bored of vertical selectable menus)
And how would I make them images rather than text?
And lastly, how would I change the size of the image selected, so it LOOKS like it zooms in?
And I'm a noob so any help would be appreciated :)

Ryex

take a look at my collapsing cms or asantear battle system both contain a horizontal menu class so you can see how it is done
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Trainer Zydragon

Wow my eyes hurt now >.<
I'll have to have a major sift through the horizontal setup sections and see whats what
Cheers tho :D

G_G

[code]Its not really help I need its just a matter of which one is more efficient?
[code]
loop do
   Graphics.update
   Input.update
   update
   if $scene != self
       break
   end
end

or
while $scene == self
   Graphics.update
   Input.update
   update
end


The 2nd one is shorter and so far it seems to be working the same as the other one.[/code][/code]

Blizzard

I prefer the first way because I can add more abort-loop conditions more nicely. It's pretty much the same in the end.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Trainer Zydragon

Any way to center text within a menu/command window?
Any help would be appreciated :D

G_G

draw_text(x, y, width, height, text, 1)


Example, I'll draw "Hello". It'll center it between the width.
draw_text(0, 32, 320, 32, "Hello", 1)

Trainer Zydragon

And that works in a command menu?
Where would I put it in main? thats IF i put it in main.

nathmatt

you would put it in here like this this

change ur call in main from @command_window = Window_Command.new to
@command_window = Window_Command2.new


#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command2 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands : command text string array
  #--------------------------------------------------------------------------
  def initialize(width, commands)
    # Compute window height from command quantity
    super(0, 0, width, commands.size * 32 + 32)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index],1)
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #     index : item number
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Trainer Zydragon

February 14, 2010, 12:31:22 pm #394 Last Edit: February 14, 2010, 12:32:56 pm by Zydragon
Quote from: nathmatt on February 14, 2010, 12:22:52 pm
you would put it in here like this this

change ur call in main from @command_window = Window_Command.new to
@command_window = Window_Command2.new


#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command2 < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     width    : window width
 #     commands : command text string array
 #--------------------------------------------------------------------------
 def initialize(width, commands)
   # Compute window height from command quantity
   super(0, 0, width, commands.size * 32 + 32)
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, @item_max * 32)
   refresh
   self.index = 0
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   for i in 0...@item_max
     draw_item(i, normal_color)
   end
 end
 #--------------------------------------------------------------------------
 # * Draw Item
 #     index : item number
 #     color : text color
 #--------------------------------------------------------------------------
 def draw_item(index, color)
   self.contents.font.color = color
   rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   self.contents.draw_text(rect, @commands[index],1)
 end
 #--------------------------------------------------------------------------
 # * Disable Item
 #     index : item number
 #--------------------------------------------------------------------------
 def disable_item(index)
   draw_item(index, disabled_color)
 end
end



I actually define my menu window IN main like so:


   s1="Items"
   s2="Skills"
   s3="Equip"
   s4="Status"
   s5="Options"
   s6="Quit"
   s7="Cancel"
   @menu_win=Window_Command.new(120, [s1, s2, s3, s4, s5, s6, s7])
   @menu_win.x=260
   @menu_win.y=60
   @menu_win.height=260
   @menu_win.index=@menu_index


Any way to change it from inside that?



EDIT::
Nevermind, I realise what you did there lol, thanks for the help again :)

G_G

How do we round floats up or down?

I'm aware of the .round method, but if its below .5 it'll round down. If its above 0.5 it'll round up. There are certain times where I want it to just round down, or round up.

winkio

try .floor and .ceiling.  Those should be the terms.

G_G

The ceiling one didn't work but floor did.

Ryex

loot in the rmxp help file at the number classes there is quite a lot of info there.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

G_G

Ah found it. It was .ceil

Also can someone explain what .abs actually does? Maybe give me some examples?