Whats the difference?

Started by bigace, October 05, 2013, 11:38:46 am

Previous topic - Next topic

bigace

October 05, 2013, 11:38:46 am Last Edit: October 05, 2013, 03:14:30 pm by bigace
So I notice a while ago that ruby 1.9.1 has msgbox and I wanted to know what was the difference between:

  • msgbox and print

  • p and msgbox_p



As far as I can see, both functions look and act the same.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

ForeverZer0

October 05, 2013, 02:22:36 pm #1 Last Edit: October 05, 2013, 02:25:20 pm by ForeverZer0
If I remember correctly, "p" is more of a debug tool, it uses the "inspect" method to determine what to output, while "print" (I think just an alias for "pretty_print", uses the standard "to_s" to determine the output.  

Both will be usually the same, but "p" will have a different output if "to_s" is overridden in the class.

test = Array.new

p test
print test

class Array
 
  def to_s
    "ARRAY"
  end
end

p test
print test
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

bigace

October 05, 2013, 03:13:58 pm #2 Last Edit: October 05, 2013, 03:17:32 pm by bigace
ops I worded that wrong :facepalm:. I fix the OP.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

October 06, 2013, 02:44:16 pm #3 Last Edit: October 06, 2013, 03:00:32 pm by KK20
Quote from: RMVXA Help File-RGSS Specifications
It is now possible to use editor options to open a console window for debugging output during play testing.
Output to message boxes using the print function and the p function has been abolished due to the aforementioned improvement. These functions have been renamed msgbox and msgbox_p.

So tell me how you are able to get print and msgbox to both work, besides doing something like

def print(*args)
  msgbox(*args)
end
def p(*args)
  msgbox_p(*args)
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

Okay so it's just a upgrade with a new name.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.