General RGSS/RGSS2/RGSS3 Help

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

Previous topic - Next topic

G_G

How do we setup
$game_temp.shop_goods


I need to figure this out for a script for my game.

legacyblade

long answer:

Spoiler: ShowHide
Not sure how to set it up, but try and find out what is inside $game_temp.shop_goods to find out, use


p $game_temp.shop_goods


When the shop scene is called. I'm guessing that it just needs an array of the IDs of which items will be for sale, but you should check. It would get this information from the interpreter script, which would get information from the data files. You're best bet is to find out what kind of data is stored in $game_temp.shop_goods, and what information the shop scene needs.


short answer:

Spoiler: ShowHide

$game_temp.shop_goods = something


It is most likely an array of the IDs of the items the shop will have.




Ryex

$game_temp.shop_goods is an array that looks like this
[[x, y], [x, y], [x, y], [x, y]]


where x is the item type
case x
when 0
  item is a $data_items
when 1
  item is a $data_weapons
when 2
item is a $data_armors
end

and y is the items ID
so...
[[0, 1], [1, 1], [2, 1]]

would create a shop where you could buy a potion, bronze sword, and bronze shield in that order

hope this helps!

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

Quote from: Ryexander on May 20, 2009, 11:24:19 pm
$game_temp.shop_goods is an array that looks like this
[[x, y], [x, y], [x, y], [x, y]]


where x is the item type
case x
when 0
  item is a $data_items
when 1
  item is a $data_weapons
when 2
item is a $data_armors
end

and y is the items ID
so...
[[0, 1], [1, 1], [2, 1]]

would create a shop where you could buy a potion, bronze sword, and bronze shield in that order

hope this helps!




Thanks Rye *powers up*

And lb of course
$game_temp.shop_goods is going to equal something xD thanks anyways lb *powers up*

Ryex

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 />

legacyblade

yay, power! And Game_Guy, that is how I find out what I need about certain data structures, print them when they're in use. It's how I figured out the move picture command in RGSS. I was just giving you my standard process.

G_G

Quote from: legacyblade on May 20, 2009, 11:10:57 pm
short answer
Spoiler: ShowHide

$game_temp.shop_goods = something


It is most likely an array of the IDs of the items the shop will have.






I was referring to the short answer. $game_temp.shop_goods = something of course it'll equal something xD

legacyblade

oh, lol. My short answers are usually a sarcastic literal answer of the question :P

G_G

Ok I want to be able to have each item have rarity stars. Now I have the icon but how would I go making this icon be display 1, 2, 3, 4, or 5 times on that item line?

Ryex


n.times do |i|
  src_rect = Rect.new(0, 0, 24, 24)
  <bitmap_class_instance>.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

where n = <number_of_times_to_draw_icon>
you can set n to 1, 2, 3, 4, or 5 with conditional branches or what ever
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

so do I replace the i or the n with the number of times?

Aqua

May 23, 2009, 06:04:17 pm #91 Last Edit: May 23, 2009, 06:07:23 pm by Aqua
Quote from: Ryexander on May 23, 2009, 05:34:22 pm
where n = <number_of_times_to_draw_icon>
you can set n to 1, 2, 3, 4, or 5 with conditional branches or what ever



You could also do...

for i in item.rarity
 src_rect = Rect.new(0, 0, 24, 24)
 <bitmap_class_instance>.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

This way you don't have to use conditions nor the n.

G_G

Quote from: Aqua on May 23, 2009, 06:04:17 pm
Quote from: Ryexander on May 23, 2009, 05:34:22 pm
where n = <number_of_times_to_draw_icon>
you can set n to 1, 2, 3, 4, or 5 with conditional branches or what ever



You could also do...

for i in item.rarity
 src_rect = Rect.new(0, 0, 24, 24)
 <bitmap_class_instance>.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

This way you don't have to use conditions nor the n.


I just replaced the n with item.rarity and it worked so there was no need to have branches.... thanks guys (lvs up aqua and ryex)

Ryex

Quote from: Aqua on May 23, 2009, 06:04:17 pm
Quote from: Ryexander on May 23, 2009, 05:34:22 pm
where n = <number_of_times_to_draw_icon>
you can set n to 1, 2, 3, 4, or 5 with conditional branches or what ever



You could also do...

for i in item.rarity
 src_rect = Rect.new(0, 0, 24, 24)
 <bitmap_class_instance>.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

This way you don't have to use conditions nor the n.

You COULD  use a 'for i in' but you SHOULDN'T it's slow and  'n.times do |i| end' is much faster WcW taught me that
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

Either way this question is resolved but could someone just explain how i would call a bitmap like the one ryex told me through the window.

I just want to know what everything in the line does.

Ryex

in a window
n.times do |i|
  src_rect = Rect.new(0, 0, 24, 24)
  self.contents.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

self.contents IS a Bitmap instance

but elsewhere

bitmap = Bitmap.new(width, height)
n.times do |i|
  src_rect = Rect.new(0, 0, 24, 24)
  bitmap.blt(<init_x_value> * i, y, RPG::Cache.icon(<icon_name>), src_rect)
end

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

Ok that makes a bit more sense now what exactly does src_rect do/mean?

Just trying to learn as much as I can

Ryex

src_rect is a compressed form of source_rectangle it is an instenct of the Rect class the Rect class simply stores a rectangle
so
src_rect = Rect.new(0, 0, 24, 24)
creates a Rect instance with the dimensions 24 by 24 at the co-ordanets (0, 0)
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 />

fugibo

You should probably just add the Rect.new parts inside the argument list, skip over storing then reloading the variable.

G_G

Thanks both of you *lv's both up*

Any bit of RGSS I can learn the better.