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
> Module Question
Adrien.
post Sep 3 2011, 06:35 PM
Post #1


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




If I am writing a module, is there a way to say, make the ability for a user using the class that includes this module NOT be able to use .new to inialize the class? instead use a diffrent method? Essentially I am asking to make a module where when included it makes the initalize method private

I know you can do in a class:

CODE
private

def inialize
end

public
#some other methods.



But I want the module to take away the idea of doing that and make the initialize method private.

Ideas?


Thread has been reported to be moved to vx

This post has been edited by Adrien.: Sep 3 2011, 06:58 PM


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Zeriab
post Sep 3 2011, 08:16 PM
Post #2


Level 12
Group Icon

Group: Revolutionary
Posts: 196
Type: Event Designer
RM Skill: Skilled




dI suggest you download standard ruby and look at Singleton.rb as that includes the feature you want. (Download version 1.8.x)


__________________________
Go to the top of the page
 
+Quote Post
   
Adrien.
post Sep 3 2011, 08:37 PM
Post #3


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




i dont want to make a singleton >_>

any ways need a mod to move this to vx


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
X-M-O
post Sep 3 2011, 08:42 PM
Post #4


Level 82
Group Icon

Group: Director
Posts: 6,347
Type: None
RM Skill: Undisclosed




QUOTE (Adrien. @ Sep 3 2011, 11:37 PM) *
need a mod to move this to vx


Moved to RPG Maker VX by user request.


__________________________
Go to the top of the page
 
+Quote Post
   
Adrien.
post Sep 3 2011, 08:56 PM
Post #5


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




i reported the thread and nothing happened >_> lol. took me asking in my own thread >_> but thanks ^__^

so why would I look at the singleton pattern as it wont help much in rgss2 as rgss2 does NOT include a lot of core ruby implementations and classes.

Ya I looked at that module and decided what I want to do RGSS2 would not support how they did it. so I have to build it from the ground up >_>

This post has been edited by Adrien.: Sep 3 2011, 09:18 PM


__________________________



Games I am working on | Each image is a link to the game
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Sep 4 2011, 04:57 AM
Post #6


The past tense
Group Icon

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




You should not need to initialize a module with .new unless you were trying to set a variable as an instance of that object. Think of the cache module, to use it you use Cache.system() or Cache.picture() you don't use Cache.new.


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Zeriab
post Sep 4 2011, 05:14 AM
Post #7


Level 12
Group Icon

Group: Revolutionary
Posts: 196
Type: Event Designer
RM Skill: Skilled




So you know what a Singleton is, good ^^
Do tell me how you would implement the singleton pattern without controlling access to the new method wink.gif


__________________________
Go to the top of the page
 
+Quote Post
   
Adrien.
post Sep 4 2011, 06:43 AM
Post #8


Bet Mapper
Group Icon

Group: Banned
Posts: 1,632
Type: Mapper
RM Skill: Advanced




So I am just playing with code. So forgive me if I seem retarded and stupid. I doubt this would EVER be implemented into a script.

CODE
module Sample

  class << self
    def extended klass
      klass.instance_variable_set :@instance, klass.new
      klass.private_class_method :new
    end
  end
  
  def instance
    @instance
  end
  
end


class Test
    extended Sample
end

Test.instance


I am getting the error method error no such method on .instance
How ever Test<Sample states I already have the module being used why extend it.

So why am I getting a no method error? I thought what I was doing was correct.

an update:

Test.new works when it shouldnt. in windows it throws an error, oh and this script compiles in windows and works, but not in RGSS2? um confusion?

Hell even in linux it works.

Does RGSS2 not support what I am trying to do?

edit - issue fixed

also this should thread needs to be moved to script support not VX

This post has been edited by Adrien.: Sep 4 2011, 07:40 AM


__________________________



Games I am working on | Each image is a link to the game
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: 24th May 2013 - 03:22 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker