RPG MAKER XP/VX FAQ

Posts

Pages: first 12 next last
Kentona asked me a while back (well, went *hint hint* which I guess I could've chosen to misinterpret) about adding some tutorials about VX. I've got a bit about simple inserting scripts (not sure what else to do with that since scripting is an incredibly broad topic) and I figured this thread would help. I don't have much personal experience to draw on so I'm looking for people to share their own advice or their own issues they had with XP/VX.

This is not a help request topic! This is more about general questions anybody may ask instead of "how do I add more stats"

My current plan is to try and get this filled out then submit it as a tutorial for VX/XP. Not quite a "How do I start with XP/VX" but a bit above that. Pointing out common pitfalls or issues with the game.

Both VX and XP

What is A/B/C/L/R?
They aren't keyboard inputs! Think of them as buttons on a controller, except instead of A/B/X/Y they're A/B/C. These are intermediate buttons between what the player pushes in and what the game reads. If you push "Enter", the engine translated this into A/B/C (based on key mapping) which the game reads. This makes it easy to separate user input across multiple buttons on the keyboard and other inputs like gamepads and how the game reads input.

A player can change their personal key mappings by changing the game settings by pushing F1 while playing a game.

My Game Has a "Stack too Deep" Error!
This is a bug in RGSS and when a script uses 'alias' in certain situations and the user restarts a game via F12. You can't fix RGSS but you can correct the issue in the scripts. In all scripts you included in your game (the default scripts don't have this issue as they never use alias) and find all lines that are an alias. It should look something like
alias new_function_name old_function_name
Add the following to the end:
unless $@
So the line looks like
alias new_function_name old_function_name unless $@
Then F12 will no longer cause "Stack too Deep" errors!

RPG Maker VX
Script Libraries
Yanfly's Pockethouse (currently down)
KGC's Script Library translated by Mr. Anonymous

The First Thing You Should Do:
There's a serious bug in RMVX: The variable operations event command can't do math right! When being translated somebody screwed up multiplication and getting the number of an item held. Thankfully this (and several other but less important) bugs were fixed by Yanfly. The first thing you should do is download this script and add it to your project to correct these bugs. There's no reason not to, it works perfectly with everything.

Mirror download link until Pockethouse is back up. Copy this into a new script in your RMVX game below "Materials" and above all other scripts and watch it kick butt! (thanks Kentona)


RPG Maker XP
Script Libraries
None yet

Test Play Doesn't Work! (Windows Vista/7)
RMXP doesn't start the test game correctly, tripping Windows security which prevents the game from starting. To fix this you need to run the editor (RMXP.exe) as an Administrator. To do this right click on the program and either select "Run as Administrator" or go under Properties->Compatability Settings and check "Run as Administrator".

RMXP Doesn't Run! / RGSS Player Crashes when Starting a Game (Windows Vista/7)
RMXP has issues with DEP, a security feature that prevents non-executable memory from being executed. To run RMXP games with DEP on, you need to add the Game.exe for that game (which means you need to add the Game.exe from each game to that list unfortunately) to the DEP OptOut list. The editor is trickier and so far you have to turn DEP off to run it unfortunately.


Scripting Advice
Comment instructions along with any script you add in the script editor because chances are, a week or a month later when you go back to work on your game you've forgotten why you put things where you put them or how your script even works. Comments are added simply by putting a numerical sign, #, before any code on a line, that lets rpgmaker know it can ignore that line(or something similar to that effect)

EX: # this line of code is commented!

A good way to prevent annoying mistakes:

When you get an error don't immediately freak out, there is a pretty good chance you just mistyped something. Go back to your script editor, review what you've added, but be very aware of how you spell things.

Spelling, caps, and spaces matter when trying to access variables/classes/what-not(also spaces in variables/class/method names are a no-no). A good way to avoid forgetting exactly how you spelled a variable is to set a precedence for how you will name things. I try to make the name of my variables/class/method describe what I will do with it but in only one or two words. Want a variable that keeps track of damage, you could name it @damage_tracker. The more your variables make sense, the easier it will be to remember what does what and how it is spelled.


Some common errors you might see:

Syntax Error: There is something grammatically wrong with your code. When I mean grammar I don't mean the English language, rather ruby(what RGSS is built on/of). Look for missing parenthesis, brackets, or quotation marks that may be enclosing array selections or text. Make sure that your if / loop / case / etc... statements have a corresponding end to them. There's other situations but those are the most general, and generally the most annoyingly hard to spot sometimes!

NoMethod Error: This error is just as the name says, you are trying to access a method for a class and that method does not exist. If you are trying to access a variable in the class instead of a method be sure that the variable has the attr_reader/accessor attached to it in class-type that you are trying to access it from. There are also other situations where this could occur, these are just the most common(to me anyway).

Name Error : You are trying to access a variable/constant that does not exist, or if it does exist you spelled it wrong. Check your spelling!
Max McGee
with sorrow down past the fence
9159
I approve of this thread (and will probably patronize it).
The stack too deep thing has been happening to me forever. Thanks for the cure.
Something I guess I didn't make clear was that people could submit their own tips, solutions, pitfalls/issues they experienced, and point out some script libraries! C'mon everyone! Let's fill this thing out!
Tips using XP? hmmm.....

Most of this will be related to scripting so if it is general info you are looking for ya best move on. Also, if you have experience in computer programming most of what I am going to say is probably not for you(since you probably already know it), but if you aren't sure what a syntax error or other basics terms are then this may be for you. Also, this should be applicable to both XP and VX, I haven't used VX but if it uses RGSS it can't be too far off.

Scripting FAQ of various information

1) Comment instructions along with any script you add in the script editor because chances are, a week or a month later when you go back to work on your game you've forgotten why you put things where you put them or how your script even works. Comments are added simply by putting a numerical sign, #, before any code on a line, that lets rpgmaker know it can ignore that line(or something similar to that effect)

EX: # this line of code is commented!

2) A good way to prevent annoying mistakes: When you get an error don't immediately freak out, there is a pretty good chance you just mistyped something. Go back to your script editor, review what you've added, but be very aware of how you spell things.

Spelling, caps, and spaces matter when trying to access variables/classes/what-not(also spaces in variables/class/method names are a no-no). A good way to avoid forgetting exactly how you spelled a variable is to set a precedence for how you will name things. I try to make the name of my variables/class/method describe what I will do with it but in only one or two words. Want a variable that keeps track of damage, you could name it @damage_tracker. The more your variables make sense, the easier it will be to remember what does what and how it is spelled.


3) Some common errors you might see:

syntax error: there is something grammatically wrong with your code. When I mean grammar I don't mean the English language, rather ruby(what RGSS is built on/of). Look for missing paranthesis, brakets, or quotation marks that may be enclosing array selections or text. Make sure that your if / loop / case / etc... statements have a corresponding end to them. There's other situations but those are the most general, and generally the most annoyingly hard to spot sometimes!

NoMethodError: This error is just as the name says, you are trying to access a method for a class and that method does not exist. If you are trying to access a variable in the class instead of a method be sure that the variable has the attr_reader/accessor attached to it in class-type that you are trying to access it from. There are also other situations where this could occur, these are just the most common(to me anyway).

NameError : You are trying to access a variable/constant that does not exist, or if it does exist you spelled it wrong. Check your spelling!! (lol, and you thought your English teacher was bad!)

I am going to stop here for now just in case I write about a bunch of stuff that isn't needed. I've been programming off and on for 10 years with various languages so some of the things I may have said here might be bad coding practices or out of date. I don't know if this is the kind of stuff you are looking for GreatRedSprit but I'd be more than happy to write along the same subject line if there is a demand.
I have a question:

When a script says, "The following commands are available using the "Script" item in events.", and has say, this in the comments:

#_/   * set_daynight_default(duration)

#_/ Forces the tint of the current phase to reset to the initial phase.

How does one go about using that in an event?

What I did was go to an event, went to page 3, selected Script, and typed:
set_daynight_default(1)
...but when I run it I get an error:
"NoMethodError occurred. undefined method 'set_daynight_default' for nil:NilClass"

So I assume I have a syntax error, but what could the correct syntax be? I haven't a clue.
post=133788
I have a question:

When a script says, "The following commands are available using the "Script" item in events.", and has say, this in the comments:

#_/   * set_daynight_default(duration)
#_/ Forces the tint of the current phase to reset to the initial phase.
How does one go about using that in an event?

What I did was go to an event, went to page 3, selected Script, and typed:
set_daynight_default(1)
...but when I run it I get an error:
"NoMethodError occurred. undefined method 'set_daynight_default' for nil:NilClass"

So I assume I have a syntax error, but what could the correct syntax be? I haven't a clue.

Rpgmaker thinks you are trying to call a method called "set_daynight_default" from a class that does not contain this method(or doesn't exist). Without being able to look at the code I am going to assume that the script you are implementing does something to modify the event processing so that the method, "set_daylight_default", is in the class where all the event commands are broken down into ruby code and then execute. That way it could be called like that without specifying a parent class. To call it outside of the parent class you must be calling it from a variable that is an instance of that class. If that method was in another class you would have to say something like:

class CustomClass
def set_daylight_default(num)
#code goes here
end
end


@example = CustomClass.new()

@example.set_daynight_default(1)

In the above example I first made the variable example an instances of a CustomClass, that means it has access to all the methods and variables available in that class. The second line of code is me calling the daylight function with the @example instance.

That may, or may not, help you fix the problem help but I am also willing to take a look at the script itself if you want.

(in other news is there a command list for the forum code? I figured out a few commands simply because they pretty obvious but a list would really help lol)
The offending bit of code is this
module KGC
module Commands
module_function
#--------------------------------------------------------------------------
# â—‹ 昼夜切り替えã‚'停止
#--------------------------------------------------------------------------
def stop_daynight
$game_system.daynight_change_enabled = false
end
#--------------------------------------------------------------------------
# â—‹ 昼夜切り替えã‚'èµ·å‹•
#--------------------------------------------------------------------------
def start_daynight
$game_system.daynight_change_enabled = true
end
#--------------------------------------------------------------------------
# â—‹ 現在のフェーズ名ã‚'取得
#--------------------------------------------------------------------------
def get_daynight_name
return KGC::DayNight::PHASE[get_daynight_phase][0]
end
#--------------------------------------------------------------------------
# â—‹ 現在の曜日ã‚'取得
# variable_id : 代入する変数 ID
#--------------------------------------------------------------------------
def get_daynight_week(variable_id = 0)
if KGC::DayNight::METHOD == KGC::DayNight::METHOD_RTIME
week = Time.now.wday
else
days = $game_variables[KGC::DayNight::PASS_DAYS_VARIABLE]
week = (days % KGC::DayNight::WEEK_NAME.size)
end

if variable_id > 0
$game_variables[variable_id] = week
$game_map.need_refresh = true
end
return week
end
#--------------------------------------------------------------------------
# â—‹ 現在の曜日名ã‚'取得
#--------------------------------------------------------------------------
def get_daynight_week_name
return KGC::DayNight::WEEK_NAME[get_daynight_week]
end
#--------------------------------------------------------------------------
# ○ フェーズ切り替え
# phase : 切り替え後のフェーズ
# duration : 切り替え時é–"(フレーム)
# pass_days : 経過させる日数 (省略時: 0)
#--------------------------------------------------------------------------
def change_daynight_phase(phase,
duration = KGC::DayNight::PHASE_DURATION,
pass_days = 0)
$game_temp.manual_daynight_duration = duration
$game_system.daynight_counter = 0
$game_system.daynight_phase = phase
$game_variables[KGC::DayNight::PASS_DAYS_VARIABLE] += pass_days
$game_map.need_refresh = true
end
#--------------------------------------------------------------------------
# ○ 次のフェーズへ遷移
# duration : 切り替え時é–"(フレーム)
#--------------------------------------------------------------------------
def transit_daynight_phase(duration = KGC::DayNight::PHASE_DURATION)
$game_screen.transit_daynight_phase(duration)
$game_map.need_refresh = true
end
#--------------------------------------------------------------------------
# ○ デフォルトの色調に戻す
# duration : 切り替え時é–"(フレーム)
#--------------------------------------------------------------------------
def set_daynight_default(duration = KGC::DayNight::PHASE_DURATION)
$game_screen.set_daynight_default(duration)
$game_map.need_refresh = true
end
#--------------------------------------------------------------------------
# â—‹ 現在のフェーズã‚'復元
# duration : 切り替え時é–"(フレーム)
#--------------------------------------------------------------------------
def restore_daynight_phase(duration = KGC::DayNight::PHASE_DURATION)
$game_screen.restore_daynight_phase(duration)
$game_map.need_refresh = true
end
end
end

class Game_Interpreter
include KGC::Commands
end
It is from the KGC DayNight script.
Okay, after some tinkering I return with results.

post=133804
class Game_Interpreter
include KGC::Commands
end


Rename Game_Interpreter to just Interpreter

I'm not sure what Enterbrain named all of their classes when it was in Japanese however it seems that Interpreter was named Game_Interpreter. When you rename it, RPGmaker now appends the code included in the renamed class to the existing code found in the event Interpreter. However there seems to also be some other errors with the code, namely it is referring to variables/methods that just don't exist and which it doesn't create. Unless of course you simply only gave me part of the code, however after looking it over I have to assume there is more code simply because what you've given me so far is more of an interface and none of the meat and potatoes that actually does stuff.

Hope that helped :)


Edit:
Also I forgot to ask if you are using XP or VX. I only have XP and so that was what the solution was tested with. If it is VX then it could also work, though it is anybody's guess lol
Edit:
Have you tried using the English version of the script? I know sometimes partially translated ones can cause trouble in the English version of VX. Could also be a problem that was fixed in a later, translated version.
I'm not sure what the issue is. The script I have seems to be translated (at least, the comment section explaining it all is, and there is a link to the translator's blog). It is just the standard KGC Day Night script.

Anywho, when I was putzing around in the VX event system I noticed that there wasn't an Inn event. Is it really gone or am I just missing seeing it?
Doh, you are using VX so all my advice(or something similar) was for naught!!!

Maybe I can help anyway!! Something I do to help troubleshoot script is to type

print "gets here"

before a section of code to check if it at least gets to the compiler. Probably not the best way to do it but if you get a windows dialog box that pops up and says "gets here" then you know at least your code executes to that point. So put one of those in the set_daynight_default class in the KGC commands module that you posted. If the msg pops up when you run your game then it at least means your script in the event is calling the function in the command module(which is a good thing!!), next look for a function with the same name in the game_screen class. Put the "gets here" thing there and then run your game again to see if a windows command window pops up again. If I am right and that function does exist in the game_screen class(and the window pops up with the "gets here") then post here again and I might be able to help further.

Since I don't have VX I really can't say much more than that as most of what I am suggesting is me grasping at straws. However I hope at least something I've said will help you.


Ah, the oldest debugging trick in the book! I have used you many a time.
I've used this trick a lot and it does have one problem: A print command in a loop is a pain to get out of. As long as the window dialog box is up you can't interact with the main game window and if you're in a loop, closing the window will give you a split second to interact with the game window (like closing it) before it comes up again. There's always the task manager way but that resets the script cursor :(

(I made a class to emulate the print command: It'll create a window in-game on top of everything and darken the rest of the screen. Does everything (except newlines) print can without the looping issues! Also usable for any time a user prompt needs to come up, mostly for Save/Load Complete)


*edit*
I'll look at the script tonight and see if I can VX-ify it.
LouisCyphre
can't make a bad game if you don't finish any games
4523
That would be a wonderful thing to have for a number of reasons, Griss.
It's pretty simple, it should go as follows (doing this from memory so there's a 99% chance it won't work):


class Window_Popup < Window_Base

def initialize(message)
# Calculate the size of the window so it is shrinkwrapped around the message
self.contents = Bitmap.new(33, 33)
width = self.content.text_size(message).width + 32 (was there a way to call text_size without making a new bitmap?)
height = self.contents.font_size + 32
# Calculate the position so it is in the center of the screen
x = (Graphics.width - width) / 2
y = (Graphics.height - height) / 2
# Create the window
super(x, y, width, height)
# Set the z-index to appear on top of everything
z = 1000

# Create the window contents
self.contents.dispose
self.contents = Bitmap.new(width - 32, height - 32)
self.content.draw_text(0, 0, self.contents.width, self.contents.width, message)

# Create the darkened screen effect
dark_sprite = Sprite.new
dark_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
# Fill the sprite's bitmap with a translucent black color
dark_sprite.bitmap.draw_rect(0, 0, dark_sprite.bitmap.width, dark_sprite.bitmap.height, Color.new(0, 0, 0, 192) )
# Set the sprite's position
dark_sprite.x = dark_sprite.y = 0
dark_sprite.z = self.z - 1

# Until the player pushes the confirm button keep the message on screen
while not Input.trigger?(Input::C) do
# Update the game
Graphics.update
Input.update
end

# Dispose of everything
dark_sprite.bitmap.dispose
dark_sprite.dispose
self.contents.dispose
self.dispose

end
end

(the one I made did a few other things but I don't have access to it right now)

Call it with "Window_Popup.new('insert message here')" and it'll clean most of itself up (and the garbage collector will clean up the actual class)
post=134134
I'm not sure what the issue is. The script I have seems to be translated (at least, the comment section explaining it all is, and there is a link to the translator's blog). It is just the standard KGC Day Night script.

Anywho, when I was putzing around in the VX event system I noticed that there wasn't an Inn event. Is it really gone or am I just missing seeing it?


Nope, there's no Inn command anymore. You can however right click and make a quick Inn event.
What's this talk about anti lag scripts?
LouisCyphre
can't make a bad game if you don't finish any games
4523
post=144584
What's this talk about anti lag scripts?

It's for people who think they need twelve parallel processes cycling pictures over fog and overlays.

(i.e. people who don't know how to use RM)
Pages: first 12 next last