Jump to content


Photo

Ruby/RGSS3 questions that don't deserve their own thread


  • Please log in to reply
839 replies to this topic

#821 estriole

estriole

    Advanced Member

  • Members
  • 993 posts
  • RM Skill - Coder

Posted 02 May 2013 - 07:52 PM

ah thx. not at my computer with ace so i cannot look at the code. that indeed helpful. btw... can we do this?

1) we define method in kernel (for example the method contain $game_variables[x] += 1)

2) can we call that method using Kernal.eval(method_name)?



#822 Tsukihime

Tsukihime

    Advanced Member

  • Members
  • 5,015 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 02 May 2013 - 08:18 PM

You can define it in BasicObject, Object, Kernel, ... basically almost anywhere.

#823 AJNR

AJNR

    Infrequent Visitor

  • Members
  • 68 posts
  • LocationNew York
  • RM Skill - Artist

Posted 06 May 2013 - 02:14 PM

Does RPG Maker's Skill Box always turn a number into an Integer? Is there a way to force it to not become an integer?

Such as the opposite of ".to_i"?

 

Because when I set a Skill's Damage to "100 + (a.atk / b.def)" it will make the number created from a.atk/b.def into an integer.

Any decimal above 1.00 and equal to or lower than 1.99 will be rounded to 1, dealing 100 Damage. And 2.00 - 2.99 equals 200 Damage, etc etc.

 

It would be nice to know the method to keep the created number a Decimal, like the way you force an Integer.

Something like: "100 + (a.atk / b.def).to_d" so that when an Atk of 84 clashes with a Def of 72, the dividend will become 1.166666666666667 and the Damage will equal 116 - instead of 100.

 

If this requires a whole script to make happen, just tell me and disregard it.



#824 Tsukihime

Tsukihime

    Advanced Member

  • Members
  • 5,015 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 06 May 2013 - 02:47 PM

It's turned into an integer when you actual apply the damage value, not when you're evaluating it.
a.atk / (b.def.to_f)
One of them needs to be a float otherwise you're going to get integer division.

#825 AJNR

AJNR

    Infrequent Visitor

  • Members
  • 68 posts
  • LocationNew York
  • RM Skill - Artist

Posted 06 May 2013 - 08:45 PM

This is exactly what I wanted. Thank you Tsukihime.

This will fulfill my fetish for division and fractions in my games.  :D



#826 HellKiteChaoS

HellKiteChaoS

    1.21 Gigawatts!

  • Members
  • 161 posts
  • RM Skill - Jack of All Trades

Posted 07 May 2013 - 08:05 AM

Greetings! Quick question for everyone...

 

I'm starting to dabble with gauges with the script I'm writing. is there a way to use the draw gauge function but make the gauge fill from the right to left, instead of the default left to right?


Demo Progress: 

Under Re-Construction

 

 

Like my project and would like to show your support? Simply place this in your signature! =D

 

YBLl8.png

 

 

What I support ^.^

 

Spoiler

#827 Matt_Sully(Gump)

Matt_Sully(Gump)

    Advanced Member

  • Members
  • 55 posts
  • LocationCanada
  • RM Skill - Coder

Posted 09 May 2013 - 12:17 PM

Greetings! Quick question for everyone...

 

I'm starting to dabble with gauges with the script I'm writing. is there a way to use the draw gauge function but make the gauge fill from the right to left, instead of the default left to right?

This will require modification of the draw_gauge method, but I would suggest copypaste and renaming to make it a new method.

 

here is the origonal:

 

