Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [RGSS2 Color Class], Built in Color Class
cmpsr2000
post Aug 18 2008, 12:24 AM
Post #1


Keeper of the Ruby Code of DOOM!
Group Icon

Group: Revolutionary
Posts: 355
Type: Scripter
RM Skill: Masterful




Built in Color Class

Version -
Author Enterbrain/cmpsr2000
Release Date August 15, 2008

Exclusive Script at RPG RPG Revolution


Introduction
This is a reverse-engineered equivalent of the RGSS2 built in Color Class. The RGSS equivalent would be identical, minus the alpha attribute. Using this along with the equivalent Table Class over at RMXP.org and the RPG module will allow developers to fully interact with the .rvdata files in the Ruby runtime in order to build their own applications on top of the RGSS2 data structures.

Script
CODE
#================================================================
#
# Enterbrain's RGSS2 Color Class
# by cmpsr2000 @ rpgrevolution.com
#
#================================================================

class Color
#=============================================================
# initialize - creates a new Color object
# red : the RGB red value of this color : 0-255(F)
# green : the RGB green value of this color : 0-255(F)
# blue : the RGB blue value of this color : 0-255(F)
# alpha : the alpha value of this color : 0-255(F)
#=============================================================
def initialize(red, green, blue, alpha = 255)
set(red, green, blue, alpha)
end
#=============================================================
# set - sets all attributes simultaneously
# red : the RGB red value of this color : 0-255(F)
# green : the RGB green value of this color : 0-255(F)
# blue : the RGB blue value of this color : 0-255(F)
# alpha : the alpha value of this color : 0-255(F)
#=============================================================
def set(red, green, blue, alpha = 255)
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
end
#=============================================================
# attr_accessor :red - includes OOR value checking
def red
@red
end

def red=(amount)
if amount < 0
amount = 0
elsif amount > 255
amount = 255
end
@red = amount.to_f
end
#
#==============================================================

#==============================================================
# attr_accessor :blue - includes OOR value checking
def blue
@blue
end

def blue=(amount)
if amount < 0
amount = 0
elsif amount > 255
amount = 255
end
@blue = amount.to_f
end
#
#==============================================================

#==============================================================
# attr_accessor :green - includes OOR value checking
def green
@green
end

def green=(amount)
if amount < 0
amount = 0
elsif amount > 255
amount = 255
end
@green = amount.to_f
end
#
#==============================================================

#==============================================================
# attr_accessor :alpha - includes OOR value checking
def alpha
@alpha
end

def alpha=(amount)
if amount < 0
amount = 0
elsif amount > 255
amount = 255
end
@alpha = amount.to_f
end
#
#==============================================================

#==============================================================
# _dump - handler for Marshal.dump, serializes this object
# d : depth level
# RETURNS : string
#==============================================================
def _dump(d = 0)
s = [@red, @green, @blue, @alpha].pack("DDDD")
return s
end
#==============================================================
# self._load - static handler for Marshal.load, deserializes
# this object
# s : string to deserialize
# RETURNS : Color
#==============================================================
def self._load(s)
vals = s.unpack("DDDD")
c = Color.new(vals[0], vals[1], vals[2], vals[3])
return c
end

end


Customization
none.

Compatibility
RGSS2 only

Terms and Conditions
Free to use in all projects so long as the credit stub at the top remains.

Credits
Thanks to Enterbrain for the RPGM series.


__________________________
Go to the top of the page
 
+Quote Post
   
Netto
post Aug 18 2008, 02:35 AM
Post #2


芸術家
Group Icon

Group: Revolutionary
Posts: 708
Type: None
RM Skill: Skilled




Great job Cmpser smile.gif


__________________________
Current Project[RC]: Twilight Realm 3DMMORPG w/dx9, and char creation through mysql after I get a server, now C++ scripting
Current Project[VX]: Obsidian Trilogy just started 08/12/2008
Current Project[XP&RM2K3]: none
Go to the top of the page
 
+Quote Post
   
Grandhoug
post Aug 18 2008, 02:45 PM
Post #3


Level 5
Group Icon

Group: Member
Posts: 70
Type: Developer
RM Skill: Undisclosed




could you please elaborate on how it works again cause im confused

This post has been edited by Grandhoug: Aug 18 2008, 03:11 PM


__________________________
Fly like a rhino, sting like shock paddles.
Go to the top of the page
 
+Quote Post
   
cmpsr2000
post Aug 18 2008, 06:15 PM
Post #4


Keeper of the Ruby Code of DOOM!
Group Icon

