View unanswered posts | View active topics It is currently Fri Sep 03, 2010 8:57 am

Forum rules


1. You shall not post anything against the global rules of this forum nor against the law of the country you or anyone lives in(that includes Child Porn and things like that).
2. You shall not flame, spam, be 1337 HAXX0rZ or just act like an obnoxious little brat.
3. You shall not act smart(unless you are)
4. You shall not give useless comments, only constructive critisism is allowed here.
5. You shall not upload resources, tutorials or games related to RPG Maker in this section that are not yours without permission and credits.
6. You shall not look at fellow members, mods, admins or Ryon in disrespect. Only look in awe.
7. You shall not post here without proper knowledge of the English language. Double-Check your posts for grammatical errors. Correct grammar and spelling makes it easier to read and understand for everyone.
8. Mindless and/or one-word posts made by post-count hunters will be deleted.
9. You shall not abuse the smileys to an unuasual extent. Only abuse them in small amounts.
10. You shall not advertise your Resources, Games, Tutorials or Topics continually everywhere. This can be labelled as spam and will not be tolerated.
11. If your topic contains any material not suited for minors, add a [NSFW] tag in your topic title.
12. Use the following tags when posting topics:
[TUTORIAL], [QUESTION], [CHIPSET], [CHARSET], [WINDOW SKIN], [GRAPHIC], [RECOURCE], [SCRIPT], [FULL GAME], [FULL GAME WIP], [OTHER]
Tags speak for themselves.
13. When posting a resource, include at least one screenshot. When posting a Full Game, include at least two screenshots. Please refrain from making Full Game WIP topics without being able to show at least two screenshots. Tutorials are nicer with pictures.
14. You shall not correct the grammar in this post. My English is better than yours! If I would be correcting all your mistakes, I'd be busy for a long while.
15. CAPZ LOCK IZ CRUIZE CONTROL FOR COOWL! It's also a one-way ticket to ban land.



Reply to topic  [ 12 posts ] 
 [TUTORIAL] The IF Controller 
Author Message
Level 1
Level 1
User avatar

Joined: Sat Aug 22, 2009 6:53 am
Posts: 142
Location: Arnhem
Post [TUTORIAL] The IF Controller
RPG Maker Tutorial

Topic: Control Structures: Conditional Branching(If, Else, ElsIf and Unless)
Creator: Melchior M. Philips
Version: VX/XP
Coding: Yes
Difficulty: Intermediate

For a litle introduction to coding into ruby, here's one of the most important things in coding: Controllers.
today we're focussing on Conditional Branching.
all conditions have exactly the same structure:
Quote:
if (expression)
then (do this)
else
(do this)
end


there's not alot to explain. If just checks if an expression is true. if yes: do something. If no: do something else(defined under else).
A little bit more complex is the Elsif.
Elsif is used when IF (expression) is not true, and there are more expressions to check.
they are structured like so:
Quote:
if (expression) #If this expression is true:
then (do this) #Then do this.
ifelse (other expressions) #If the previous expression if false, but this one is true:
then (do this) #The do This
else #when both expressions are false:
(do this) #do this
end #end "If" Controller


here's a simple example for use in for example an inn:
Quote:
$child fee = "10$"
$adult fee = "25$"

if age >= 18 then
print "adult fee¥n"
else
print "child fee¥n"
end


Here's a more complex version using Elsif:

Quote:
$child fee = "10$"
$adult fee = "25$"
$senior fee = "15$"

if age < 18 then
print #{$child fee}"
elsif age > 65 then
print #{$senior fee}"
else
print #{$adult fee}"
end


There's also the Unless controller. it is the exact opposite of IF.
it tells you not to do it, Unless this expression is true.
Example:
Quote:
unless baby?
feed_meat
else
feed_milk
end


Basically, this little script tells you you're giving your child meat UNLESS it's still a baby.

In case you're wondering what the deal is with the #{$"something"}, consult my unexsisting tutorial on Expressions that I've actually should've made before this one...
I'll make it someday.

anyway, I hope this kinda helped you along with your scripting adventures!

Greetings
- Melchior M. "Mind Controller" Philips

_________________
Lord Melchior's Cult (Leader)
Click the sig for my website
Image


Sat Aug 22, 2009 2:25 pm
Profile WWW
MFFA Staff
MFFA Staff
User avatar

Joined: Mon Jun 01, 2009 7:54 am
Posts: 5627
Location: NYC
Post Re: RPGmaker Tutorial: The IF Controller
confusing as hell..

this is ruby or basic RPG coding?

_________________
Image
MFFAKKK


Sat Aug 22, 2009 2:31 pm
Profile YIM WWW
Level 1
Level 1
User avatar

Joined: Sat Aug 22, 2009 6:53 am
Posts: 142
Location: Arnhem
Post Re: RPGmaker Tutorial: The IF Controller
Actually this is pretty basic stuff that can be interpreted in both.
In the script editor, you can put this pretty much everywhere.

And sorry that I suck at explaining.
Just stick to my Beginner tutorials Ryon, you'll get it eventually.

_________________
Lord Melchior's Cult (Leader)
Click the sig for my website
Image


Sat Aug 22, 2009 2:34 pm
Profile WWW
MFFA Staff
MFFA Staff
User avatar