def draw_gauge(x, y, width, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8
    contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
    contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
  end

 

I was trying to figure out how to modify it to make it do what you want but its not as easy as I thought -- at least not for me. Hmm...

 

Edit: Untested, this probably wont work, just an idea really:

 

 

def draw_reverse_gauge(x, y, width, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8
    contents.fill_rect(x+width, gauge_y, width, 6, gauge_back_color)
    contents.gradient_fill_rect(x+width, gauge_y, fill_w, 6, color1, color2)
  end

 

If that doesn't work, apologies... Come to think of it it will probably just start filling the gauge at the end of the gauge and beyond.

 

Actually kind of tricky to get it to fill back. Might be better off writing a new method.

 

I'm sure someone has a simple solution that will make me feel dumb lol :)

 

Your question (in my opinion) deserves its own thread though.


Edited by Matt_Sully(Gump), 09 May 2013 - 12:19 PM.

Did something I do help you? Please hit the Like button on the post that helped you! Thanks!

 

Known as "Mattdk" on rpgmaker.net. Submissions page: http://rpgmaker.net/...dk/submissions/

 

Site: GumpScripts (wordpress blog)


VX Ace Scripter
Released Scripts/Systems: 


#828 HellKiteChaoS

HellKiteChaoS

    1.21 Gigawatts!

  • Members
  • 161 posts
  • RM Skill - Jack of All Trades

Posted 10 May 2013 - 02:37 PM

After asking around my work office we came up with the answer, or at least it works for what I'm trying to do. The code looks as follows...

 

Thanks for helping me in the right direction though Matt =)

 

  def draw_gauge_neg(x, y, width, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8
    contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
    contents.gradient_fill_rect(x - (width - (width * (1 - rate))), gauge_y, fill_w, 6, color1, color2)
  end

Demo Progress: 

Under Re-Construction

 

 

Like my project and would like to show your support? Simply place this in your signature! =D

 

YBLl8.png

 

 

What I support ^.^

 

Spoiler

#829 Ebonflame

Ebonflame

    Advanced Member

  • Members
  • 41 posts

Posted 11 May 2013 - 01:21 AM

[deleted because I found the problem and fixed it... can't believe it took me five days to really understand create_contents]


Edited by Ebonflame, 12 May 2013 - 02:54 PM.

KISS: Keep It Simple, Silly

- If you want me to practice my KISSing skills, tell me!

 

v8 slap: A facepalm to the forehead. 

- You may not have seen the commercial, but there's a mom that's offering her baby a fry, and the baby smacks her on the forehead... then it cuts to a picture of a v8 bottle while the narrator says, "You coulda had a v8!"


#830 Jonnie19

Jonnie19

    Advanced Member

  • Staff Manager/Global Mod
  • 576 posts
  • LocationDevon UK
  • RM Skill - Musician

Awards Bar:

Users Awards

Posted 18 May 2013 - 07:02 AM

Okay, so orignal my project was in VX, and whenever a project loads It was meant to activate a common event, now originally someone told us to place: 

 

$game_temp.common_event_id = 4 

here...

  #--------------------------------------------------------------------------
  # * Execute Load
  #--------------------------------------------------------------------------
  def do_load
    file = File.open(@savefile_windows[@index].filename, "rb")
    read_save_data(file)
    file.close
    $scene = Scene_Map.new
    RPG::BGM.fade(1500)
    Graphics.fadeout(60)
    Graphics.wait(40)
    @last_bgm.play
    @last_bgs.play
    $game_temp.common_event_id = 4
  end

 

This was in VX, so I'd like to enquire where the feck I place it now :D 

Seeing as VX Ace does not have the do_load command (I know that isn't the word I'm looking for -_- my head isn't screwed on properly :P) Any help?


80x50_orange.png  indiedb_88x31.png 1.jpg?v=bede4bp004_0_02_01.jpg SMC%20Games%20Afficiation%20Request.png

 

I now have a selection of free music here!

btn_donate_SM.gif

To help keep the Tea cupboard stocked up

(What...I'm british ;))


#831 regendo

regendo

    Ruler of Worlds

  • Local Moderators
  • 676 posts
  • LocationGermany
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 18 May 2013 - 07:21 AM

I'm not familiar with VX, but I'd assume you're looking either for DataManager#load_game_without_rescue(index) or Scene_Load#on_load_success.

Also, I think common events now work differently, but I'm not quite sure.



#832 Tsukihime

Tsukihime

    Advanced Member

  • Members
  • 5,015 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 18 May 2013 - 07:32 AM

Okay, so orignal my project was in VX, and whenever a project loads It was meant to activate a common event, now originally someone told us to place: 

$game_temp.common_event_id = 4 


Use $game_temp.reserve_common_event(4) instead

Edited by Tsukihime, 18 May 2013 - 07:32 AM.


#833 Jonnie19

Jonnie19

    Advanced Member

  • Staff Manager/Global Mod
  • 576 posts
  • LocationDevon UK
  • RM Skill - Musician

Awards Bar:

Users Awards

Posted 18 May 2013 - 07:39 AM

Thankyou :) I was able to load the game without any errors, I placed it here:

  #--------------------------------------------------------------------------
  # * Processing When Load Is Successful
  #--------------------------------------------------------------------------
  def on_load_success
    Sound.play_load
    fadeout_all
    $game_system.on_after_load
    $game_temp.reserve_common_event(4)
    SceneManager.goto(Scene_Map)
  end
end

 

and it all seemed to work perfectly :D Thanks to both of you :)


80x50_orange.png  indiedb_88x31.png 1.jpg?v=bede4bp004_0_02_01.jpg SMC%20Games%20Afficiation%20Request.png

 

I now have a selection of free music here!

btn_donate_SM.gif

To help keep the Tea cupboard stocked up

(What...I'm british ;))


#834 Arin the Illustrious

Arin the Illustrious

    Overly Obsessive

  • Staff
  • 847 posts
  • LocationWith Al Pacino.
  • RM Skill - Writer

Posted 21 May 2013 - 10:45 PM

Is there anyway to add a msgbox snippet that checks if a particular Font is installed on the system, and if isn't, the program exits? I've been debating whether or not to do something like this for Harem.


I WANT A HAREM, TOO, MOMMY!:

 

Spoiler


aVbAM22.png?1

 

SMC%20Games%20Afficiation%20Request.png

 


#835 Galv

Galv

    Cap'n

  • Global Moderators
  • 3,505 posts
  • LocationAustralia
  • RM Skill - Jack of All Trades

Posted 21 May 2013 - 11:34 PM

You can put the font you want in a /Fonts/ folder in your game's folder and the game will use that font without it being installed on their computer.
pr-banner-1_zps8677a4d1.png gs-banner_zpsfc59b073.png

#836 Arin the Illustrious

Arin the Illustrious

    Overly Obsessive

  • Staff
  • 847 posts
  • LocationWith Al Pacino.
  • RM Skill - Writer

Posted Yesterday, 07:17 AM

Really? It's that simple? I thought I was going to have to jump through a multitude of hoops to make this work, but that's awesome.


I WANT A HAREM, TOO, MOMMY!:

 

Spoiler


aVbAM22.png?1

 

SMC%20Games%20Afficiation%20Request.png

 


#837 Galv

Galv

    Cap'n

  • Global Moderators
  • 3,505 posts
  • LocationAustralia
  • RM Skill - Jack of All Trades

Posted Yesterday, 02:21 PM

Yep, it's that simple :D
YourProject/Fonts/
pr-banner-1_zps8677a4d1.png gs-banner_zpsfc59b073.png

#838 Ventwig

Ventwig

    Advanced Member

  • Members
  • 304 posts
  • RM Skill - Coder

Posted Yesterday, 05:58 PM

Does this piece of code:
module RPG
class BaseItem
def boss_bar
      if @boss_bar.nil?
        if @note =~ /<boss_bar>/i
          @boss_bar= true
        else
          @boss_bar = false
        end
      end
      @boss_bar
    end
end
end
work? What I'm trying to do is make notetags for enemies, except for some reason when I use this code and try to access &game_troops.alive_members[x], it says that boss_bar doesnt exist. (Maybe it's in the wrong class?)
(I dont remember if &game_troops has an s or not, but i did use the right one in the script)

Thanks

VTS- Ventwig's Turquoise Symphony

(VTS- Because everyone needs an obnoxious acronym to go with them!)

Spoiler


#839 Galv

Galv

    Cap'n

  • Global Moderators
  • 3,505 posts
  • LocationAustralia
  • RM Skill - Jack of All Trades

Posted Yesterday, 06:06 PM

Try this instead:
class RPG::BaseItem
  def boss_bar
    if @boss_bar.nil?
      if @note =~ /<boss_bar>/i
        @boss_bar = true
      else
        @boss_bar = false
      end
    end
    @boss_bar
  end
end
Or if you just need it for enemies, you could use RPG::Enemy
pr-banner-1_zps8677a4d1.png gs-banner_zpsfc59b073.png

#840 Tsukihime

Tsukihime

    Advanced Member

  • Members
  • 5,015 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted Yesterday, 08:31 PM

module RPG
  class BaseItem
Works fine. I use it all the time.

Need to know how you are accessing it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users