Charas-Project

  • Home
  • Help
  • Search
  • Calendar
  • Login
  • Register
*
Please login or register.

Login with username, password and session length
 

News:

Click here to join us on IRC (#charas on irc.freenode.net)!



  • Charas-Project »
  • Off-Topic »
  • All of all! »
  • Algorithm, Ruby, and MOD...
« previous next »
  • Print
Pages: [1]

Author Topic: Algorithm, Ruby, and MOD...  (Read 1843 times)

Offline drenrin2120

  • Global Moderator
  • Sage
  • *
  • Posts: 6,101
Algorithm, Ruby, and MOD...
« on: May 12, 2006, 07:30:10 PM »
Some questions I'd like to discuss and maybe find some answers to.

First off:
    Does anyone know typical Battle Algorithm? (Lookin for you on this one DB ;) )


Second off:
    Can someone help me with Ruby? Maybe a link to a site explaining the language.


Thirdly:
    Mod. I once knew this and I know it seperates a number's digits. How does it work, again?


If it hasn't become obvious yet, I want to make a CBS in RMXP. I've had some experience and the possibilities with RMXP are pretty much limitless, I would really like to learn Ruby and do this.
Logged

Offline coasterkrazy

  • June 2005 - September 2008... January 2011?
  • Exemplar
  • *
  • Posts: 1,915
  • Hello...
(No subject)
« Reply #1 on: May 12, 2006, 07:49:28 PM »
In response to thirdly:

I PM'd DB about this once a while back, and he gave me the whole thing. Just so no one has to go through the trouble of reposting it, I'll copy it from the the PM. Good thing I saved it!

Quote
DB
- Anyway, make a common event, make it parallel process, and if you turn on a switch when you go into the menu system, set that as the trigger switch.
- Set a variable [hp] to the hero's hp.
- Set a variable [hp 1 digit] to [hp]
- Set a varaible [hp 10 digit] to [hp]
- Set a varaible [hp 100 digit] to [hp]
- Set a variable [hp 1000 digit] to [hp]
- Select [hp 100 digit], select the operation MOD, and enter in a value of 1000
- Select [hp 10 digit], select the operation MOD, and enter in a value of 100
- Select [hp 1 digit], select the operation MOD, and enter in a value of 10
- Select [hp 1000 digit], select the operation SUBTRACT, use the variable referance of [hp 100 digit]
- Select [hp 100 digit]. select the operation SUBTRACT, use the variable reference of [hp 10 digit]
- Select [hp 10 digit], select the operation SUBTRACT, use the variable reference of [hp 1 digit]
- Divide [hp 1000] by 1000
- Divide [hp 100] by 100
- Divide [hp 10] by 10

Thats it

You'll have to make (copy) this event for every value you wish to split, I sugest putting them all in the same common event though to save space.

Just in case you were confused on what that did, lets say the value was 2356, you would now have four variables. [hp 1000 digit] would be 2, [hp 100 digit] would be 3, [hp 10 digit] would be 5, and [hp 1 digit] would be 6.

Hoped that helped If you have any other questions, feel free to ask.
Logged

Offline drenrin2120

  • Global Moderator
  • Sage
  • *
  • Posts: 6,101
(No subject)
« Reply #2 on: May 12, 2006, 07:52:20 PM »
Thanks CK, that helped a lot.

EDIT: Oh, annex the first question about algorithm, I found a great list.

EDIT2: How do I make a variable show up in a text? Like, in rm2k3 it's [/v#] so what is it in RMXP?
Logged

Offline DragonBlaze

  • A Wild DB Appeared!
  • Royal
  • *
  • Posts: 3,329
(No subject)
« Reply #3 on: May 12, 2006, 08:45:36 PM »
*Sigh* I wasn't even able to help out :p

