Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

2 Pages V   1 2 >  
Reply to this topicStart new topic
> [Eventing]Switch & Variable Efficiency, Moving from Amateur to Pro with Switches & Variables.
Titanhex
post Jul 3 2011, 09:13 AM
Post #1


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




So I was grabbing some help earlier and had to return the favor. I realized what I know is not very common amongst the RPG Maker developer base, and wanted to change that.

There's a million guides for Beginners which teach them how to use switches and variables. But there's nothing that teaches them efficiency once they've learned these. I want to change that.

I see a lot of people here turn very easy, simple systems into bloated code, but only because that's how the beginner tutorials taught them to do it.

I'm here to tell you you're making more work for yourself and complicating your systems. So, lets get into it.

What a Switch REALLY is


You've always thought a switch was an ON/OFF didn't you. Well this is only half true, and sort of limits your vision of switches. I'm here to tell you what a switch REALLY is. A switch is just a boolean. What's a boolean? In programming, a boolean is simply a TRUE/FALSE. Makes sense right, ON/OFF, TRUE/FALSE. The default for switches is always OFF/FALSE on creation.

This means instead of checking if two opposites are on, such as IS PRESENT or ISNT PRESENT, you can just check IS PRESENT = ON(TRUE, Is present) or OFF (FALSE, Not present), removing that ISNT PRESENT switch.

Oh no, but what if there's 3 values. PRESENT, NEAR, and FAR. Don't make 3 switches! Make 1 variable. 0 means PRESENT, 1 means NEAR, and 2 means FAR. (BTW Variable default on creation is 0)

Turning Switches into Variables


Many switches can be condensed into a single variable. Lets say a player must grab a key to progress, then open a door to beat a boss, and pick up a chalice in the boss room by checking piles of junk. GRAB KEY would be a switch, as would KILL BOSS and GRAB CHALICE. But you could turn all of these into 1 variable, MAIN STORY STEPS, and check if MAIN STORY STEPS is higher than a number. I do this for linear plots in a game, which just move forward like steps, in increasing order. This turns upwards of 100 switches into a single variable.

So, instead of turning on GRAB KEY, we'd either set the variable to 1 or do +1. This would replace the line [Turn on Switch, GRAB KEY = ON] with MAIN STORY STEPS =+ 1. Instead of checking if GRAB KEY = ON, we'd check if MAIN STORY STEPS is greater than or equal to 1. Instead of KILL BOSS, we'd do set MAIN STORY STEPS to 2 or +1, checking for MAIN STORY STEPS equal to or higher than 2 instead of KILL BOSS as ON.

It's a good idea to keep a comment nearby telling you what # the variable should be after adding to it.

If you have a mission that requires doing steps in a random order, like collecting items scattered in a dungeon, it's easy. If the variable is at 22 when they get to this point and they have to collect 3 items in any order, each time they find an item that variable increases by 1. Thus, by the end of the collecting, the variable will be 25. So 25 is the number we check to know they have all the items.

When do I use a Switch and when do I use a Variable?


A lot of people use switches when they can be using variables. This is what this tutorial is about. Let me convert your thinking. A switch is an ON/OFF, which if you read early is just a TRUE/FALSE. A true false is really just a 0 or a 1.

What? That makes no sense. Well, what's the difference between the switch HAS DOG = ON/OFF and the variable HAS DOG = 0/1. If we check for 0, then we do the things for HAS DOG being off. That'd be the same thing for checking for OFF. Try it yourself. You'll see.

Variables are great when going through steps. Steps can be numbered. Step 1, 2, 3. That is why variables are great for quest lines, and main story setup. They're just steps.

Variables are great for checking how many items someone has collected. But if you want to check for a specific item, you should use a switch, since they either do or dont.

And that's where switches come in. Very simple black or white, do or dont, true or false. If something needs to be defined by only two values with no sequence switches are good. Like checking for gender. If we're checking for hair color, we'd use a variable as hair color has many values.

================================================================================

Thank you for reading! Underneath I've contained snippets that can help you in other commonly misunderstood areas.

The Common Event


Common events, while nice to shrink long snippets of code, is better used for actual "common" events. Common Events means the event reoccurs more than once in the game. This can make altering and correcting code so much easier. Instead of having to change the code in every event, you just change the code once in a common event. It's especially useful when you must detect an area around an event or a wide passage for a player's approach.

