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

FamilyGamer7

Villager
Member
Joined
Jan 4, 2021
Messages
29
Reaction score
3
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,135
Reaction score
7,326
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
3
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,135
Reaction score
7,326
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
3
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,135
Reaction score
7,326
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
3
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,135
Reaction score
7,326
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
3
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,135
Reaction score
7,326
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
3
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
689
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
3
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:

Jacoh

Villager
Member
Joined
Dec 14, 2017
Messages
16
Reaction score
4
First Language
Italian
Primarily Uses
RMVXA
How do you make the player not able to use items when afflicted by a specific status using a script?
 

Ayanamiku

Villager
Member
Joined
Mar 1, 2021
Messages
6
Reaction score
8
First Language
Français
Primarily Uses
RMXP
Good morning all : D

With RMXP we can modify the basic size of the icons from 20px to 32px?

Or would it take a script?
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
351
Reaction score
136
First Language
English
Primarily Uses
RMXP
Good morning all : D

With RMXP we can modify the basic size of the icons from 20px to 32px?

Or would it take a script?
You can make them whatever size you want, as long as you make all the adjustments in your scripts accordingly. Take for example Window_Item:
Code:
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
You just have to update the 24's there.

There is no script that will universally do this for you, however.
 

Ayanamiku

Villager
Member
Joined
Mar 1, 2021
Messages
6
Reaction score
8
First Language
Français
Primarily Uses
RMXP
You can make them whatever size you want, as long as you make all the adjustments in your scripts accordingly. Take for example Window_Item:
Code:
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
You just have to update the 24's there.

There is no script that will universally do this for you, however.
Thanks
 

idleberry

Villager
Member
Joined
Mar 8, 2021
Messages
15
Reaction score
2
First Language
russian
Primarily Uses
N/A
hi from russia ^^
rpg maker vx ace (RGSS3):
is it possible to create and draw a picture as a "Show Picture" picture, from: Event Commands - "script" command?
(I mean - create a picture without saving it to a file (using the bitmap class), but display it on the screen in a standard way, so that later you can control it through standard event commands)
 
Last edited:

idleberry

Villager
Member
Joined
Mar 8, 2021
Messages
15
Reaction score
2
First Language
russian
Primarily Uses
N/A
at the moment I am using script:

$game_variables[30] = Sprite.new $game_variables[30].bitmap = Graphics.snap_to_bitmap $game_variables[30].src_rect.set(191, 0, 160, 480) $game_variables[30].x = 191 $game_variables[30].y = 0

but I do not know how to place the picture under the character and not above him.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,194
Reaction score
843
First Language
Hungarian
Primarily Uses
RMVXA
You can do that, but be aware that if the player can access the save menu and tries to save the game, the game will crash and the save file will become corrupted, so it gets auto-deleted.
To avoid this, you have to dispose the sprite you assigned to that variable and set the variable to something that is compatible with the Marshal.dump method (it can be a simple nil or false).

Also, having the sprite on screen when the player opens the menu (or changes the scene in any other way) will make the image disappear once the scene is back to the map, but that doesn't mean that the variable is cleared, so it will still hold that sprite.

In short, you can't just create sprites all over the place, you have to make sure that they are properly disposed when you are done with them or you will get into a lot of issues.

If you get the disposal issue out of the way, here is how you can set the image above/below other things:
Code:
$game_variables[30].z = 50
Just change the value to higher/lower (by +/-50 at a time) to see where it gets placed.
 

Latest Threads

Latest Posts

Latest Profile Posts

Yay, our new game, Causality is finally released on Steam!
A good way to practice writing is to write "flash fiction"; very short stories. Link
[CM]
5VaUMjAFpz1I6fSsgDrfJc.jpg

Title is star.
Dam, does the night get to me, I sound and look like a monster. Its 3:54 am right now...I need sleep...or...coffee.

Forum statistics

Threads
110,488
Messages
1,053,675
Members
143,582
Latest member
beru
Top