iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
5 Pages V  « < 3 4 5  
Reply to this topicStart new topic
> Ruby Scripting Tutorials in RPG Maker VX, Video tutorial to teach the basics and not so basics of Ruby for VX
GubiD
post Apr 16 2012, 03:07 PM
Post #81



Group Icon


Type: Coder




Starting tutorials on VX Ace now. Check them out:







Should be having plenty more coming as I blaze my way into VX Ace.

This post has been edited by GubiD: Apr 16 2012, 03:08 PM
Go to the top of the page
 
+Quote Post
   
Tellier
post Apr 21 2012, 12:40 PM
Post #82



Group Icon


Type: Undisclosed
Alignment: Chaotic Good




I absolutely adore your tutorials! They're priceless for a rookie ruby coder!

I've encountered an error during Tutorial 7 Part 4 - Cooking Script. When I run the script and talk to the "boy" it's not possible to change the recipe you want to cook and when I then press the first recipe "Line 176: NameErorr occured. undefined local variable or method update_details for #<Scene_Cooking:0x2bdbc98>" pops up. Anyone know what I've done wrong?

Here's my unfinished script prototype:
Spoiler:
CODE
#===============================================================================
# Cooking Script v1.0 by GubiD 5/16/2011
#===============================================================================
module Cooking

# ID => [ITEM_ID, BURNT_ID, REQ_LV, EXP]
Recipes = {
1 => [2,21,1,100],
2 => [3,1,2,300]
}

def self.ingredients(id)
case id
when 1
return [[1,3]]
when 2
return [[1,2],[2,3]]
end
end
end


class Game_Party < Game_Unit
attr_reader :cooking_lv
attr_reader :learned_recipes
alias init_gm_party_cooking_script initialize unless $@

def initialize(*args)
init_gm_party_cooking_script(*args)
@cooking_lv = 1
@cooking_exp = 0
@cooking_exp_list = [0, 500, 1000, 2000]
@learned_recipes = []
end

def gain_cooking_exp(value)
@cooking_exp += value
@cooking_exp = [@cooking_exp, 9999].max
if @cooking_exp_list[@cooking_lv] < @cooking_exp
gain_cooking_lv
end
end

def gain_cooking_lv
@cooking_lv += 1
end

def learn_recipe(number)
@learned_recipes << number if !@learned_recipes.include?(number)
@learned_recipes.sort!
end

def forget_recipe(number)
@learned_recipes.delete(number)
end
end

class Cooking_Title < Window_Base

def initialize
super(0,0,544,64)
refresh
end

def refresh
create_contents
fsize = self.contents.font.size
self.contents.font.size = 24
self.contents.draw_text(0,0,544-32,WLH+8, "Cooking")
self.contents.font.size = fsize
self.contents.draw_text(0,0,544-32,WLH+8, "Level: #{$game_party.cooking_lv}",2)
end
end

class Cooking_Available_List < Window_Selectable

def initialize
super(0,64,544/3, 416-64)
refresh
end

def refresh
recipes = $game_party.learned_recipes
@item_max = recipes.size
create_contents
for i in 0...@item_max
recipe_data = Cooking::Recipes[recipes[i]]
cur_lv = $game_party.cooking_lv
if recipe_data[2] > cur_lv
draw_recipe_disabled(i)
else
draw_recipe_enabled(i)
end
end
end

def draw_recipe_disabled(index)
fcolor = self.contents.font.color
self.contents.font.color = Color.new(50,50,50,255)
rect = item_rect(index)
r_id = $game_party.learned_recipes[index]
recipe_data = Cooking::Recipes[r_id]
item_id = recipe_data[0]
item = $data_items[item_id]
self.contents.draw_text(rect, item.name)
self.contents.font.color = fcolor
end

def draw_recipe_enabled(index)
self.contents.font.color = normal_color
fcolor = self.contents.font.color
self.contents.font.color = Color.new(50,50,50,255)
rect = item_rect(index)
r_id = $game_party.learned_recipes[index]
recipe_data = Cooking::Recipes[r_id]
item_id = recipe_data[0]
item = $data_items[item_id]
self.contents.draw_text(rect, item.name)
end
end


class Cooking_Details < Window_Selectable

def initialize
super(544/3,64,544-544/3, 416-64)
refresh
end

def refresh(recipe = nil)
@recipe = recipe
create_contents
return if recipe == nil
@recipe_data = Cooking::Recipes[@recipe]
@item = $data_items[@recipe_data[0]]
fsize = self.contents.font.size
self.contents.font.size = 24
self.contents.font.bold = true
self.contents.draw_text(0,0,width-32,WLH+8,@item.name,1)