It can be great for creating unity in code as well, allowing for consistency, so that if you typo once you will see it in all the code that calls it.

It's important to note that objects and spells can also trigger Common Events, which can be highly useful to activate special conditions or spells. I myself have made a "HP Damage Field" that increases in power when a boss uses a skill with common events.

Credits to Night5h4d3 for bringing this up. Common Events should also be considered as Global Events. What this means is that the event can be run anywhere in the game, or can be running indefinitely despite what map you're on. When creating an event ran system it's good to keep this in mind, as it can allow a number of things, like poison effects periodically on a character with HP reduction, screen shaking when drunk, or timers.

Debugging


Ever had a problem with your events, and no matter how much you looked at the code you couldn't figure it out? Try DEBUGGING. Put in messages near the problem that say "THIS PART IS HAPPENING" or show values like "\v[1]" so you know what value a variable is at a given time. This will help you know where exactly the problem is happening until finally you pinpoint it.

Suggested by lilcooldude69: If you're playtesting your game through the editor, F9 can open up a nifty switch and variable editor as well.

Page Numbers vs Conditional Branches


I want to get people thinking about page numbers and conditional branches a little differently too. A page number is really just a Conditional Branch. You may say, "But how?!" Well, let me show you.

Think of 3 pages, each checking if a variable is 1, 2 or 3. If it's 1, on the page we put the message "This is Page 1". Repeat for 2 and 3.

Well it's the same as if we had only 1 page, but in that page we had 3 Conditional Branches. The branch checks if the variable is 1, next branch if its 2, next if it's 3, telling us what page number it is. The order the branches are in is the same as the page order. These two events are actually the same thing.

Now where page numbers and conditional branches are different is in the bottom left corner of the page, where you see Autonomous movement, Graphic, Priority, Trigger and Options. When these are not consistent between pages, then page number is necessary.

Loops & Waits


Recently I had a problem where I was running a loop without a wait in that loop. Believe it or not, if a loop doesn't have a wait in it, it could run so rapidly it stops your game from updating the screen. This is true in scripting as well as eventing. Remember when using loops to include a wait somewhere, and/or a break point so it doesn't run infinitely. If your loop isn't working, check these two problems first. It's likely one of those.

What many don't know is that a Parallel Process and Autorun is just the Loop Event with some tweaks and GUI Setup. Parallel Process is the Loop event that lets you still use your hero, and Autorun does not. The loop is broken by moving to a new page number.

Eventing is Scripting


" What?! Ludicrous! I can't script." You might say. Well, maybe I'm exaggerating a little here. Eventing is psuedo scripting. All those events you made, they're turned into script by the game. All you're doing is taking blocks of script that do certain things and putting them in via the events menu. The engine does the hard stuff for you.

But scripting is a lot of what you've already learned. Variables, Booleans, Loops, Ifs (Conditional Branch). Those are what compose the start of scripting. If you start to master these concepts, scripting may just be up your alley.

This post has been edited by Titanhex: Aug 8 2011, 01:38 PM


__________________________
Go to the top of the page
 
+Quote Post
   
Titanhex
post Jul 5 2011, 10:57 PM
Post #2


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




Wanted to add this is my first tutorial for RPG Maker. Is there any Comments on the content here that may help be improve? Things not explained clearly enough, over-explained, redundancy, or misinformation? Perhaps topics that could use more probing? Requests for information?

Was this guide useful when you read it, or do you feel you know this already?

=================If you wish to reply, please skip to the last post in the thread.
=================The exception would be if you think you can handle very advanced
=================variable and switch uses, as posts 3-11 cover advanced uses.

This post has been edited by Titanhex: Aug 8 2011, 01:36 PM


__________________________
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Jul 6 2011, 06:19 AM
Post #3


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




I'd say this tutorial was very useful for the new RM-er, as well as for some novice and even intermediate. I laughed at how true the final statement is, coding is really actually so easy, but people are scared of the 'mass amounts of typing' I think. But once you actually sit down and check into it, it can be great fun.
Eventing, and scripting, and coding, they're all pretty much the same, only two things differ, and that's the syntax, and what you can do with it. once you learn the syntax, you're pretty much good to go.

In regards to a few things in your tutorial, I personally like to consider common events as like global events, much like the difference with local and global variables.

For using variables as switches, I think its a good method. Another more advanced way to do this (although it yields more switches) would be to make use of the fact that variables are 7 digits long (about 7, right?) and since switches are always 1 or 0, on or off, yes or no, true or false, you can make use of that, suppose you had variable N which was 1100010, you can separate that into 7 switches, three being on, 4 off. The way to do that is take variable N and mod it, it's been a while since I've done that, so if I tried explaining how, I'd probably get it wrong XP.

Regarding loops and waits, yes this is so true, its always wise to put a 1 frame wait in a loop, or at the beginning of an autorun/parallel process event, I think they're more widely known as throttles or throttle pauses, thats what they used to be called in the good ol' days of RM2k/3. XD

Anyway, great tutorial.



__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Titanhex
post Jul 6 2011, 12:25 PM
Post #4


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




Thank you for bringing that snippet up about common events. I threw in a credit to you and added it along with some other information on Common Events.

I vaguely understand what you're saying about the variables. Unfortunately the only use I can think of for that is in some sort of Code Generator for storing and recalling information. It's such a special case, I probably won't add it, unless you have a common use for that method.

I appreciate the feedback too, you've definitely helped improve this tutorial smile.gif

I may add a demo and create new tutorial posts that will link to and from this one to create an indepth guide.


__________________________
Go to the top of the page
 
+Quote Post
   
Kazesui
post Jul 6 2011, 12:55 PM
Post #5


Level 9
Group Icon

Group: Revolutionary
Posts: 141
Type: Event Designer
RM Skill: Advanced




QUOTE (Night5h4d3 @ Jul 6 2011, 04:19 PM) *
For using variables as switches, I think its a good method. Another more advanced way to do this (although it yields more switches) would be to make use of the fact that variables are 7 digits long (about 7, right?) and since switches are always 1 or 0, on or off, yes or no, true or false, you can make use of that, suppose you had variable N which was 1100010, you can separate that into 7 switches, three being on, 4 off. The way to do that is take variable N and mod it, it's been a while since I've done that, so if I tried explaining how, I'd probably get it wrong XP.


If you're going with a more advance solution you might as well choose the method which allows you to compress as many as 24 switches into one variable, by letting the switches form a binary number and converting it into base 10 for variable storage, and afterwards back from base 10 to a binary number consisting by the switches you want to use (easier to code than it might sound).

A common use for it would be to use a set of switches as "local switches" which you store into variables specific for the current area. Allows you to reuse switches for stuff like chests without having to relocate more space for new switches for every new area you make.
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Jul 6 2011, 01:06 PM
Post #6


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




I think I get what you mean, like have your set of 24 switches: 1111 1111 1111 1111 1111 1111, and swapping from binary to decimal that number becomes 16777215, and storing that in your variable instead, right? That's probably a better way that mine, but eventing a way to change that back into 24 switch values is the tedious work, not only do you have to re-convert it into binary, you also need to mod the variable, which is in short, what my method does.

It'd be more practical if you were using RMXP or VX where you could use a script to calculate that. But if you did, you may as well just store all your extra switch values in a global array, like $game_switches is.


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Kazesui
post Jul 6 2011, 01:14 PM
Post #7


Level 9
Group Icon

Group: Revolutionary
Posts: 141
Type: Event Designer
RM Skill: Advanced




Your general idea is correct, apart from the last switch being decided by the sign, since 2^23 is the highest you can go without blowing the absolute number limit.

QUOTE (Night5h4d3 @ Jul 6 2011, 11:06 PM) *
That's probably a better way that mine, but eventing a way to change that back into 24 switch values is the tedious work




I don't think this looks very tedious (though this solution doesn't account for the sign bit, which is possible to include with a few more lines of code)
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Jul 6 2011, 01:23 PM
Post #8


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




You're right, that does look simple, I should totally work more in eventing. And at 3 variables for 23 switches, that does beat my method, which would be 3 variables for 21 switches.


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Kazesui
post Jul 6 2011, 01:48 PM
Post #9


Level 9
Group Icon

Group: Revolutionary
Posts: 141
Type: Event Designer
RM Skill: Advanced




Well, technically, you'd need an extra variable as well for your method. You'd need a variable to hold the value of the digit you're trying to get to determine whether is 1 or 0. If not you'd end up destroying the original value before you could set all switches.
So your solution creates space for 7n switches for n + 1 variables, while mine creates space for 23n switches for n + 4 variables (you missed a few). This means that I could get space for 138 switches with 10 variables while your solution would only get 63.
Either way, one doesn't really have to conserve variables that tightly since you can access 9,999,999 of them with the use of pointers anyway, and I have problems seeing anyone use that many variables without doing some severely bad coding.

