General RGSS/RGSS2/RGSS3 Help

Started by G_G, March 04, 2009, 12:14:28 am

Previous topic - Next topic

Aqua

It's .ceil

Don't you know what absolute value is? O.o
It'll return the positive value of a number... in simplest terms :P

Ryex


(1).abs     #1
(-1).abs    #1
(10).abs    #0
(-10).abs   #10

the absolute value of X (or |X|) is simply the positive distance from 0 on the number line
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

G_G

Quick file question.
I'm using this to read all lines from a text file.
lines = []
file = File.open('Data.txt')
file.each_line{|line| lines.push(line)
file.close
for i in lines
 p i
end


Which works and prints all 5 lines. Except the first 4 lines print the line plus \n. Anyway to remove this?

I also did another test with it with integers.
lines = []
file = File.open('Data.txt')
file.each_line{|line| lines.push(line.to_i)
file.close
for i in lines
 p i
end


And this time it just printed the numbers with no \n. Any idea?

Ryex

\n is the new line char. try using gsub! to remove it
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

file = File.open('Data.txt', 'r')
lines = file.readlines
file.close
lines.each {|line| p line}


:)
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Both ways worked. xD

However blizz is the simplest. I'm gonna have to go with his. However *double level's up*

fugibo

There's also

s.chomp! # removes whitespace at end of string

Blizzard

lstrip / rstrip / strip can be useful as well. :3 I'm just not sure if they are named the same in Ruby as in other languages.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

nathmatt

February 20, 2010, 12:41:19 pm #408 Last Edit: February 21, 2010, 05:40:51 pm by nathmatt
ok im trying to make a small script def that you will give it the current exp of a passive type skill and will return the lvl and exp needed i baes my code off this
Quote from: Jackolas on October 22, 2009, 04:46:33 am
Harder than I thought it was gone be :^_^':
best i could do i a short time.

To calculate exp needed to lvl:
L= LVL
B= Base
I= Inflation
E= EXP

E = B * ((L + 4) ^ (2,4 + I / 100)) / (5 ^ (2,4 + I / 100))

so the exp needed from lvl 5-6 when base and inflation are both 10 is:
10*((5+4)^(2,4+10/100))/(5^(2,4+10/100)) = 56,56854
looking in the rmxp actor exp table it says 56

yes i know they are a litle bid off...
but i think that RMXP is not calculating with numbers behind the ,
so it will always round the numbers down

im getting a syntax error on this  @e = 25 * ((lvl + 4) ^ (2,4 + 35 / 100)) / (5 ^ (2,4 + 35 / 100))
  def get_lvl(lvl,exp,expneeded)
   @e = 25 * ((lvl + 4) ^ (2,4 + 35 / 100)) / (5 ^ (2,4 + 35 / 100))
   if exp >= @e
     lvl += 1
   end
   expneeded = @e - exp
   return lvl,expneeded
 end

Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Blizzard

In programming you never use a decimal comma. You ALWAYS use a decimal dot.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

fugibo

Quote from: Champion Blizzard on February 22, 2010, 02:36:44 am
In programming you never use a decimal comma. You ALWAYS use a decimal dot.


silly europeans, not following america's vastly superior lead :V

Trainer Zydragon

I dont see the logic in a decimal comma, surely thats only meant to be used for thousands and millions like 9,999,999... The people like us 'silly europeans' would be confused when you say 9,999 is actually 9.999  :haha:

nathmatt

February 22, 2010, 10:25:55 am #412 Last Edit: February 22, 2010, 12:10:42 pm by nathmatt
k fixed that but now im having another problem the lvl is increasing to much when lvl 1 you need 25 exp but when i make exp 25 the lvl goes up to 5 & expneeded  goes to 10

edit got it to work

class Bitmap
 
  def get_lvl(exp,x,y)
    lvl = 1
    while exp >= get_exp_list(lvl)
      lvl += 1
    end
    slvl = lvl - 1
    expneeded = get_exp_list(lvl) - exp
    self.draw_text(x, y, 120, 32, slvl.to_s)
    self.draw_text(x, y+32, 120, 32, exp.to_s+'/'+get_exp_list(lvl).to_s)
  end
  def get_exp_list(lvl)
    @exp_list = Array.new(101)
    @exp_list[1] = 0
    pow_i = 2.4 + 35 / 100.0
    for i in 2..100
      if i > 99
        @exp_list[i] = 0
      else
        n = 25 * ((i + 3) ** pow_i) / (5 ** pow_i)
        @exp_list[i] = @exp_list[i-1] + Integer(n)
      end
    end
    return @exp_list[lvl]
  end
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


fugibo

February 22, 2010, 10:33:27 am #413 Last Edit: February 22, 2010, 10:36:11 am by fugo ad te, pikachu!
Quote from: Zydragon on February 22, 2010, 09:38:58 am
I dont see the logic in a decimal comma, surely thats only meant to be used for thousands and millions like 9,999,999... The people like us 'silly europeans' would be confused when you say 9,999 is actually 9.999  :haha:


For writing, I stand by this as the proper form:
Quote
1 234 567.89

which should read as one-million, two-hundred and thirty-four thousand, five-hundred and sixty-seven and eighty-nine hundredths.

Trainer Zydragon

Quote from: fugo ad te, pikachu! on February 22, 2010, 10:33:27 am
Quote from: Zydragon on February 22, 2010, 09:38:58 am
I dont see the logic in a decimal comma, surely thats only meant to be used for thousands and millions like 9,999,999... The people like us 'silly europeans' would be confused when you say 9,999 is actually 9.999  :haha:


For writing, I stand by this as the proper form:
Quote
1 234 567.89

which should read as one-million, two-hundred and thirty-four thousand, five-hundred and sixty-seven and eighty-nine hundredths.


See us British would write that as 1,234,567.89 :)

fugibo

Quote from: Zydragon on February 22, 2010, 11:03:04 am
Quote from: fugo ad te, pikachu! on February 22, 2010, 10:33:27 am
Quote from: Zydragon on February 22, 2010, 09:38:58 am
I dont see the logic in a decimal comma, surely thats only meant to be used for thousands and millions like 9,999,999... The people like us 'silly europeans' would be confused when you say 9,999 is actually 9.999  :haha:


For writing, I stand by this as the proper form:
Quote
1 234 567.89

which should read as one-million, two-hundred and thirty-four thousand, five-hundred and sixty-seven and eighty-nine hundredths.


See us British would write that as 1,234,567.89 :)


I'm American. We do, too. I prefer 1 234 567.89, though. The commas are used for readability. Spaces work just as well.

nathmatt

ok im any help on the most effective way to make passive type (mining,fishing,etc... )skills i thought about sort of a copy of game actor but not sure 
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Blizzard

Quote from: fugo ad te, pikachu! on February 22, 2010, 09:27:39 am
Quote from: Champion Blizzard on February 22, 2010, 02:36:44 am
In programming you never use a decimal comma. You ALWAYS use a decimal dot.


silly europeans, not following america's vastly superior lead :V


Lulz
That's because you had the first computers and you said it's gonna be a dot. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Zeriab

February 23, 2010, 07:05:37 am #418 Last Edit: February 23, 2010, 07:10:22 am by Zeriab
Quote from: Champion Blizzard on February 19, 2010, 02:42:05 am
file = File.open('Data.txt', 'r')
lines = file.readlines
file.close
lines.each {|line| p line}


:)


I suggest using a block since File provides error handling in that case. It for example ensures that the file stream will be closed.
File.open('Data.txt', 'r') {|file|
 lines = file.readlines
 lines.each {|line| p line}
}


*hugs*

Blizzard

I prefer begin-rescue blocks since you can catch the error. :3
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.