Joined: Mon Jun 01, 2009 7:54 am
Posts: 5627
Location: NYC
Post Re: RPGmaker Tutorial: The IF Controller
no i get it , ijust didnt read it.

i understand if and if else, in terms of RPG maker but not mugen.

so yeah.

i was just wondering if this is scripting, or if this is press the tab enter the info coding.

_________________
Image
MFFAKKK


Sat Aug 22, 2009 2:35 pm
Profile YIM WWW
MFFA Staff
MFFA Staff
User avatar

Joined: Fri Aug 21, 2009 12:34 am
Posts: 1293
Location: UK
Post Re: RPGmaker Tutorial: The IF Controller
Melchior M. Philips wrote:
Just stick to my Beginner tutorials Ryon, you'll get it eventually.


Lol. Feel the burn!

_________________
Sexy Bullet
MFFAKKK
Image


Sat Aug 22, 2009 2:41 pm
Profile
Level 1
Level 1
User avatar

Joined: Sat Aug 22, 2009 6:53 am
Posts: 142
Location: Arnhem
Post Re: RPGmaker Tutorial: The IF Controller
MrSteve81 wrote:
Melchior M. Philips wrote:
Just stick to my Beginner tutorials Ryon, you'll get it eventually.


Lol. Feel the burn!


Oh darn, I was actually trying to be genuinly nice to Ryon for once.

ah well.

I have to admit, Ruby(or RGSS for that matter) is very confusing. if you're not used to coding it can frustrate you untill your hair falls out. you want to slowly build up to being an awesome scripter.
follow all the basic tutorials. when you find then too easy, go to Intermediate. afterwards, go to advanced, and when you're done with that see the Professional Tutorials(which do not exsist, as I'm not a pro myself).

coding is something you build up. some stuff even confuses me. don't be sad or mad if you don't get stuff.

_________________
Lord Melchior's Cult (Leader)
Click the sig for my website
Image


Sat Aug 22, 2009 3:03 pm
Profile WWW
MFFA Staff
MFFA Staff
User avatar

Joined: Mon Jun 01, 2009 7:54 am
Posts: 5627
Location: NYC
Post Re: RPGmaker Tutorial: The IF Controller
the ef are you talking about?

i was asking if this was scripting or simple window clicking coding.`

_________________
Image
MFFAKKK


Sat Aug 22, 2009 3:06 pm
Profile YIM WWW
Level 1
Level 1
User avatar

Joined: Sat Aug 22, 2009 6:53 am
Posts: 142
Location: Arnhem
Post Re: RPGmaker Tutorial: The IF Controller
Ryon wrote:
the ef are you talking about?

i was asking if this was scripting or simple window clicking coding.`



oh shit.

This is RGSS, so the actual scripting you put into the Script Editor or the "Script" thingy in Map Events.

I thought it was pretty clear by putting "Coding: Yes" on top of the tut.

_________________
Lord Melchior's Cult (Leader)
Click the sig for my website
Image


Sat Aug 22, 2009 3:16 pm
Profile WWW
MFFA Staff
MFFA Staff
User avatar

Joined: Mon Jun 01, 2009 7:54 am
Posts: 5627
Location: NYC
Post Re: RPGmaker Tutorial: The IF Controller
coding can be 2 things to some people.

but okie dokie.

_________________
Image
MFFAKKK


Sat Aug 22, 2009 3:18 pm
Profile YIM WWW
MFFA Staff
MFFA Staff
User avatar

Joined: Thu Aug 20, 2009 8:38 pm
Posts: 3374
Location: Here in the Soul- I mean MFFA.
Post Re: RPGmaker Tutorial: The IF Controller
I tried to understand this and tried to use it with the timer but I don't tthink it worked like I wanted it to.

_________________
Image
Image


Sun Aug 23, 2009 1:01 am
Profile
Level 1
Level 1
User avatar

Joined: Thu Aug 20, 2009 9:49 pm
Posts: 182
Location: Former Gmod Of This Place :o
Post Re: RPGmaker Tutorial: The IF Controller
i did not understand a word in this topic lol

_________________
Image
"And I'm unusual as shit, I am superbad yo girl prolly Doodlin my dick"-Big Sean

"have you ever had sex with a pharoah,
I put the pussy in a sarcophagus,
now she claiming I bruise her esophagus"-Kanye West


Sun Aug 23, 2009 1:21 am
Profile
Level 1
Level 1
User avatar

Joined: Sat Aug 22, 2009 6:53 am
Posts: 142
Location: Arnhem
Post Re: RPGmaker Tutorial: The IF Controller
Here, let me further explain the simple example:

Quote:
if age >= 18 then
print "adult fee¥n"
else
print "child fee¥n"
end


Quite basically, this script checks if your characters age is equal to or higher than 18.
if this is true, a window will display the fee for adults
If the previous expression is false(if he's below 18)
It will display the fee for children.
end = identifier for the end of a piece of script

Here's it all summed up:
IF: checks if the expression behind is it true
ELSE: Specifies what to do if all previous expressions are false(if) or true(unless)
ELSIF: The same as Ifelse. If the previous expression(s) is/are not true, check if this one is true
UNLESS: Specifies what not to do unless the following expression is true

If you still don't get it I probably just suck at explaining.

_________________
Lord Melchior's Cult (Leader)
Click the sig for my website
Image


Sun Aug 23, 2009 2:21 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.