Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Special Support - A great place to learn to Script

Everyone wants to learn to script, but no one really knows where to start. In my honest opinion, the best place to learn is just by reading the default scripts. I learned to script with the japanese RMXP, so I didn't have English comments at my disposal, so everyone of the new generation has that upperhand. Anyways, what I think the best thing to do to learn to script is read the default scripts, and understand each line.

So what I am offering here is support for anyone trying to learn to script. If there is a line of code you don't understand, ask me here. If there is something you want to know, like where in the script editor does something happen, ask here.
  • Ask about a certain line of code : What it means, does, etc.
  • Ask where the coding is for a certain function
PLEASE DO NOT ASK SOMETHING OTHER THAN EXISTING CODE, OR WHERE IN THE DEFAULT SCRIPTS TO FIND A CERTAIN BLOCK OF CODE. Your post will be deleted.

This is a Trial and Error topic. Hopefully, it can lead to more a use full FAQ for beginners.
 
Bonjour people,I'm I have a doubt, it is a very difficult to be answered I believe, or almost shown to be impossible to make. I would like to know whether it is possible call the Editor of scripts command call Script?

I believe that a script must be established for such done
 
Ok. Hi everyone. I am tring to use self switch in move route of event. I tried everything, like:
$game_self_switches[[3, 16, "A"]] => true
$game_self_switches = {[$game_map.map_id, $event.id, "A"] => true}
And others I thinked out... Eh : /

It is possible to use it? Maybe it is non working cause I'm calling it in Move_Route? Am I doing something wrong...? Pls...

EDIT: haha XDD, I asked friend. Problem was that map wasn't refreshing =] , then I just added there:
$game_map.need_refresh = true
and it's working
 

yutu

Member

hello =]
a question -
how do i save values?
i need to decrease 1 from a virable  values, every time im talking to an event.
i hope i explained it well... ty.
(sory for the bad english)
 
yutu":2w7rmqm8 said:
how do i use the "%"?

unless I am mistaken, I believe it determines the remainder of a division operation.

so,
Code:
6 % 3
would return 0, due to 6 leaving no remainder after being divided by 3.

Code:
7 % 3
would return 1, due to 7 leaving a remainder of 1 after being divided by 3.

I hope that helps.
 

e

Sponsor

There are also other alternate uses of the % character. It is also used to escape double quoted strings.

Say you have a string:

Code:
And Bob said: "Oh ye mighty, tremble!"

You want to put this between double quotes (escape it).

So you do:

Code:
%<And Bob said: "Oh ye mighty, tremble!">

And it yields:

Code:
"And Bob said: \"Oh ye mighty, tremble!\""
 

elder

Member

I’m new with RGSS2, so I may have tons of newbie questions :D Let's hope I won't look too much dumb hehe.

Let’s start with the Main page with the following statement:

Graphics.freeze

From which class Graphics is? Since RMVX isn’t a coding environment, how can I find/track instances or classes without looking each page one by one?
 
Graphics is a built in module. You can find it by using the Index or Search function in the help doc.

To trace instances, use the Cntl-Shift-F search function in the script editor.

As you mentioned, it's not a programming environment. It's pretty much manual.

However, since it's Ruby, if you have an interactive Ruby coding application, I'm sure you could dump the code to it.

Be Well
 

e

Sponsor

Otherwise, there is unfortunately no central documentation for all the classes in RMXP/RMVX, something I hope to fix whenever I have the time to write proper documentation in Doxygen format for all classes.
 

elder

Member

After reading a thead about changing fonts, I've put those two lines in Main after 'begin':

$defaultfonttype = $fontface = Font.default_name = "Pixel Berry 08/84 Ltd.Edition"
$defaultfontsize = $fontsize = Font.default_size = 18

My question is about: $defaultfonttype, $fontface, $defaultfontsize, and $fontsize.

Where these global variables come from? I can't find any reference about them. They are certainly build-in variables, but where should I learn about them? (I've searched the whole script and nothing, I've also search the documention, nothing.

Thank you :D
 

EOG

Member

I've got a question about strange operator it occurs in RPG maker few times and I cannot figure out what it does

example:
Code:
        for i in $game_party.actors

          used |= i.skill_effect(@actor, @skill)

        end

If you do not know what I am talking about is |=
From looks it is bit-equal operator but if yes what is the different between ==
 
@EOG:
The || boolean operator means "or". Similary, the && boolean operator means "and".
The line you have shown and this one has the same result:
Code:
used = used or i.skill_effect(@actor, @skill)


SEE YA!!!!!
 
It's not the logical operator or - it's the Array#| method. That method returns a new array by joining two arrays and removing duplicates.
The cause of using this method is that an actor can't be poisoned two times :wink: . E.g.:
[ruby]current_actor_states = %w(Poisoned Paralyzed Sleeping)
states_to_assign = %w(Sleeping Poisoned Blind)
p current_actor_states + states_to_assign  # actor is poisoned and sleeping two times
p current_actor_states | states_to_assign  # he's not poisoned and sleeping two times
[/ruby]But remember that also Fixnum, FalseClass and other classes can have this operator defined and each can have different effects. Read the help (you have to serach manually because of the | character) or the Ruby Documentation, etc.

Btw the line you mean is the same as following:[ruby]used = (used | i.skill_effect(@actor, @skill))
[/ruby]
 
I need some help here, please. I've been trying to do it myself but I've been failing. =/

In the default VX battle system, the system picks the highest element modifier, and uses that to modify the damage. It finds the highest modifier like this:

Code:
  def elements_max_rate(element_set)

    return 100 if element_set.empty?

    rate_list = []

    for i in element_set

      rate_list.push(element_rate(i))

    end

    return rate_list.max

  end 

From reading this, I suppose the game makes a list ("rate_list") of all the element modifiers, and then picks the bigger one with "max". So far, so good.
What I want to do is, I want the game to make an average out of all the modifiers, instead of picking the highest modifier.
So, if I attack an enemy with a skill with both A and B elements, and the enemy has 200% vulnerability to A and 50% to B, I want the final damage to be multiplied by (200+50)/2 = 125, instead of 200 (the highest one).

No scripting knowledge beside making simple deductions out of the scripts themselves. I'm having trouble getting this to work. =/
But I bet it's really simple.
 

e

Sponsor

Well, basically instead of making a list (rate_list.push) you'd make a rate_total and divide that by 2.

So:

[rgss]  def elements_max_rate(element_set)
    return 100 if element_set.empty?
    rate_total
    for i in element_set
      rate_total += element_rate(i)
    end
    return (rate_total/2)
  end
[/rgss]
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top