Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: element on September 11, 2010, 05:06:26 am

Title: I'm starting scripting ^^
Post by: element on September 11, 2010, 05:06:26 am
Hi all,

Today, I'd like to start trying to script.
Cuz I'm making a game that'll have a lot of scripts that still need to be made.
I read some articles online how to script RGSS, I might need to re-read them cuz I don't really know how to start.
That's why I ask you all how u started scripting RGSS, or started scripting at all.
RGSS/Ruby would be my first scripting language I learn.

I took a goal for me, I'd like to script something that takes track of eneamy levels so that they can be placed later on in a hud. The hud is something to make after this one.

So, what I like to make:
A system that will give something like: Eneamy[ID]'s level == ['45']
Just so I can dislpay the level later on in the Hud, apart from the name.
I think this would be an easy part of code and a good start.

What I ask to you guys:
How did you start scripting? What tutorials did you follow? What did u do next?
And afterwards, how would I need to start making this script?

Thanks In advance for your helps ^^
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 11, 2010, 05:12:00 am
I started messing around with others' simple scripts. I did edits and watched what happened, what changed in the original workflow of a script. That way I figured out which part did what and quite quickly (later on the same day I actually started) I was able to put together a simple script myself. It was a credits script that would show picture after picture. (Later I upgraded that script to the Picture Movie Scene from Tons.)
Title: Re: I'm starting scripting ^^
Post by: element on September 11, 2010, 05:22:01 am
That's a good Idea. I'll start checking out some scripts.
Title: Re: I'm starting scripting ^^
Post by: stripe103 on September 11, 2010, 05:43:58 am
That is how I started as well. Though I haven't got as good.
The first thing I ever did with scripting was editing Zeriabs QuestBook (http://forum.chaos-project.com/index.php/topic,2325.0.html).
It turned out quite good as an AchievementsBook (http://www.rpgrevolution.com/forums/index.php?showtopic=38567). I'm quite happy with it.
Title: Re: I'm starting scripting ^^
Post by: Aqua on September 11, 2010, 10:44:45 am
O.o Why is this in News/Suggestions/Feedback?
Title: Re: I'm starting scripting ^^
Post by: littleK123 on September 11, 2010, 11:45:59 am
heelo im new to rpg maker xp i have a friend name joey101 on rpg rpg revoultion
i got rpg maker xp downloaded and i asked him if he can help me out he said hes busy so i should go here and he told me to look for the:
Blizz-ABS but i cant find it can some one help me thank you
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 11, 2010, 11:54:36 am
http://www.chaos-project.com/index.php?option=com_scriptdatabase&view=scriptdatabase&Itemid=29

Please try searching harder the next time and making use of the search function in the forum (there's a button in the top menu).
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 11, 2010, 11:59:05 am
Well Element I'm pulling for you man!!
I too will give scripting another chance.
Title: Re: I'm starting scripting ^^
Post by: element on September 11, 2010, 03:02:22 pm
I hope we get there  :)
Any other scripters wanna post how they started?
It would help me a lot.
Title: Re: I'm starting scripting ^^
Post by: winkio on September 11, 2010, 03:04:14 pm
I had a small programming background, so I just applied that knowledge to RGSS.  I guess reading over Blizz-ABS, understanding it, and then making small modifications to it were the first things I did, two years ago.
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 11, 2010, 03:40:31 pm
well I started like most every one else said, by reading a script i wanted to edit and trying to under stand it. eventually I decided that I would learn more by making my own so I made the "collapsed" menu (eventually I edited it to be the "collapsing" menu). I also read several ruby tutorials as i was a complete beginner when it came to programing.
the thing about tuts: they can teach you all the syntax in the world, but not a single one of them teaches the jump from knowing syntax to knowing how to apply it. this is where the large learning curve comes in. knowing how to make all those words do what you want is never taught, only what the words mean is.

good luck.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 11, 2010, 03:56:25 pm
@Ryexander:
That is the leap I never crossed. Well put.
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 11, 2010, 04:05:30 pm
the only way I know of to cross it is to make something and then make something else, getting more complex each time.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 12, 2010, 12:42:37 am
Make something ... then make something else huh?
Well ... I don't even know how to make a CMS. I mean ... I can add additional features and shit, but as far as adding original items like sprite animations of things that would actually make a CMS cool ... nope.
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 12, 2010, 01:07:57 am
thats where I started. :P
I also asked a lot of questions when i went to build something beyond my ability. this place is very friendly to budding scripters
Title: Re: I'm starting scripting ^^
Post by: element on September 12, 2010, 03:12:15 am
Becouse probably i'm only going to make graphical scripts and stuff, i'm going to try to dislpay a picture, and dislplay text in it. Should be easy hm?
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 12, 2010, 04:11:18 am
Put the gold window on the map for training. Through that process you should learn how scenes and windows are organized.

Gah, I still need to make my guide "How to learn scripting in X steps".
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 12, 2010, 04:41:13 am
if some one ever makes a guide that allows people to make that leap between knowledge and application I will be very happy.
Title: Re: I'm starting scripting ^^
Post by: element on September 12, 2010, 05:25:18 am
I second what ryex said  :D


EDIT : Ok so I tried to write something that shows a picture on the map.
Most simple thing there is I think. I wrote a, probably shitty, piece of code :
##################################################
#                                                #
#              Text on picture test              #
#                                                #
##################################################

class Text_test
 
  ##############################
  #   Draw Text and picture    #
  ##############################
  def initialize
  Bitmap.new(189-Down01)
  Bitmap.new(50, 50)
  dispose
  end
end


How do I call this on the map? How do I make it appear on the map?
What am I doing wrong? What needs to be added?

Please be easy on me cuz I don't really already know what i'm doing.
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 12, 2010, 04:26:11 pm
well to call it on the map you would edit scene maps main method but as is your code won't work. Bitmaps alone aren't drawn to the screen you need to create a sprite and attach the bitmap to it btw the Bitmap.new(50, 50) create an empty bitmap and won't do anything and the Bitmap.new(189-Down01) won't work because first off it take a string and second the path to the image is wrong
Title: Re: I'm starting scripting ^^
Post by: element on September 12, 2010, 04:52:00 pm
yeah, i tougth it would make no sense.
Ill start reading some more code tomorrow.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 12:15:11 am
Alright, since this is an active thread I'll ask this question here.
What is the importance of knowing real RUBY programming as opposed to RGSS?

@ALL RGSS Scripters on CP:
Would you personally advise learning as much about the father language as possible before beginning with RGSS, or do you believe that connection is unimportant? Do you feel personally that people would be wasting time with RUBY? Is RGSS easy enough to pick up on without a proper understanding of RUBY?
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 13, 2010, 02:16:52 am
RGSS is not really a language. RGSS is a system that can be used with Ruby. The way the scripts are organized in RMXP is just an internal way of arranging them. When you learn RMXP's Ruby and RGSS, you are learning Ruby anyway. Of course, it will be easier to work with RMXP's scripts if you already know Ruby, but you will still have to figure out how RGSS works.
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 13, 2010, 02:21:47 am
don't bother learning ruby specific programing first in order to use RGSS you need to know its structure and once you have learned RGSS you have learned Ruby
it is the same language RGSS just hase some extra built in classes that are game specific.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 02:24:32 am
Well alright then.
Thank you guys. I have spent an hour or so just looking at default scripts.

Things are still a blur to me. I get pieces here and there. This is gonna take me forever, and I really don't think I'll get to the point where I can build scripts from the ground up. I think I'll be able to edit at best, Lol.
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 13, 2010, 02:25:06 am
Right, I said a bunch of things, but actually didn't give a direct answer.
Pretty much what Ryex said. Don't bother with Ruby, go straight for RGSS. You will learn Ruby with RGSS faster that you would be if you first learned some Ruby and then had to learn RGSS again.

Yeah, the default scripts are quite big. Best you take just one of the simpler scripts and try to understand a bit what is going on. Then try to add edits and see what happens. If you understood things right and the changes you made were what you wanted, the right thing should happen and you will figure out something in the scripts. Then you can go from there and keep experimenting.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 02:30:31 am
That worked for me in the past, and it seems to be working now. Like, I have made some simple edits to the title screen, and some simple edits to the default menu system and like you said ... the edits are what I want and so pieces of the puzzle are beginning to fall into place, but will this method really take me to the top?

A constant help for me has been the Help Text file in the editor believe it or not.
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 13, 2010, 02:35:11 am
yes it will take you to the top, and yes the help file is awesome. I'm still using it, and will likely keep using it. its not like a person can completely memorize an entire code base.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 02:39:40 am
*points to Blizzard* (with both hands muthaf*****) LMFAO.

At any rate this is good news. Thank you Ryexander.
Continuing to look at default scripts I've realized that the scripts use two main thingy majigs. def initialize and def main.
Am I correct in assuming that def initialize is used when establishes an item's properties, and that def main is used for the declaration of processing of those items?
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 13, 2010, 04:39:43 am
Exactly. "initialize" is called when you create a new object, a new instance of a class.
Title: Re: I'm starting scripting ^^
Post by: ForeverZer0 on September 13, 2010, 12:28:53 pm
Quote from: Ryexander on September 12, 2010, 04:26:11 pm
well to call it on the map you would edit scene maps main method but as is your code won't work. Bitmaps alone aren't drawn to the screen you need to create a sprite and attach the bitmap to it btw the Bitmap.new(50, 50) create an empty bitmap and won't do anything and the Bitmap.new(189-Down01) won't work because first off it take a string and second the path to the image is wrong


You need something like this:

class Test_test

  def initialize
    @sprite = Sprite.new # Sprites display the bitmaps
    @sprite.bitmap = Bitmap.new("FILENAME") # Sets a bitmap to the sprite
    @sprite.x, @sprite.y = X, Y # Sets the location, in pixels, of the sprite on the screen
  end

  # Now the sprite will not update without calling an update method and the game will
  # crash if the sprite is not disposed and called again, but I hope this can at least
  # point you in the right direction.
end
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 13, 2010, 01:10:17 pm
ya def initialize is an inbuilt ruby method that is called when .new is called in order to create the object and "initialize" object data

def main is only uses in scene classes.

a scene class is a class that process a scene and is something you set the $scene object too

it you look at the main script you will notice that that it loops indefinitely and calls $scene.main
a def main method contains another loop that dose updating
first it calls Input.update to update input information form the system and make it available to in game processing
then it calls the scene update method which updates displayed windows, and then it calls Graphics.update which refreshes what is drawn on the screen.
then you will notice that in the loop in the main method there is a condition
if $sceen != self
  break
this means that if $scene has chanced to something that is not the same object that the loop is running it breaks the loop.
you will notice that after the loop there is objects disposed. this makes sure the all the sprites drawn in that scene are disposed so that they don't carry over and stay when the next scene is called.
at this point the code jumps back to the main loop again and calls $scene.main again. so the main method of the new scene is called.

are you starting to understand the flow now?
understanding program flow is key to understanding RGSS
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 01:15:39 pm
That is the answer I was looking for Blizzard. Thank you!
Knowing that def initialize is called when I create a new class will be a much more logical way for me to remember its purpose than simply saying it's used to define the characteristics of a class (even though that's what it's for).

@Ryexander:
This conversation between Blizzard and me was a perfect example of that gap we talked about. I understood that "def initialize" held the base characteristics of a new class by looking at default code, but now knowing that it absolutely needs to be called and defined and when I need to do that helped me cross that gap of application. Now I know how and when to apply that syntax. If that's the case with 'def initialize' ...

@Scripters:
Then the same goes for 'def main' right? If you create a new class then "def main" NEEDS to be defined somewhere after def initialize, right? Because 'def initialize' sets up the new class, but something has to tell those properties what to do? That is what 'def main' is for, right? Well...maybe "def main" doesn't technically tell that class what to do, but it tells all the attributes defined in the new class' 'def initialize' method how to properly process the way you want without failing, right!? That's the purpose of 'def main'?

Then, you take it one step further by creating a new scene.
Calling new scenes is how you actually tell that new class what to do, right appear on screen?

Edit:
@Ryexander:
yea. I really do believe I'm understanding this a bit now. This order...it will always be the same for all new classes and scenes, etc...? Like, it doesn't matter if I'm making a time and climate system that doesn't use graphical enhancements as opposed to a CMS. The process of writing the code needs to be the same, right?
Title: Re: I'm starting scripting ^^
Post by: element on September 13, 2010, 02:11:16 pm
Ok I learned Reall ymuch more now.
So now I'll try to make a class that stops the bgm.
Nothing more than that.
I learned that
$Class_name
is used to call a class and
$Class_name.Thing_in_class
is used to call
def Thing_in_class

True?

Also can someone explain me how scripts are built up? and explain some more things like the previous explaination of def initialize, cuz that helped me alot  :D
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 13, 2010, 02:14:19 pm
Pretty much, yeah.

@Calintz: def main is a slightly different concept. Scenes define main as a sort of entry and exit for a main update loop. Other classes don't need a main. In fact, initialize isn't needed either. If it's not defined, it will not be called. So if you have a utility class with no attributes, there is no need to define initialize.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 02:26:56 pm
@Blizzard:
I think I understand that concept. By default you are on the map. This is a scene in itself. It contains all of the information needed to play the game, and only updates that information accordingly. Viewing your menu however, has a completely different set of requirements and information of its own, therefore you need to make a transition through those scenes. It's that transition from updating one set of information to a whole new set that requires the 'def main' to be used?

This is why windows don't have a 'def main' right? Their information is established through the 'def initialize' process. That process builds the window itself and its update information, but no actual change from one update to another is required. This is why windows don't have 'def main' in the code, but scenes do? The scenes(which is where 'def main' is used, because of the transition) simply pulls that information by calling it's class. (Scene_Menu.new)

Is that right?
Title: Re: I'm starting scripting ^^
Post by: element on September 13, 2010, 03:06:13 pm
Anybody can help me with wat i'm doin wrong.

##################################################
#                                                #
#              stop the bgm test                 #
#                                                #
##################################################

module MUSIC
  def initialize
    @Stopthemusic = false
  end
  class Stop_music
    def music_stop
   
      if @Stopthemusic == true
        $game_system.bgm_stop
      end
    end
  end
end


I'm calling the stop the bgm in an event with : MUSIC.@Stopthemusic = true

It gives me a syntax error that leads me to game_temp first line
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 13, 2010, 03:26:55 pm
ya that would fail... for one. @Stopthemusic isn't public, and ya there is just a lot wrong with that.

ok first off modules are completely different than class in terms of what they are user for. think of a module as a static namespace that can't be instanced.
in other words MUSIC.new would raise a NoMethod error. so no def initialize for modules.
modules can contain methods and classes but in order to call a modules method out side the module they have to be defined as
def self.methodname
this format allows a method to be called with out the class (or module) being instanced
def method name can only be called by a method inside the module

take this for example

##################################################
#                                                #
#              stop the bgm test                 #
#                                                #
##################################################

module Music
  class Stop_music
    def self.music_stop
      stop_music_internal
    end
    def stop_music_internal
      $game_system.bgm_stop
    end
  end
  def self.music_stop
    stop_music_internal
  end
  def stop_music_internal
    Stop_music.music_stop
  end
end


Module and Class names MUST be capitalized other wise they are not constants and they can't be called correctly
method names by convention are not capitalized, there is no reason two and it confuses people, also i think it might have some side effects I don't know about.


Music.music_stop  #> stops the music
Music::Stop_music.music_stop  #> stops the music
Music.stop_music_internal  #> NoMethod Error
Music.Stop_music.stop_music_internal  #>  NoMethod Error
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 13, 2010, 04:10:55 pm
@Calintz: Yes, you got it. Windows usually have a refresh method that updates the display. That method should only be called when the information has changed because calling it every frame would heavily increase CPU load and it would start to lag. Windows also have an update method that updates other additional information such as user input to move the cursor around (or even constantly checking whether the displayed data has changed so it can be refreshed).

When calling a new scene, you need to use "$scene = Scene_X.new" When the current update loop ends, the current scene will exit and the new scene will be started.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 04:29:42 pm
@Element:
We're getting there bud. A step at a time.

@Blizzard:
I've noticed the use of the refresh method in the Gold window, Steps window, and the Playtime window, and so that was my initial thought: The refresh method is used because that information is always changing during gameplay. The Playtime clock even runs during Menu processing.

Actually, because the Playtime clock is always running isn't that why there is an additional 'Frame Update' method in the standard Playtime script? It looks like the code is saying "if the frame count divided by the frame rate changes by the second, then refresh. Either that, or if the frame count divided by the frame rate is no longer equal to the current playtime, then refresh. This is what my brain interprets from that line. Does the '/' even mean divided by in that line, or am I missing something?
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 13, 2010, 06:34:54 pm
it says
if the frame rate / the total frame count does not equal the value we have stored for total seconds then refresh
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 06:55:18 pm
Okay ... That makes sense. I've noticed that  !=  is often used to determine whether or not something is changing. So it makes sense that this means it's asking whether or not what you have stored is equal to another value or not. If it isn't, then that itself denotes the change I mentioned. Hence the  !=  .

But still ... what is the purpose of this symbol in the code.  '/'
Is "if the frame rate / the total frame count does not equal the value we have stored for total seconds then refresh"
Equal to assuming this "if the frame rate divided by the total frame count does not equal the value we have stored for total seconds then refresh"
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 13, 2010, 08:48:14 pm
ya
/ = divide
* = multiply
** = to the power of
% = divide and return the remainder
+ = add
- = subtract
+= = increment by
-= = deincrement by
*= = return stored value multiplied by
/= = return stored value divided by
there is also
|
&
|=
&=and i think there is a
%=
but i can't really explain those

Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 09:50:13 pm
Very nice. Then it looks like I'm on track.
Now a quick question. Can you display a message window through a script call?

Like, not using p "blablabla"
but actually displaying a message window and specify what goes in it?
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 13, 2010, 10:27:12 pm
well no, not really. but you can display an internal window.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 10:33:32 pm
Not what I wanted. Thank you!
Another quick one. How do you enable a disabled item? Like scripts check if save is disabled or not because you can change that with events. But if you've added a custom option to the menu and you disable it? How do you enable it again?
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 13, 2010, 10:46:59 pm
take a look at the command window's disable item method.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 13, 2010, 11:22:17 pm
I can't get anything to work, Lol.
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 13, 2010, 11:25:10 pm
remember try to understand the flow of the program
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 14, 2010, 12:01:16 am
Well that isn't the problem here.
I'm putting things in the proper place, and using the proper code, but I think in order to succeed I have to go further than I can right now with edits into other scripts. I don't want to ruin anything, so I'll wait for that. It won't stop me from completed this task. It was just an aesthetic. I'll try again in the near future.
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 14, 2010, 02:26:32 am
You get the number of seconds by dividing the number of frames with the frame rate. So it's saying "If the number of seconds played has changed, refresh".
Title: Re: I'm starting scripting ^^
Post by: Zeriab on September 14, 2010, 03:37:29 am
Quote from: Ryexander on September 13, 2010, 03:26:55 pm
ya that would fail... for one. @Stopthemusic isn't public, and ya there is just a lot wrong with that.

ok first off modules are completely different than class in terms of what they are user for. think of a module as a static namespace that can't be instanced.
in other words MUSIC.new would raise a NoMethod error. so no def initialize for modules.
modules can contain methods and classes but in order to call a modules method out side the module they have to be defined as
def self.methodname
this format allows a method to be called with out the class (or module) being instanced
def method name can only be called by a method inside the module

take this for example

##################################################
#                                                #
#              stop the bgm test                 #
#                                                #
##################################################

module Music
  class Stop_music
    def self.music_stop
      stop_music_internal
    end
    def stop_music_internal
      $game_system.bgm_stop
    end
  end
  def self.music_stop
    stop_music_internal
  end
  def stop_music_internal
    Stop_music.music_stop
  end
end


Module and Class names MUST be capitalized other wise they are not constants and they can't be called correctly
method names by convention are not capitalized, there is no reason two and it confuses people, also i think it might have some side effects I don't know about.


Music.music_stop  #> stops the music
Music::Stop_music.music_stop  #> stops the music
Music.stop_music_internal  #> NoMethod Error
Music.Stop_music.stop_music_internal  #>  NoMethod Error



I am sorry, but what you write here is not right.
It'll probably be like this:

Music.music_stop  #> NameError
Music::Stop_music.music_stop  #> NameError
Music.stop_music_internal  #> NoMethod Error
Music.Stop_music.stop_music_internal  #>  NoMethod Error


The problem is one of scope. You cannot call instance methods without having a reference to the instance.
You do not have a local variable defined by stop_music_internal and no method by that name either, so you'll probably get a NameError.
You can create an instance of the Stop_music class and call stop_music_internal on that:
      instance = Stop_music.new
      instance.stop_music_internal



Here are some tutorials which you guys have not have seen:
RGSS Graphics for Noobs - Part 1, Tired of being 'the weakest link'? (http://www.creationasylum.net/forum/index.php?showtopic=23437)
RGSS Graphics for Noobs - Part 2, Are you gonna eat that? (http://www.creationasylum.net/forum/index.php?showtopic=23438)

Links to part 3 and 4 in the next post


*hugs*
Title: Re: I'm starting scripting ^^
Post by: Zeriab on September 14, 2010, 03:44:12 am
Part 3 and 4: (Adding them to the above post causes a php permission error :<)
RGSS Graphics for Noobs - Part 3, iiiiiit's BACON! (http://www.creationasylum.net/forum/index.php?showtopic=23439)
RGSS Graphics for Noobs - Part 4, Twas brillig, and the slithy toves did gire and gimble in the wabe... (http://www.creationasylum.net/forum/index.php?showtopic=23831)
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 14, 2010, 03:48:08 am
Woh zeriab. I can testify to that the results I gave, as I have done similar things myself if a method belonging to a module is defined as def self.name then module.name will call that function
Title: Re: I'm starting scripting ^^
Post by: Zeriab on September 14, 2010, 08:23:07 am
You misunderstand what the error is. Here is an example which illustrates the problem:

module Foo
  def self.bar
    my_instance_method
  end
  def my_instance_method
    p 'self.bar will not call this'
  end
end

Foo.bar


*hugs*
Title: Re: I'm starting scripting ^^
Post by: ForeverZer0 on September 14, 2010, 12:14:18 pm
Quote from: Zeriab on September 14, 2010, 08:23:07 am
You misunderstand what the error is. Here is an example which illustrates the problem:

module Foo
  def self.bar
    my_instance_method
  end
  def my_instance_method
    p 'self.bar will not call this'
  end
end

Foo.bar


*hugs*


I think he needs to learn the basics before he leanrs how to use the Singleton principle.  ;)
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 14, 2010, 12:46:03 pm
oh *face palm* thats right...
Title: Re: I'm starting scripting ^^
Post by: Zeriab on September 14, 2010, 12:52:12 pm
*pats*

@ForeverZer0:
Where do you see that pattern used (or an attempt at applying it) ?_?
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 14, 2010, 03:29:45 pm
wow I just researched what a singleton was and realized that I've been doing similar things in my last two big projects! lol :P
Title: Re: I'm starting scripting ^^
Post by: ForeverZer0 on September 14, 2010, 04:31:00 pm
I don't see why you would use that. All that is doing is calling a method that does nothing more than call another. Why not just call the second one to start with? Could that possibly work to call an instance method of the class, but use the Singleton method?
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 14, 2010, 04:38:30 pm
I didn't really read much of the last posts, but I just wanted to say that I don't like the concept of singleton so much. The concept of a static class (that ultimately behaves the same as a singleton, it is also a module in Ruby) looks a lot cleaner and better organized to me.
Title: Re: I'm starting scripting ^^
Post by: Ryex on September 14, 2010, 06:57:13 pm
@Zer0
I mostly did that to give them a picture of how methods inside modules work, personally I'd never do such a thing.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 14, 2010, 11:44:10 pm
@Blizzard:
Thank you for further demonstrating the purpose of that line. Now it makes perfect sense, Lol.

Edit:
Thanks to Blizzard and Ryexander. I have been growing little by little as a scripter.
Title: Re: I'm starting scripting ^^
Post by: Blizzard on September 15, 2010, 02:27:03 am
The hardest part is to start off. Once you get things rolling, it's a lot easier to continue on your own.
Title: Re: I'm starting scripting ^^
Post by: Calintz on September 15, 2010, 03:03:56 am
Thank you for the encouragement. I have been working on a DEMO for ojp and Game_Guy's Quest Log system, but as soon as I finish it I will get back to scripting. Thanks to you guys though I have base knowledge and I know that anytime I open the script editor...remember the flow of the language. That is the most important part. If you don't recognize the flow you'll probably start putting code into weird places!!  :naughty: