Jump to content


Photo

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


  • Please log in to reply
1556 replies to this topic

#1541 SpookyMothman

SpookyMothman

    Spooky Scary Skeleton

  • Ace Member
  • 379 posts
  • RM Skill - Jack of All Trades

Posted 24 October 2014 - 03:48 PM

Killozapit's worked like a charm. I put it in the wrong place, kinda, but it still works. I put it between [@opening = @closing = false] and [end] under Object Initialization in Window_Base. Thanks for the help.


[HOME]

dCcz82j.png

Games that are awesome:

Spoiler

 

People that are awesome:

Spoiler

#1542 KilloZapit

KilloZapit

    FAIRY DUST! FAIRY DUST FOR EVERYONE! WHEE!

  • Ace Member
  • 864 posts
  • RM Skill - Coder

Posted 24 October 2014 - 04:28 PM

You are welcome! *sprinkles fairy dust on you*

#1543 pencilcase27

pencilcase27

    So, I can write anything I want here... right?

  • Ace Member
  • 228 posts
  • RM Skill - Coder

Posted 25 October 2014 - 04:39 AM

In Window_Base, you'll find the following two methods:

Spoiler

Both of them draw pictures to a windows content by opening a bitmap, but only the first disposes the bitmap at the end. Could someone please explain to me why?


Edited by pencilcase27, 25 October 2014 - 04:39 AM.


#1544 Wispward

Wispward

    Newbie

  • Ace Member
  • 5 posts
  • LocationWinnipeg, MB. Canada
  • RM Skill - Coder

Posted 25 October 2014 - 04:48 AM

I've noticed that by default every player sprite's Y coordinate is set to +2 for some reason.

(What I mean is in this picture)

 

http://i.imgur.com/H5pCe2n.png

 

Does anyone know where in the script this is written and can be modified?
I poked around for 10 minutes, but I couldn't find a thing.

Hoping it's not hard-coded into the program.


Edited by Sketchward, 25 October 2014 - 04:48 AM.


#1545 pencilcase27

pencilcase27

    So, I can write anything I want here... right?

  • Ace Member
  • 228 posts
  • RM Skill - Coder

Posted 25 October 2014 - 05:02 AM

It is hard-coded, but it's also hard-coded to ignore this if the image name starts with a "!". You'll find the following code in the Game_CharacterBase class:

class Game_CharacterBase  
  #--------------------------------------------------------------------------
  # * Determine Object Character
  #--------------------------------------------------------------------------
  def object_character?
    @tile_id > 0 || @character_name[0, 1] == '!'
  end
  #--------------------------------------------------------------------------
  # * Get Number of Pixels to Shift Up from Tile Position
  #--------------------------------------------------------------------------
  def shift_y
    object_character? ? 0 : 4
  end
end

Edited by pencilcase27, 25 October 2014 - 05:16 AM.


#1546 Wispward

Wispward

    Newbie

  • Ace Member
  • 5 posts
  • LocationWinnipeg, MB. Canada
  • RM Skill - Coder

Posted 25 October 2014 - 05:18 AM

Worked perfectly, thank you very much. :)

I must have spent the last 20 minutes crawling around in Sprite_Base and Sprite_Character messing with Y formulas.
You're a life saver.



#1547 Uriel Everos

Uriel Everos

    Uriel Everos

  • Ace Member
  • 59 posts
  • LocationPhilippines
  • RM Skill - Jack of All Trades

Posted 25 October 2014 - 07:41 AM

class Uriel
  attr_accessor :eid
  attr_accessor :id
  def initialize
    @eid = 0
    id = 0
  end
  
  def enemies_id(id)
    @eid = $data_enemies[id].param[0]
  end
end

I'm using script call: Uriel.enemies_id(1)
I end up with a no method error

Any ideas?


Proud_to_be_Pinoy_by_mikkoman123.png
CrystalKnights.jpg


#1548 Glasses

Glasses

    The Coder

  • + Premium Members
  • 425 posts
  • LocationThe Internet
  • RM Skill - Coder

Posted 25 October 2014 - 07:46 AM

@Uriel,

 

You call methods from objects, like,

@uriel = Uriel.new
@uriel.enemies_id(1)

2vd44mv.png

 

 

Spoiler

#1549 TheoAllen

TheoAllen

    Eremidian Royal Guardian

  • Global Moderators
  • 1,410 posts
  • LocationIndonesia
  • RM Skill - Coder

Posted 25 October 2014 - 07:56 AM

In Window_Base, you'll find the following two methods:

Spoiler

Both of them draw pictures to a windows content by opening a bitmap, but only the first disposes the bitmap at the end. Could someone please explain to me why?

Character will likely to be used in map as well. If you dispose the characters bitmap inside the draw_character, you won't see the the character in map. While Faces are only used inside the Window by default.

 

Edit :
Actually, it's memory management.

Game doesn't need to reload the character graphics since it's been cached. Character will be used in map frequently than the face that only shown in menu. You know, loading bitmap takes much time


Founder of :
IkmCNj7.png

Visit also :

Theolized SBS | Development Journal | DeviantArt | SoundCloud | Free Midis |


rmid10.png
Vty978c.png

 
I support of these people / projects :

Spoiler
Be careful with the scripters
http://fc05.devianta...len-d7fchsv.jpg

#1550 KilloZapit

KilloZapit

    FAIRY DUST! FAIRY DUST FOR EVERYONE! WHEE!

  • Ace Member
  • 864 posts
  • RM Skill - Coder

Posted 25 October 2014 - 08:40 AM

@Uriel,
 
You call methods from objects, like,

@uriel = Uriel.new
@uriel.enemies_id(1)

 
You can also turn it into a module instead if you want, but you will have to get rid of the initialize method (you don't actually need a lot of the time anyway, if you are careful) and do some trickiness to turn the instance methods into class methods.
module Uriel
  # using "<<" tells ruby to extend an object directly rather then a class, here we extend the current object, self.
  class << self
    attr_accessor :eid
    attr_accessor :id
  end
 
  # putting self. in front of a method name does the same thing, as putting it in a "class << self" block
  def self.enemies_id(id)
    @eid = $data_enemies[id].param[0]
  end
 
end
Then you can just run Uriel.enemies_id whenever you want. You can actually do this with classes too, but that is mostly used for creating instances of that class. for example, .new is a class method.
 

Character will likely to be used in map as well. If you dispose the characters bitmap inside the draw_character, you won't see the the character in map. While Faces are only used inside the Window by default.

Edit :
Actually, it's memory management.
Game doesn't need to reload the character graphics since it's been cached. Character will be used in map frequently than the face that only shown in menu. You know, loading bitmap takes much time


The thing is though, the default cache is awful and never cleans out old bitmaps at all, so if you don't properly dispose cached bitmaps the number of cached bitmaps can grow and grow. One reason I wrote my own cache script actually. :P

Here is a question actually... does disposing a sprite dispose the bitmap too? If so character sprites should dispose their bitmaps when they are disposed on scene switch, but it might not if the cache references the bitmap... I have sort of assumed in the past disposing a sprite would dispose the bitmap, but maybe I should check more carefully.

Edited by KilloZapit, 25 October 2014 - 09:02 AM.


#1551 Uriel Everos

Uriel Everos

    Uriel Everos

  • Ace Member
  • 59 posts
  • LocationPhilippines
  • RM Skill - Jack of All Trades

Posted 25 October 2014 - 09:30 AM

I see. Understood, Thankyou. :)
@KilloZapit, Funny how i found the fix, before i even saw your post. When i read it. It was the exact fix that i used. So Kudos to you sir :)

my only  new issue now is this:

Is it possible to get a hash/array of variables. like

var = $game_variables[5]...[20].total

 

So that we don't have to type it one by one?


Edited by Uriel Everos, 25 October 2014 - 12:44 PM.

Proud_to_be_Pinoy_by_mikkoman123.png
CrystalKnights.jpg


#1552 TheoAllen

TheoAllen

    Eremidian Royal Guardian

  • Global Moderators
  • 1,410 posts
  • LocationIndonesia
  • RM Skill - Coder

Posted 25 October 2014 - 09:53 AM

 

The thing is though, the default cache is awful and never cleans out old bitmaps at all, so if you don't properly dispose cached bitmaps the number of cached bitmaps can grow and grow. One reason I wrote my own cache script actually. :P

Here is a question actually... does disposing a sprite dispose the bitmap too? If so character sprites should dispose their bitmaps when they are disposed on scene switch, but it might not if the cache references the bitmap... I have sort of assumed in the past disposing a sprite would dispose the bitmap, but maybe I should check more carefully.

 

Meanwhile, I made my own precache script. It loads most of the bitmap at the beginning of the game mainly for the animations. Yes, it can be around 200mb stored in memory. So the animation now run smoother. Since the computer these days have 2GB+ memories, so I have no worries :P

 

No, sprite and bitmap handled separately. Disposing sprite doesn't dispose the bitmap. Though, when the reference of the bitmap is lost, the bitmap automatically disposed.


Founder of :
IkmCNj7.png

Visit also :

Theolized SBS | Development Journal | DeviantArt | SoundCloud | Free Midis |


rmid10.png
Vty978c.png

 
I support of these people / projects :

Spoiler
Be careful with the scripters
http://fc05.devianta...len-d7fchsv.jpg

#1553 Evgenij

Evgenij

    Advanced Member

  • Ace Member
  • 128 posts
  • LocationGermany
  • RM Skill - Coder

Posted 27 October 2014 - 04:06 AM

Is it possible to get a hash/array of variables. like

var = $game_variables[5]...[20].total

 

So that we don't have to type it one by one?

 

Dont know exactly what you want but you can for example do this:

array = [100, 200, 300, 400]
array[1..3] # would return [200, 300, 400]

logoaa.png


#1554 TheoAllen

TheoAllen

    Eremidian Royal Guardian

  • Global Moderators
  • 1,410 posts
  • LocationIndonesia
  • RM Skill - Coder

Posted 27 October 2014 - 04:12 AM

Originally taken from helpfile

self[start, length]
Returns an array containing length items from start. If the start value is negative, counts backward from the end of the array (the index of the last element is -1).If length is longer than the length of the array from start, the length of the overlong portion is ignored. Returns nil if length is negative.


Founder of :
IkmCNj7.png

Visit also :

Theolized SBS | Development Journal | DeviantArt | SoundCloud | Free Midis |


rmid10.png
Vty978c.png

 
I support of these people / projects :

Spoiler
Be careful with the scripters
http://fc05.devianta...len-d7fchsv.jpg

#1555 Wispward

Wispward

    Newbie

  • Ace Member
  • 5 posts
  • LocationWinnipeg, MB. Canada
  • RM Skill - Coder

Posted 29 October 2014 - 04:42 AM

Is there any way through RGSS3 to detect what the system date/time is?

If not, would it be roughly possible to set up a system similar to Animal Crossing or Pokemon Gold/Silver through scripting?

IE detecting time that has passed even while the game is not being played.



#1556 TheoAllen

TheoAllen

    Eremidian Royal Guardian

  • Global Moderators
  • 1,410 posts
  • LocationIndonesia
  • RM Skill - Coder

Posted 29 October 2014 - 04:48 AM

It's something to do with Time.now << will return current time

Though, I havent really do an experiment about this


Founder of :
IkmCNj7.png

Visit also :

Theolized SBS | Development Journal | DeviantArt | SoundCloud | Free Midis |


rmid10.png
Vty978c.png

 
I support of these people / projects :

Spoiler
Be careful with the scripters
http://fc05.devianta...len-d7fchsv.jpg

#1557 Wispward

Wispward

    Newbie

  • Ace Member
  • 5 posts
  • LocationWinnipeg, MB. Canada
  • RM Skill - Coder

Posted 29 October 2014 - 04:49 AM

It's something to do with Time.now << will return current time
Though, I havent really do an experiment about this


Thanks much, I'll do some experimentation with that.
If anyone can go more in-depth, I'd greatly appreciate it. :)


Actually after a little Googling of RGSS3 Time.now, I found a script that already allows synchronization with PC clock.
Thanks again for the help TheoAllen. :)




1 user(s) are reading this topic

1 members, 0 guests, 0 anonymous users