Joined
Aug 12, 2012
Messages
164
Reaction score
80
First Language
English
Primarily Uses
Ah, I see. Up until I've been assuming that you know what the script you've copied and modified was doing.


You'll need to show me the entire script you've been working on in order for me to be able to answer why only 3 Actors are drawing.
 

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
Below is my script. Thank for helping.

Code:
module Config#==============# Change menu command titleMenu_Title = "Partnership"end#========================================================================class My_Custom_Class < Window_MenuStatus  def initialize      super(0, 0)    end     def draw_item(index)    actor = $game_actors[index]    return if actor.nil?    rect = item_rect(index)    draw_item_background(index)    draw_actor_face(actor, rect.x + 1, rect.y + 1)    draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)  endendclass Scene_Partnership < Scene_Base      #--------------------------------------------------------------------------  # * Start Processing  #--------------------------------------------------------------------------  def initialize    super    @my_class = My_Custom_Class.new()    @my_class.activate()    @my_class.set_handler(:cancel,   method(:return_scene))    end      #--------------------------------------------------------------------------  # * Frame Update  #--------------------------------------------------------------------------  def update   super    return_scene if Input.trigger?(:UP)  end    #--------------------------------------------------------------------------  # * Termination Processing  #--------------------------------------------------------------------------  def terminate   super   @my_scene.dispose()  end end###########################################class Scene_Menu < Scene_MenuBase   #--------------------------------------------------------------------------  # * Create Command Window  #--------------------------------------------------------------------------  alias scenemenu_createcommandwindow  create_command_window  def create_command_window    scenemenu_createcommandwindow()    @command_window.set_handler(:partnership,      method(:partnership))  end    def partnership()      SceneManager.call(Scene_Partnership)    endend######################################class Window_MenuCommand < Window_Command    include Config  #--------------------------------------------------------------------------  # * For Adding Original Commands  #--------------------------------------------------------------------------    def add_original_commands    add_command(Menu_Title,   :partnership)  endend#############################################
 
Joined
Aug 12, 2012
Messages
164
Reaction score
80
First Language
English
Primarily Uses
Whatever happened to you using the compact method?

The script works fine (as far as DRAWING) as is, you just need to either use compact on $game_actors, or add +1 to the actor index

def draw_item(index) actor = $game_actors[index+1] return if actor.nil? rect = item_rect(index) draw_item_background(index) draw_actor_face(actor, rect.x + 1, rect.y + 1) draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2) end
or

Code:
module Config#==============# Change menu command titleMenu_Title = "Partnership"end#========================================================================class My_Custom_Class < Window_MenuStatus  def initialize      super(0, 0)    end   def draw_item(index)    actor = $game_actors.compact[index]    return if actor.nil?    rect = item_rect(index)    draw_item_background(index)    draw_actor_face(actor, rect.x + 1, rect.y + 1)    draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)  endendclass Scene_Partnership < Scene_Base      #--------------------------------------------------------------------------  # * Start Processing  #--------------------------------------------------------------------------  def initialize    super    @my_class = My_Custom_Class.new()    @my_class.activate()    @my_class.set_handler(:cancel,   method(:return_scene))    end      #--------------------------------------------------------------------------  # * Frame Update  #--------------------------------------------------------------------------  def update   super    return_scene if Input.trigger?(:UP)  end    #--------------------------------------------------------------------------  # * Termination Processing  #--------------------------------------------------------------------------  def terminate   super   @my_class.dispose()  end end###########################################class Scene_Menu < Scene_MenuBase   #--------------------------------------------------------------------------  # * Create Command Window  #--------------------------------------------------------------------------  alias scenemenu_createcommandwindow  create_command_window  def create_command_window    scenemenu_createcommandwindow()    @command_window.set_handler(:partnership,      method(:partnership))  end    def partnership()      SceneManager.call(Scene_Partnership)    endend######################################class Window_MenuCommand < Window_Command    include Config  #--------------------------------------------------------------------------  # * For Adding Original Commands  #--------------------------------------------------------------------------    def add_original_commands    add_command(Menu_Title,   :partnership)  endend#############################################class Game_Actors  def compact    @data.compact  endend
 
Last edited by a moderator:

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
actor = $game_actors[index+1]
That is really nice trick. Simple and effective. It is weird that my custom scene only display max 3 actors instead of all actors in database. When It set actor = $game_actors[2] , it display 1st actor repeat 3 times. There must be a loop somewhere?
 
Joined
Aug 12, 2012
Messages
164
Reaction score
80
First Language
English
Primarily Uses
The keyword in that method is 'index'. This VARIABLE is giving you a number.

When you change the accessibility of your actors to just a constant number (which is what you did when you used 'actor = $game_actors[2]') it will repeatedly give you the same actor.

You want to keep using that index variable.

The loop starts in the inherited Window_Selectable class with this code here:

#--------------------------------------------------------------------------# * Draw All Items#--------------------------------------------------------------------------def draw_all_items item_max.times {|i| draw_item(i) }endThat code pretty much goes through a loop a certain amount of times.The item_max designation in this code is in fact a method.

The item_max method is redefined in Window_MenuStatus (the class you've copied/inherited from) with:

#--------------------------------------------------------------------------# * Get Number of Items#--------------------------------------------------------------------------def item_max $game_party.members.sizeendSo if you want all your database actors to be draw, inside your 'My_Custom_Class' which is inheriting from Window_MenuStatus, simply add the following as a method:

Code:
#--------------------------------------------------------------------------# * Get Number of Items#--------------------------------------------------------------------------def item_max  $data_actors.sizeend
 
Last edited by a moderator:

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
Ok I think I am lost from here. I still can't catch the idea how methods and classes talk to each other. 

def draw_item(index) actor = $game_actors[index+1] return if actor.nil? rect = item_rect(index) draw_item_background(index) draw_actor_face(actor, rect.x + 1, rect.y + 1) draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)endThe def draw_item above, not only have methods inside talk to one another, also talk to other methods outside of either in the same class or inherited class. For example the loop you posted. 

def draw_all_items item_max.times {|i| draw_item(i) }endI dont understand how It was able to to talk to the draw_item method? the index variable in draw_item method where the value it takes from?

=============================================================

Another example is item_rect method. It is like selected a few methods of the Rect class for calculation then return the value to index?

def item_rect(index)    rect = Rect.new    rect.width = item_width    rect.height = item_height    rect.x = index % col_max * (item_width + spacing)    rect.y = index / col_max * item_height    rect  endCan you write a tutorial (not demo) to explain things and possibly draw a diagram of one method relate to another. Because as I understand it seems these methods and classes passing the value back and forth. It is like there is a flow pattern which I still dont catch the source and destination.

Thank for helping btw.
 
Last edited by a moderator:

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
I see a clearer picture now. The draw_item method that the draw_all_item loop use I dont quiet get it yet. There are more than 3 draw_item methods, one below the loop and one somewhere in Window_Selectable class, and another one define in custom class. Are there priority for each one that the loop must use?

Another problem which It was confused but now I get it, it was  the syntax that I got me confused,  because Ruby syntax often omit the "return" that why I thought the method was called instead of return the value.

Thank for the video.
 
Joined
Aug 12, 2012
Messages
164
Reaction score
80
First Language
English
Primarily Uses
The priority is simply the lowest one in the hierarchy it can use.

In this case the most recent class would be the lowest in that hierarchy.
IE:

Window # Draw Item does not Exist ^ Window_Base # Draw Item does not Exist ^Window_Selectable # Draw Item is Defined ^Window_MenuStatus # Draw Item is Redefined ^My_Custom_Class # Draw Item is Redefined once againSo as you can see, My_Custom_Class is the lowest class in that hierarchy and since it has 'draw_item' defined, THAT is the one that will be used.
If you did not have draw_item defined in 'My_Custom_Class', instead the draw_item method in Window_MenuStatus would be used (as it's now the lowest one in the hierarchy).
 

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
Ok It's alot clearer for me now. One more thing, I still has not understood yet, is after all the calculations and and value passing where the standard output? Take example of your method int, the output is msg_box to out put the final value on screen. Where is the out of everything such as the actor face, the gauge, name...etc. what methods to do the output?

Also, do you think you can make a tutorial about the wrapper and parameters, a little bit more in depth? How they handle values? For basic one two parameters in a method I can follow but when a methods with increase of methods and number of parameters it tends to get lost.

this method for example

def initialize(x, y) super(x, y, window_width, window_height) @pending_index = -1 refresh endthe initialize method takes two parameters, but the super method take 4 parameters, just example. If you can make a tutorial which explain the wrapper and parameters little more in depth when there's  involvement of more than 4-5 methods and each method take different number of parameters, how they work together as one block of code?. In your tutorials although you explained about the method but your method is very simple take one or two parameters and the method tends to has only 1 or 2 methods in side it. which when I look at the actual script I tends to get lost.

The script I tried to run it I got the error, "face_name" Nil. I think it has the same problem like $game_actors index where 0 in the array dont count? But has you already used the compact method to grab non-empty array and when it pass the value it should pass the non-empty value? Just my guess.
 
Last edited by a moderator:

vindaca

CEO of Tales of the Valiant
Veteran
Joined
Dec 11, 2012
Messages
534
Reaction score
77
First Language
English
Primarily Uses
Just for your example if you wanted to pass more variables into a class, (which I would try to keep to a minimum.)  all you have to do is extend the list inside the brackets.
then set whatever value the method is passed to a variable to use it or you can even pass those values directly to another method if it is being called by that method. (Like the "super" method inside of the method below.
 
The widow_width and window_height below in green are methods that are handled by the inherited class. So to better explain you can also pass methods into method as long as they return a value. As both of those do (or should. Also if you redefine a method inside of your class, it will pass the new method.)

def initialize(x, y, actor_name, actor_face, yada, di, da) super(x, y, window_width, window_height)  @actor_face = actor_face  @actor_name = actor_name  @pending_index = -1 example_method(@actor_face, @actor_name, yada, di, da, refresh)end
Code:
def draw_item(index)  actor = $game_actors[index+1]  p actor  return if actor.nil?  rect = item_rect(index)  draw_item_background(index)  draw_actor_face(actor, rect.x + 1, rect.y + 1)  draw_actor_simple_status(actor, rect.x + 108, rect.y + line_height / 2)end
 
I am not sure if you are still using this but you shouldn't need to use +1 anymore with compact. You should print your actors to make sure that they are indeed the actors too and make sure they are the right ones. That might be a couple reasons for your '"face_name" Nil.' error.
 
Last edited by a moderator:

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
For method contain one of two methods I have no problem to follow up. The script I am working on right now somewhat more than the scope of my understanding (this I considered  as learn the advance from practice). As you can see when you create the class it will initialize that class then It also initialize the super class which is Window_MenuStatus, the Window_MenuStatus initialized its super class the Window_Selectable. The Window_Menus status called the Refresh method which it is inherited from Window_Selectable. In the Refresh method it called Draw_All_Item. This method then excuse block of array involve Draw_Item. This Draw_Item then called several methods Rect, Draw_Actor_Fac....etc., and involve an array. As you can see it is not just a few methods within a class involve but it draws many methods from other classes that it inherit from. That's why I got lost for such complex method. Thank to DiamonPlanium's video I have better understanding but I just want to see some more demonstration tutorials which explain in depth.

The "face_name" Nil I mentioned above which I just looked at the code it is not because the compact method dont work but it seems the compact method can only grab the actor array but not the face_name array. Right now, I tested to see if it is nil at index [0], the first 3 actors  face are shown but after that all nil, also actors name and actor's gauge
 
Last edited by a moderator:
Joined
Aug 12, 2012
Messages
164
Reaction score
80
First Language
English
Primarily Uses
That would be because your other Actors aren't initialised.

At the beginning of your game/project; Add all Game_Actors to the party (check Initialize box on all of them).

Then remove all unwanted Actors. Your scene should be working.
 

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
Is there a way to pull the actors from database without having to initialize?
 
Joined
Aug 12, 2012
Messages
164
Reaction score
80
First Language
English
Primarily Uses
You're gonna have to initialize.

But that doesn't mean you have to do it the boring conventional way.

Add this:

class Game_Party  def init_all_actors    for i in 1..($data_actors.size-1)      $game_actors.setup(i)    end  endendNow in a script call:

Code:
$game_party.init_all_actors
 
Last edited by a moderator:

mrthree

Villager
Member
Joined
May 20, 2012
Messages
7
Reaction score
0
First Language
indonesian
Primarily Uses
please make tutorial scripting ,how to make my own battle system.,like pokemon series
 
Joined
Sep 9, 2014
Messages
1
Reaction score
0
First Language
English
Primarily Uses
Hello! First I wanted to say that i've been trying to learn/understand how to write rgss3 for a long time!

The videos you've made are extremely basic (which is what's great!) and have helped me to understand

what's actually happening in the scripts! I've never wrote a script before so I'm very noob about it still...

but your vids give me some hope! :D

I've made several games with vx ace already without any problem.. but this time around I'm attempting to write some

very simple scripts myself..instead of just importing other peoples scripts.

My Problem Is:

Whenever i follow along with with your vids everything works perfect.. but whenever I attempt to do my own thing

I get errors that crash my game! :/

I'm making a game that... well, I guess I'll skip the details lol... in one part of my game the player will be able to grow plants.

Planting the seeds, watering them & so on.

+++++++++++++++++++++++++++ Problem 1
 

I'm using "Galv's Event Spawn Timer" script to set a timer for the growing times...

so i set a variable in my script to hold the amount of time that "Galv's" timer will use...

In one event, i got it to work, but the variable i set always = 0 (even though i set it to 5 "seconds" at the moment in my script)..

So i guess I'm not understanding how to use variables properly! ??

I understand if you don't want to help with this one particularly because it's using someone elses script and you'd

probably have to study their script.

+++++++++++++++++++++++++++ Problem 2

And before you can water the plant you must refill the watering can... I'm attempting to use a script in a conditional branch to

check if the amount of water in the can ($game_variables[87]) is < the total that it can hold (which i set as a variable in my script).

I've attempted this "many" different ways.. but this last time I tried to use a class (the Game_Interpreter class) because in one of

your vids you said in order to use a script call you must use that class.. so anyways can you possibly help me to get this working??

PLEASE!!!

          THE SCRIPT:

class Game_Interpreter
  plant_growthtimer = 10   # The "Wait Time" while growing plants
  wateringcan_total = 3       # The total amount of water that can be stored

  def iswatercanfull()
    return $game_variables[87] < wateringcan_total
  end
end

          THE CONDITIONAL BRANCH:

@>Conditional Branch: Script: iswateringcanfull() == true

     #Show message "true" here.

:Else

     #Show message "false" here.

: Branch End
 
Last edited by a moderator:

BVT

LionStar Lead Dev
Member
Joined
Sep 7, 2014
Messages
28
Reaction score
3
First Language
English
Primarily Uses
I'm going to try and learn scripting through this. Thank you for making these.

If'n you don't mind me asking, what accent/dialect is that?
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,982
Reaction score
3,119
First Language
French
Primarily Uses
RMMV
please make tutorial scripting ,how to make my own battle system.,like pokemon series
Ho my mrthree-san did you know much is hard to make a battle system???

is not for beginner script maker battle system are the worst and the most hard thing's to do in rgss this will not require one tutorial but like 10 or 20 tutorial just for having a sub-fonctionnal battle system and most of battle system are not under 3000 lines 

I advise you to pratice before enter in battle system
 

aldwin7894

Fnatic.LoL
Member
Joined
Sep 28, 2014
Messages
4
Reaction score
0
First Language
Filipino
Primarily Uses
Hi, I just want to say that your tutorials are awesome! And I am watching them until now.
But I'm a bit confused on RGSS.. lol

I know some of C# and java but ruby is different. Can you give me tips or suggestions so that I can understand it better? Tyvm.
 

Latest Threads

Latest Posts

Latest Profile Posts

Hello! Can anyone help me? I followed making cooking tutorial for RPG Maker MV. But for some reason buff state that food gives doesn't work in overworld. It disappears. What am I supposed to do?
A shotgun is not a rifle. Huh.
SIGH its so hard to convince my friend that making a game for fun and making one to sell takes different planning. I don't care about weird bothersome ways of doing things in a game made for fun, but when you are planning to market it, there is some stuff that you just have to streamline or cut out.
It might be a little bit boring and tedious, but building that database of armor, items, weapons and skills are super important.

Forum statistics

Threads
124,399
Messages
1,163,337
Members
163,195
Latest member
new88betscom
Top