Group: Revolutionary
Posts: 355
Type: Scripter
RM Skill: Masterful




QUOTE (Grandhoug @ Aug 18 2008, 05:07 PM) *
could you please elaborate on how it works again cause im confused


It's for scripters who want to access RMVX data outside of the RMVX program. Enterbrain has several hidden classes that they probably wrote in c++ to extend the ruby library for the game maker. You can't reconstitute the data from a marshal.load without the code for the classes it is reconstituting. Because of this, it is impossible to load information from the .rvdata files without your own Table and Color Class along with the supplied RPG module. The Table Class has been reverse engineered over at RMXP.org, but I haven't seen a color class anywhere so I had to write my own.

You should only be using this if you are attempting to work with RMVX data inside a normal ruby environment.


__________________________
Go to the top of the page
 
+Quote Post
   
Chronno
post Aug 18 2008, 06:21 PM
Post #5


Level 5
Group Icon

Group: Member
Posts: 64
Type: None
RM Skill: Undisclosed




let me see, are you saying that you can edit the editor with that? i dont know anything about c++ or ruby, so tell me if im wrong, if you can edit the editor you could make some king of update patchs?... well i dont know
Go to the top of the page
 
+Quote Post
   
cmpsr2000
post Aug 18 2008, 06:35 PM
Post #6


Keeper of the Ruby Code of DOOM!
Group Icon

Group: Revolutionary
Posts: 355
Type: Scripter
RM Skill: Masterful




QUOTE (Chronno @ Aug 18 2008, 08:43 PM) *
let me see, are you saying that you can edit the editor with that? i dont know anything about c++ or ruby, so tell me if im wrong, if you can edit the editor you could make some king of update patchs?... well i dont know


You cannot edit the editor without some serious hacking, and it's against the enterbrain ToS. However, you can use this code to write your own editor from scratch in ruby (or any language that supports ruby interop).


__________________________
Go to the top of the page
 
+Quote Post
   
Grandhoug
post Aug 18 2008, 07:17 PM
Post #7


Level 5
Group Icon

Group: Member
Posts: 70
Type: Developer
RM Skill: Undisclosed




QUOTE (cmpsr2000 @ Aug 18 2008, 09:57 PM) *
QUOTE (Chronno @ Aug 18 2008, 08:43 PM) *
let me see, are you saying that you can edit the editor with that? i dont know anything about c++ or ruby, so tell me if im wrong, if you can edit the editor you could make some king of update patchs?... well i dont know


You cannot edit the editor without some serious hacking, and it's against the enterbrain ToS. However, you can use this code to write your own editor from scratch in ruby (or any language that supports ruby interop).


hmm... does this then mean i might be able to make scripts or edit somethings within the game scripts. if not could you maybe show a picture of this editor you speak of

This post has been edited by Grandhoug: Aug 18 2008, 07:18 PM


__________________________
Fly like a rhino, sting like shock paddles.
Go to the top of the page
 
+Quote Post
   
woratana
post Aug 19 2008, 05:31 AM
Post #8


Looking for scripter to hire? PM me *O*
Group Icon

Group: +Gold Member
Posts: 1,038
Type: Scripter
RM Skill: Undisclosed




I just wandering if this can use in game.
But since I can't see how it connects to RGSS library or original Color class, I guess not. sad.gif


__________________________
Check out my NEW blog!!!



MVP (Most Valuable Poster) Award 2008


Go to the top of the page
 
+Quote Post
   
cmpsr2000
post Aug 20 2008, 02:38 AM
Post #9


Keeper of the Ruby Code of DOOM!
Group Icon

Group: Revolutionary
Posts: 355
Type: Scripter
RM Skill: Masterful




QUOTE (woratana @ Aug 19 2008, 07:53 AM) *
I just wandering if this can use in game.
But since I can't see how it connects to RGSS library or original Color class, I guess not. sad.gif


I'm sorry, I don't understand what you mean. I'm not sure why anyone would want to use this code in an RMVX game, since you do not gain anything by actually knowing it.


__________________________
Go to the top of the page
 
+Quote Post
   
woratana
post Aug 20 2008, 03:36 AM
Post #10


Looking for scripter to hire? PM me *O*
Group Icon

Group: +Gold Member
Posts: 1,038
Type: Scripter
RM Skill: Undisclosed




I see smile.gif

Thanks for the answer >_>/


__________________________
Check out my NEW blog!!!



MVP (Most Valuable Poster) Award 2008


Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 22nd May 2013 - 11:26 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker