Ruby/RGSSx questions that don't deserve their own thread

FamilyGamer7

Villager
Member
Joined
Jan 4, 2021
Messages
29
Reaction score
2
First Language
English
Primarily Uses
RMVXA
To get the value of an array starting from the last index, you use -1 and so on
For example,
Code:
array = [2, 1, 3, 5, 6, 7, 0, 8, 9, 10, 11]
array[-1] # 11
array[-2] # 10
array[-3] # 9
array[-4] # 8
array[-5] # 0

Okay, I understand that. Now, how would you filter that through an array to only show the specified equip slots in the draw_item(index) on the Window_EquipSlot?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,048
Reaction score
7,135
First Language
Indonesian
Primarily Uses
RMVXA
Okay, I understand that. Now, how would you filter that through an array to only show the specified equip slots in the draw_item(index) on the Window_EquipSlot?
At this point, your question deserves this own thread as it is no longer asking for logic/syntax but modifying a window class. And this may end up explaining the class which may be helpful for others if you create your own thread because it gains less attention here.

Yes, I do have the answer but I don't have time to maybe write a thoughtful answer for now.
 

FamilyGamer7

Villager
Member
Joined
Jan 4, 2021
Messages
29
Reaction score
2
First Language
English
Primarily Uses
RMVXA
At this point, your question deserves this own thread as it is no longer asking for logic/syntax but modifying a window class. And this may end up explaining the class which may be helpful for others if you create your own thread because it gains less attention here.

Yes, I do have the answer but I don't have time to maybe write a thoughtful answer for now.

I would have to respectfully disagree. I am requesting for logic/syntax, even though it might pertain to modifying a class. I am not necessarily asking for someone to provide the solution for me (unless you want too). But, I would agree with the aspect of making it more visible for others to benefit from.

For the "I do have the answer"... comes off as rude (like teasing).. even though I think it's just the way you wrote it. Honestly you would of been better off excluding that as I can happily accept no assistance at this time. But I do appreciate the initial response assistance.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,048
Reaction score
7,135
First Language
Indonesian
Primarily Uses
RMVXA
I would have to respectfully disagree.
Whether you disagree or not, there is nothing harmful about making a new thread. Are you afraid of the mods scolding you and put back your post here?

For the "I do have the answer"... comes off as rude (like teasing)
Fine, I will tease you more...
Go overwrite draw_all_items...

Edit:
I can happily accept no assistance at this time.
I have assisted you with the logic about -1, so I can say you're as rude as not acknowledging that.
you're asking for a direct answer on how to modify the method. I'm willing to answer that, I don't mind, but later (because I don't have time to look at RM yet), while at it, why not create a new thread? I don't want to come as "you are not helping because you're arguing with me".
 
Last edited:

FamilyGamer7

Villager
Member
Joined
Jan 4, 2021
Messages
29
Reaction score
2
First Language
English
Primarily Uses
RMVXA
Whether you disagree or not, there is nothing harmful about making a new thread. Are you afraid of the mods scolding you and put back your post here?


Fine, I will tease you more...
Go overwrite draw_all_items...

Edit:

I have assisted you with the logic about -1, so I can say you're as rude as not acknowledging that.
you're asking for a direct answer on how to modify the method. I'm willing to answer that, I don't mind, but later (because I don't have time to look at RM yet), while at it, why not create a new thread? I don't want to come as "you are not helping because you're arguing with me".

It has nothing to do with mods putting my post were they think it belongs. I have stated why I think my post was valid here, but I did agree with the visibility aspect.

I would agree that it would of been rude for me to not acknowledge your response on grabbing a value from an array, but if you take a look above.. I very clearly stated that I understood and requested if you could fill the gap with the "filter" aspect. It was never about a direct answer needed. I was very happy with an example if provided.

Now I do appreciate the willingness to help. But, I think I have already demonstrated above in my recent post(s) that I am not asking for direct answers, but more guidance on the areas that I lack knowledge.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,048
Reaction score
7,135
First Language
Indonesian
Primarily Uses
RMVXA
All right, first of all... let's breakdown your question. First, you want to draw 4 items. I don't know how is your window looks like and how did you modify the code, but ... if you put this in your window
Code:
def draw_all_Items
  4.times {|i| draw_item(i)}
end
It will draw only 4 items. Since you need only 4 items to draw, that should do.

Now with the example, I gave above (about -1), you could turn the argument "i" to negative, which means
Code:
def draw_item(index)
  i = (index+1) * -1
  ...
end
This will convert an iteration of 0,1,2,3 from the "times" function to -1,-2,-3,-4
Use this to get your equip slot.

However,
a method "item_rect" does not work well with negative "i", so you gonna need to keep the non-negative of it so that the item is drawn in the correct spot.

This is the best direction I could give you without looking at the RM code to see the whole context of the code.
 

FamilyGamer7

Villager
Member
Joined
Jan 4, 2021
Messages
29
Reaction score
2
First Language
English
Primarily Uses
RMVXA
All right, first of all... let's breakdown your question. First, you want to draw 4 items. I don't know how is your window looks like and how did you modify the code, but ... if you put this in your window
Code:
def draw_all_Items
  4.times {|i| draw_item(i)}
end
It will draw only 4 items. Since you need only 4 items to draw, that should do.

Now with the example, I gave above (about -1), you could turn the argument "i" to negative, which means
Code:
def draw_item(index)
  i = (index+1) * -1
  ...
end
This will convert an iteration of 0,1,2,3 from the "times" function to -1,-2,-3,-4
Use this to get your equip slot.

However,
a method "item_rect" does not work well with negative "i", so you gonna need to keep the non-negative of it so that the item is drawn in the correct spot.

This is the best direction I could give you without looking at the RM code to see the whole context of the code.

The RM code in question was literally just the "Window_EquipSlot". Nothing was changed within the default RM script on functionality.

But... I believe at this point, my question now deserves its own thread. I appreciate the response in a direction, but I have given a try and even looked up some ruby code on how to filter this and no luck. What you have provided and what I have tried does technically get me half way, but when I go to select the slot that looks correct, the item selection does not correspond to the specific slot.

I thought maybe this was due to my project, but I tried on a blank project and got the same result.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,048
Reaction score
7,135
First Language
Indonesian
Primarily Uses
RMVXA
The RM code in question was literally just the "Window_EquipSlot". Nothing was changed within the default RM script on functionality.
You dare to say that you essentially want to change the window and said nothing is changed within the default script. well ok. Whatever, it is up to you at this point ...

I will just say this thread is mostly for asking a ruby syntax, preferably without context since it does not deserve its own thread.
 

FamilyGamer7

Villager
Member
Joined
Jan 4, 2021
Messages
29
Reaction score
2
First Language
English
Primarily Uses
RMVXA
You dare to say that you essentially want to change the window and said nothing is changed within the default script. well ok. Whatever, it is up to you at this point ...

I will just say this thread is mostly for asking a ruby syntax, preferably without context since it does not deserve its own thread.

I honestly think there is a language barrier at this point as you have misinterpreted what I have requested at many points.

Let me clarify a few things:
- The Window_EquipSlot was default. Nothing was modified.

- I did request ruby syntax to be able to modify how the equip slots displayed and behaved. I was trying to give some context, but that clearly is too much information for this thread (As you mentioned).

That is enough for me. As I have stated multiple times, I appreciate the help that has been given.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,048
Reaction score
7,135
First Language
Indonesian
Primarily Uses
RMVXA
Yes, there is a language barrier that apparently you did not understand my point.
So, let me clarify.

- The Window_EquipSlot was default. Nothing was modified.
You don't need a modified Window_EquipSlot to open a new thread. Learning RGSSx forum means it does include understanding the default script behavior, the unmodified one.

I did request ruby syntax
I gave you one.

to be able to modify how the equip slots displayed and behaved
No, you're requesting an example.

Now, if you're still looking for assistance, go make a new thread.
If not then we can drop this.
 

FamilyGamer7

Villager
Member
Joined
Jan 4, 2021
Messages
29
Reaction score
2
First Language
English
Primarily Uses
RMVXA
@FamilyGamer7 You can do $game_party.send("actor_mp_levels_actor#{id}"), where id is the integer you want to use.

I am looking to do a similar approach with a module variable. Below is my current test setup..

Ruby:
Module Test
    Module Variables

    Lv1 = 1
    Lv2 = 2

    end
end

I want to be able to do Test::Variables::Lv(a) - "a" would be my variable that I am using, so I could loop through 1..2 or anything for that matter. What would the syntax look like in module form versus the $game_party.send syntax?

I have done some google searches in Ruby and cannot find anything referencing this approach with using a module. The only thing I see is maybe putting the modules within a newly defined class...
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
686
Reaction score
448
First Language
English
Primarily Uses
RMVXA
@FamilyGamer7 Try Test::Variables.const_get("Lv#{a}"), where a is the variable. You can also do Test::Variables.const_get("Lv#{a}") if Test::Variables.const_defined?("Lv#{a}"), which won't cause errors if the constant doesn't exist.
 

FamilyGamer7

Villager
Member
Joined
Jan 4, 2021
Messages
29
Reaction score
2
First Language
English
Primarily Uses
RMVXA
@FamilyGamer7 Try Test::Variables.const_get("Lv#{a}"), where a is the variable. You can also do Test::Variables.const_get("Lv#{a}") if Test::Variables.const_defined?("Lv#{a}"), which won't cause errors if the constant doesn't exist.

Yep, that worked as intended. Appreciate the help.
 
Last edited:

Latest Threads

Latest Profile Posts

treele.jpg
A them/they in a forest... a still for the game I'm working on.
Making a blue-magic-heavy game is very fun but there's a lot of extra hassle as well. Balancing skills for both enemy and player usage isn't easy.
BTW everyone on staff who made the forum jump, thank-you! This time I am not panicked and lost all rounds.
I'm not searching for bugs, just pleasant surprises, for now on ^^
Been a while since I've been here, whoops. My computer's been acting really stupid so I wasn't able to work on my projects, but the good news is I've got a new one, meaning I can get back to work. And I've got a nice idea in mind, I'll just need to find some good scripts for the Aesthetic.

Forum statistics

Threads
108,838
Messages
1,039,942
Members
141,301
Latest member
sxips
Top