Anyway, if you're making a cbs in rmxp, you won't need to know how to split the digits. Its not like in rm2k3 where you have to use pictures to display health and such, you can just use the variables to display it on the screen. Unless you want to use pictures anyway for an added effect or something.
 
Oh, and if the MOD features is confusing, theres a much much easier way of doing it, at least with rm2k3 there is, I don't know if it'll work in rmxp. But anyway, variables in rm2k3 can't be decimal numbers. So if you would have 1234 as HP, you could just divide it by 1000 to get the thousand digit, divide it by 100 to get the hundred digit, etc. Even if you're number is 9999, it'll be 9.999, and since it can't be a decimal number, everything after the decimal will just be thrown out, leaving you with a 9. I would assume the same thing would be true with the event editor in rmxp. However, if you're doing it through ruby, I doubt the decimals will be thrown away. So its probably safter to use the MOD option.

I can give you some basic info on ruby, but your best bet would be to just search google for some tutorials.

Ok, first off, every script starts with 'class "name"' where name is the name of the script. You can also have 'class "name1" < "name2"' where name 2 is the script name, and name1 would be the parents name. Basically the class shows the start of the program, at the end of the program, you need to type end for it to know where the end is.

Now each seperate section of the code also has names and it needs to be defined. So you put def 'name' Again, you need to put end after each section to let the program know where the section ends.

Like in rm2k3, there are variables, but besides just numbers, variables can hold letters and such. A regular variable is just like 'name', you can set it equal to a number, a variable, or an expression. So you could use:
hp = 1000
hp = hero.hp
hp = 10 + hero.hp

If you want the variable to hold characters, you have to use "$name". So for example, $name = "bob", you can also use $name = $hero.name. However, you CAN'T set a character variable equal to a numeric variable or visa versa. I'm not sure about ruby, but most programming languages require the characters to be enclosed in " ", so I'm guessing its like that in ruby, or it may be ' ', I'm not sure.

Another variable type is @name. I'm not exactly sure the differance between that and the numeric type, but its there.

Ok, another thing you should know about is conditional branches. Its basically the same as in the evend database, you would type:

if var == 0 (note 2 equal signs)
  Expresion
end

You don't have to use == though, you can use >, <, <=, >=, and !=. The != stands for not equal to. I think you can put the ! in front of any expresion to make it not the expresion.

I'm guessing you can also use elses.

if var > 0
 hero.alive = 1
else
 hero.alive = 0
end

Another type of conditional branch is the case branch. This is useful when comparing a lot of differant outcomes.

case name (where name is the variable name
when 1
var = 1
when 2
var = 2
when 3
var = 3
end

(note, in a situation like this, it would be easier to just set teh var = to name :p)

Ok, and last thing for now, if you want to jump to a differant scene or script, you use the command
$scene = scene_name.new

Thats about all I know of ruby. I never tried any of it out :p I just compared it to C++ and Basic and thats what those commands seemed to do :p Anyway, I don't know if that was helpful at all, but good luck learning ruby :)
Logged
Hell Yeah! Just recovered all my old rm2k/3 games from my 10 year old, broken laptop hard drive that had been formatted and had a new OS installed on it. Oh, and I did all of this from my phone. WIN

Offline drenrin2120

  • Global Moderator
  • Sage
  • *
  • Posts: 6,101
(No subject)
« Reply #4 on: May 13, 2006, 08:13:05 PM »
Old Post: lol, thanks a bunch DB, it helped immensely. I'll find a site about Ruby and stufy it. But that was a great way to start off. Thanks man!

NEW Post: Does anyone know how to identify what pisition in the party a character is? This would be much appreciated.
Logged

  • Print
Pages: [1]
« previous next »
  • Charas-Project »
  • Off-Topic »
  • All of all! »
  • Algorithm, Ruby, and MOD...
 

  • SMF 2.0.10 | SMF © 2015, Simple Machines
  • XHTML
  • 2O11
  • RSS
  • WAP2
  • Simple Machines Forum