draw_icon(@item.icon_index, ((width-32)/2)-12, 40)
draw_item_description
draw_ingredients
end

def draw_item_description
end

def draw_ingredients
end
end

class Scene_Cooking < Scene_Base
def start
create_window
end

def create_window
@title = Cooking_Title.new
@list = Cooking_Available_List.new
@details = Cooking_Details.new
@list.active = true
@list.index = 0
@details.active = false
end
def post_start
end

def update
if @list.active == true
update_list
return
end
if @details.active == true
update_details
return
end
end

def update_list
if Input.trigger?(Input::C)
recipe_id = $game_party.learned_recipes[@list.index]
data = Cooking::Recipes[recipe_id]
if data[2] > $game_party.cooking_lv
Sound.play_buzzer
return
end
Sound.play_decision
@list.active = false
@details.active = true
@details.index = 0
end
if Input.trigger?(Input::cool.gif
Sound.play_cancel
$scene = Scene_Map.new
end

end
def pre_terminate
end
def terminate
@title.dispose
@list.dispose
@details.dispose
end
end

class Game_Interpreter
def learn_recipe(number)
$game_party.learn_recipe(number)
end
def forget_recipe(number)
$game_party.forget_recipe(number)
end
end



On a side note though, if you have a lot of spare time, It'd be even better if you could do some short but informative tuts
on the short (but important) parts of the RGSS2. For example a detailed walkthrough of Scene_Menu and Game_Picture would
be well appreciated!

Keep on rockin'!

This post has been edited by Tellier: Apr 22 2012, 07:42 AM
Go to the top of the page
 
+Quote Post
   
GubiD
post Apr 23 2012, 02:56 AM
Post #83



Group Icon


Type: Coder




Ok, so to answer both. Firstly you are not updating the windows. You are calling the 'input methods' for those windows of "update_list' and 'update_details', but your still not actually updating the windows. I believe in the demo I did a 'update_windows' method that does this. You could also just add the lines: @list.update and @details.update and it will resolve that one.

Now, the second error is because the update_list is saying to make the details active, which it does. But then if you search for 'def update_details' it does not exist. That is all the error message is saying as well. There is no variable or method by the name of update_details currently, hence it crashes.

Hope this helps.
Go to the top of the page
 
+Quote Post
   
Tellier
post Apr 23 2012, 07:19 PM
Post #84



Group Icon


Type: Undisclosed
Alignment: Chaotic Good




I see, thanks for the help! I'm just confused why it worked for you in the tutorial when I wrote everything exactly as you did laugh.gif Anyway, I'll just continue with part 5 & 6 and see if I can get it up and running after that, it seems as copying your part of the "def update_details" won't do me any good.
Go to the top of the page
 
+Quote Post
   
GubiD
post May 14 2012, 12:04 PM
Post #85



Group Icon


Type: Coder




2 more tutorials for you guys



This post has been edited by GubiD: May 14 2012, 12:04 PM
Go to the top of the page
 
+Quote Post
   
jesse120
post Jul 13 2012, 06:06 PM
Post #86


Master Eventer, Novice scripter, pathetic spriter
Group Icon


Type: Designer
Alignment: Chaotic Good




you don't have tutorial 7 part six posted here.


--------------------
I might not post anything for a while, but I am still here, watching. You may not see me, but I see you.
Still taking event requests. Still watching topics. I will see comments to my posts and respond.
I will probably not update any of my scripts for a while.

I have not gone!!!

Spoiler:

Master eventer
Need an unusual event call me and i might be able to make it
ex vehicle, pet
search number
I do take event requests
search number 10519195120
Please don't put this number on any of your own posts or topics
note: the search number will be on any post I make to aid in searching by author. If I forget to put it on a topic please notify me.

I will try to check any posts/PMs around 7:30 AM, 3:00 PM, and after 6 PM most days (time in Pacific Time)

The ultimate video game

Legend of, Elder, Fear, of Fabled, Fallout, Call, of Modern, Gears, of Halo, Metal, Ghost, Assassin, Mass, Homicide, Fantasy, 5
That stands for
Legend of Zelda, Elder Scrolls, ?????, Fable, Fallout, Call of Duty, Modern Warfare, Gears of War, Halo, Metal Gears, Ghost Recon, Assassin's Creed, Mass Effect, Auto Homicide, Final Fantasy, 5
Let me know if you want a game added to the list

If you are a believer of Jesus Christ, believe he is the only way to heaven, and are 100% proud of it, put this in your sig.
Go to the top of the page
 
+Quote Post
   

5 Pages V  « < 3 4 5
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: 30th September 2014 - 10:57 AM

RPGMakerVX.net is an Privacy Policy, Legal.