Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [Scripting]How to create your own shop type, Scripting for anyone- Part 1
-dah0rst-
post Dec 1 2010, 12:52 PM
Post #1


Level 11
Group Icon

Group: Revolutionary
Posts: 174
Type: Scripter
RM Skill: Advanced




Still under construction, but you may start reading wink.gif

This tutorial will result into a series of tutorials, helping beginning and advanced scripters to develop their own shops/ monster manuals/ states/ special battle skills/ level advancement systems.
This tutorial is VX based- but it may also help understanding scripting with ruby a bit better.

This tutorial will be a little bit more advanced than some others, for example own skills will be a very easy one...

So here we go- please give feedback (positive or negative doesn't matter, but just show you read my work wink.gif )
The example used is a little itemsmith script I'm currently working on.

What parts do I need for an own shop?

First, you need windows, for example to show a list of items, informations or your character's stats. So you create a bunch of own windows, like I did- for example an item list, a status window for the characters, a window that shows you the items you need for your new item to forge.
Basic windows like an "Info Window" that shows you what the forged item does already exist, so we don't need to create that one- also I used the already existing "Window_ShopStatus"- why create something now that already is implemented so well?

Next thing we need is a scene class, that handles all the actions we do in our shop- like moving from one window to the other or buying something.

Here you see my classes:

IMAGE

Remember: Windows only show something- they actually never doing something- they are only like a picture, displaying something. The only one who does some work is the scene class (a little different is window selectable, but we'll come to that)

So were to start?
As a general rule, before you start doing a big script, make sure how exactly you want to have it work and how should it look like. For example, i always draw a layout on apiece of paper, looking were to place the windows and how big they have to be. The native resolution on VX is 544(x) * 416(Y)- keep that in mind and also write down how big in width and height each window should be.

Here's an example layout from me:

IMAGE

So now you know what you need and were to place it- so let's go to work!

Let's to the item list first!
Ok, here we go:
To make it easy- and we are lazy- we just copy the already existing "Window_ShopBuy" into a new field (strg+a, then strg+c to copy all), making a new window called "Window_ForgeBuy".
First thing we do: we change the class because it's a new window. So we write "class Window_ForgeBuy < Window_Selectable" on top instead of the old class name.
We don't have to modify much here, because we'll use the same shop list used in the original shop (with the old shop list, so we can use the list from the call shop event later on).
The only thing that changes is, which items are displayed as enabled (means they are not gray)- for this purpose, I replaced the old "enabled = ..." with enabled=$scene.incredients?(item) in the draw_item method. So $scene is always our scene_smith, so we will define "incredients?" later on (it means only to display the items as enabled you have the items needed for creation)
Also I removed the "self.contens.draw_text..." (also in draw_method) because I don't wanted to show the item price here.
For your own shop or menu: With self.contents.draw_text you can draw any text into a window at the assigned place- we'll use this later on a lot wink.gif )
So here's the first script (not much changed, tough):

Window number one- finished!
class Window_ForgeBuy < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 544/2, 416-y)
@shop_goods = $game_temp.shop_goods
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
number = $game_party.item_number(item)
enabled = $scene.incredients?(item)
rect = item_rect(index)
self.contents.clear_rect(rect)
draw_item_name(item, rect.x, rect.y, enabled)
rect.width -= 4
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
end


Hey man- I don't want to just copy your lame script- what's the deal with this list?
So here we go again- just deleted one page of text by mistake. But as I'm willing to finish this tutorial, I'll write this chapter again wink.gif


__________________________
You want Next Gen graphic algorithms in RPG VX? Ask the horst :P


But don't expect this in real time ;)
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 22nd May 2013 - 11:32 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker