I'm starting scripting ^^

Started by element, September 11, 2010, 05:06:26 am

Previous topic - Next topic

Ryex

it says
if the frame rate / the total frame count does not equal the value we have stored for total seconds then refresh
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Calintz

September 13, 2010, 06:55:18 pm #41 Last Edit: September 13, 2010, 06:56:49 pm by Calintz
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"

Ryex

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

I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Calintz

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?

Ryex

well no, not really. but you can display an internal window.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Calintz

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?

Ryex

take a look at the command window's disable item method.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Calintz

I can't get anything to work, Lol.

Ryex

remember try to understand the flow of the program
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Calintz

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.

Blizzard

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".
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Zeriab

September 14, 2010, 03:37:29 am #51 Last Edit: September 14, 2010, 03:44:41 am by Zeriab
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'?
RGSS Graphics for Noobs - Part 2, Are you gonna eat that?

Links to part 3 and 4 in the next post


*hugs*


Ryex

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
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Zeriab

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*

ForeverZer0

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.  ;)
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.

Ryex

I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Zeriab

September 14, 2010, 12:52:12 pm #57 Last Edit: September 14, 2010, 12:54:10 pm by Zeriab
*pats*

@ForeverZer0:
Where do you see that pattern used (or an attempt at applying it) ?_?

Ryex

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
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ForeverZer0

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?
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.