This is also disregarding that these temporary variables are only temporary, and can be used for other calculations later on as well.
But just to have said it though, your proposed solution isn't without merit, as it's probably easier to understand, especially for people who doesn't know anything about binary numbers and how to convert between different bases.

And yeah, you should play more around with eventing, because this is the kind of things that are fun
Go to the top of the page
 
+Quote Post
   
lilcooldude69
post Jul 31 2011, 12:28 AM
Post #10


The pro-est eventer u know ;D
Group Icon

Group: Revolutionary
Posts: 297
Type: Event Designer
RM Skill: Masterful




on a 2nd note about using rpg maker vx, help with debugging, if your using the run game command from the rpg maker vx editor program, you can press f9 during in game, and u can turn switches on and off, and change variables from that menu as well as check what the numbers are...idk if you said that in ur post or if somone else said it i was just putting my 2 cents in :X

This post has been edited by lilcooldude69: Jul 31 2011, 12:28 AM


__________________________

My Userbars


Rated pg-13 part of signiture
Scientist A: "A single sperm has 37.5MB of DNA information in it. That means a normal ejaculation represents a data transfer of 1,587.5TB."
Scientist B: Too bad ejaculate has terrible packet loss
Scientist C:but the transfer does have a lot of redundancy

Go to the top of the page
 
+Quote Post
   
Vanit
post Jul 31 2011, 07:52 AM
Post #11


Level 15
Group Icon

Group: Revolutionary
Posts: 291
Type: Developer
RM Skill: Undisclosed




I'm glad that this thread has touched on composite variables a little bit, but I don't think its really been fleshed out about why you'd do this and when it'd be useful. There are 2 main applications of composite variables (that is, variables that hold multiple "meanings"): you can either use them to have many switches in one place, or the same with many variables. Its difficult to describe when these are useful, but I think it may be educational to describe the uses I found for them.

Many switches in a variable + pic pointer patch = the holy jebus of efficiency

One of the problems I faced in the FF72DR battle system was that in the menu each spell could have many combined states, and since I had to show all these combinations with only 1 picture allocated per spell on the page, it was difficult to do dynamically. The spells can sometimes have All materia attached to them, which puts a red triangle next to them, and the character may not have enough mana, so the text may be greyed out, or it may be white if they have enough. I think immediately you might see the issue here, I'd need basically 3 IF conditions for all 30 spells... which isn't pretty (90 IF conditions), and its pretty slow too. The solution I came up with only needed 3 IF conditions for the ENTIRE set. I used a variable to represent the combined states in the format XXYZ, XX is a 2 digit ID code for what spell it is, Y is 1 if there is All materia, 0 if not, and Z is 1 if theres enough mana, and 0 if not. So for example 3011 might be Lightning (ID 30), 1 for All, and 1 for has enough mana. So then using the pic pointer patch I'd call Spell_3011.png, which represents that exact state, and I was able to call it dynamically in only 1 picture, with only 3 IF conditions and 1 Show Picture call for the entire set. Pretty clever. smile.gif

Representing meaningfully combined values in a single variable

I touched on this a little bit at the end of the first section, where I meaningfully combined an ID and 2 switches to call a picture that represented 1 state. But this can be used in other ways too. For example in the FF72DR menu system I had to tackle the issue of how I paired materia together. The way the battle system works is that in order to increase the speed of calculations during battle, all the materia and such is preprocessed before battle to tell you all the spells you have and how they're linked etc. Each materia in my system has a 2 digit ID code, and then when I'm pairing them they are joined into one variable as WWXYYZ, where WW is the first materia ID and X is its rank, and YY is the second materia's ID and Z is its rank. Then I will parse all these meaningfully linked values to generate the outputs about how they're linked. For example 303012 might be a Cure rank 3 (30-3) paired with an All rank 2 (01-2), the parser would break these apart and then activate the necessary cure spells and then give them an ID of the All materia they're linked to. This would be MUCH more difficult to do otherwise.

So, hopefully this will get some of you thinking about other applications. smile.gif


__________________________
Go to the top of the page
 
+Quote Post
   
neiljwd
post Aug 8 2011, 10:51 AM
Post #12


Level 5
Group Icon

Group: Member
Posts: 69
Type: None
RM Skill: Undisclosed




Tutorial is great, aimed exactly at my current level.
All the posts below it, are a step beyond that though.
Kinda goes over ones head to be discussing those points on a page that's JUST fleshed out intermediate skills.
Kinda detract from the tutorial I feel, making it all seem too overwhelming. Where as the tutorial itself is spot on.
Only thing that it could benefit from is screenshots. Fine without them, just pictures and highlights are always good aides smile.gif


__________________________
If you help me I'll pray for you^^.
Go to the top of the page
 
+Quote Post
   
Titanhex
post Aug 8 2011, 01:28 PM
Post #13


Guru of Water
Group Icon

Group: Revolutionary
Posts: 1,096
Type: None
RM Skill: Masterful
Rev Points: 5




I'll definitely look into where pictures would be good for the tutorial.

Glad it was helpful.

I agree though, the discussions after the tutorial are for advanced users. Since this is a tutorial aimed at getting people out of that inefficiency you bring with you from reading beginner tutorials, the advanced stuff detracts and overwhelms. It's a few steps above. I'll put a disclaimer beneath my original post.

The F9 debug feature is nifty. It seems appropriate for the post, which makes me wonder why I left it out. Thanks lilcooldude.

This post has been edited by Titanhex: Aug 8 2011, 01:40 PM


__________________________
Go to the top of the page
 
+Quote Post
   
BigEd781
post Aug 8 2011, 03:20 PM
Post #14


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




QUOTE (Kazesui @ Jul 6 2011, 02:14 PM) *
Your general idea is correct, apart from the last switch being decided by the sign, since 2^23 is the highest you can go without blowing the absolute number limit.

QUOTE (Night5h4d3 @ Jul 6 2011, 11:06 PM) *
That's probably a better way that mine, but eventing a way to change that back into 24 switch values is the tedious work


I don't think this looks very tedious (though this solution doesn't account for the sign bit, which is possible to include with a few more lines of code)


This is wrong and I have seen a bit more misinformation here, so I thought I would chime in. In Ruby complexity like this is hidden from you, and even in a statically typed language on most platforms an int will be 32 bits, i.e., 2^31 possible combinations, losing one power of two to store the sign bit. If the type is unsigned than you can use the full 32-bit range. I don't know where you got 2^23 from, but that is incorrect.

With Ruby you don't need to worry about any of that because the standard library allows for arbitrarily sized numbers, and you certainly would not have to convert from decimal to binary and back.

All numbers in a computer are stored in binary, decimal is just another way of presenting it. The difference is meaningless in terms of operations performed on these numbers. In other words, the following to expressions will always yield the same result as the computer doesn't care how the number is being displayed.

CODE
(decimal)
5 & 1
=> 1

(binary)
101 & 1
=> 1


Same exact thing.

This post has been edited by BigEd781: Aug 9 2011, 12:52 PM


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
Vanit
post Aug 11 2011, 07:57 PM
Post #15


Level 15
Group Icon

Group: Revolutionary
Posts: 291
Type: Developer
RM Skill: Undisclosed




QUOTE (BigEd781 @ Aug 9 2011, 09:20 AM) *
QUOTE (Kazesui @ Jul 6 2011, 02:14 PM) *
Your general idea is correct, apart from the last switch being decided by the sign, since 2^23 is the highest you can go without blowing the absolute number limit.

QUOTE (Night5h4d3 @ Jul 6 2011, 11:06 PM) *
That's probably a better way that mine, but eventing a way to change that back into 24 switch values is the tedious work


I don't think this looks very tedious (though this solution doesn't account for the sign bit, which is possible to include with a few more lines of code)


This is wrong and I have seen a bit more misinformation here, so I thought I would chime in. In Ruby complexity like this is hidden from you, and even in a statically typed language on most platforms an int will be 32 bits, i.e., 2^31 possible combinations, losing one power of two to store the sign bit. If the type is unsigned than you can use the full 32-bit range. I don't know where you got 2^23 from, but that is incorrect.

With Ruby you don't need to worry about any of that because the standard library allows for arbitrarily sized numbers, and you certainly would not have to convert from decimal to binary and back.

All numbers in a computer are stored in binary, decimal is just another way of presenting it. The difference is meaningless in terms of operations performed on these numbers. In other words, the following to expressions will always yield the same result as the computer doesn't care how the number is being displayed.

CODE
(decimal)
5 & 1
=> 1

(binary)
101 & 1
=> 1


Same exact thing.

I think you have completely misunderstood. We're not talking about computers, we're talking about RPG Maker where variables cap out at 7 digits, which is effectively 24bits (plus a sign, taking you up to 25). Because the number types are abstracted away from the user in RGSS, if you want to store a conceptually binary number, its still stored as a decimal, meaning you have less bits to work with in the number. To overcome this problem with composite variables you could store the binary number in its decimal form, and then convert it back when you need to extract the values of various bits - getting you 24-25 bits instead of 7-8. The ramifications would be hideous, but yeah.


__________________________
Go to the top of the page
 
+Quote Post
   
BigEd781
post Aug 12 2011, 09:00 AM
Post #16


No method: 'stupid_title' found for `nil:NilClass'
Group Icon

Group: Revolutionary
Posts: 1,829
Type: Scripter
RM Skill: Undisclosed




QUOTE (Vanit @ Aug 11 2011, 08:57 PM) *
I think you have completely misunderstood. We're not talking about computers, we're talking about RPG Maker where variables cap out at 7 digits, which is effectively 24bits (plus a sign, taking you up to 25). Because the number types are abstracted away from the user in RGSS, if you want to store a conceptually binary number, its still stored as a decimal, meaning you have less bits to work with in the number. To overcome this problem with composite variables you could store the binary number in its decimal form, and then convert it back when you need to extract the values of various bits - getting you 24-25 bits instead of 7-8. The ramifications would be hideous, but yeah.


And again, that is incorrect.

1. Variables are not capped. They are simply Ruby variables and you can assign them via a Script... event command if needed. The editor may impose limitations, but if we're talking about bit twiddling than I am pretty sure we all know how to get around them.
2. No numbers are "stored as decimal" in a computer. They are *displayed* as decimal, which makes absolutely no difference when you're talking about bitwise operations. A number is a number is a number, no matter how you represent it. You *never* have to convert from one base to another to perform operations. This is basic number theory, this conversion stuff is nonsense.

This post has been edited by BigEd781: Aug 12 2011, 09:09 AM


__________________________
`
Give me teh codez!!!


I am the master debator!
Go to the top of the page
 
+Quote Post
   
Vanit
post Aug 12 2011, 04:03 PM
Post #17


Level 15
Group Icon

Group: Revolutionary
Posts: 291
Type: Developer
RM Skill: Undisclosed




Again, you completely misunderstood. Obviously in computer memory all data is stored as binary at the lowest level. I personally don't use XP/VX/RGSS so if it has actual bitwise operators then yes, they'd work on any number.

What I'm saying is that if you go 'number = 10101010', in memory its actually 100110100010000100010010, because even though the text representation looked like binary, it was actually decimal.


__________________________
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Aug 12 2011, 11:26 PM
Post #18


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




I think you're the one misunderstanding here, Vanit. ^^

In RPG Maker XP and VX, variables are Ruby objects. On the most fundamental level, they are just binary sequences, but they aren't stored as decimal numbers, ever. They are displayed as decimal, and the conversion is actually done dynamically at runtime. Meaning, you can perform bitwise operations (and Ruby does have bitwise operators) on them - manual conversion is completely useless.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Vanit
post Aug 12 2011, 11:35 PM
Post #19


Level 15
Group Icon

Group: Revolutionary
Posts: 291
Type: Developer
RM Skill: Undisclosed




Ahh, so there it is. smile.gif I tried to look up if something like that was happening (I wasn't sure what the deal was with the abstraction), and when I found nothing I assumed it was abstracted like rm2k3.

Reading the thread it seemed like we were talking about eventing, and there was no real mention of this being done in scripts until BigEd himself explicity mentioned Ruby. But if that is infact what we're talking about I stand corrected, despite the thread not mentioning that, and the only screenshots being of an event.


__________________________
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Aug 12 2011, 11:55 PM
Post #20


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




In XP/VX, events merely invoke methods found in the scripts data and pass arguments. While bitwise operators are absent from the graphic interface, they do exist and are even callable inside an event via the Call Script event command. Regular switches and variables are stored as Ruby objects so they're not different from a more custom object created by the user in the script editor.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   

2 Pages V   1 2 >
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: 20th May 2013 - 07:36 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker