Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -



Post new topic Reply to topic  [ 148 posts ]  Go to page 1, 2, 3, 4, 5  Next
    e
  Tue Mar 04, 2008 6:10 am
shittybutt
User avatar



Location: Berlin
Scripter's Corner

There seems to be a growing amount of capable scripters around the forums, people who pour their heart and souls into well concocted delights of logic and arithmetic in the hopes to further the cause of video game designers and creators in general; yet, these people, this community, has no real way to share information between themselves. Workarounds, hacks, snippets, bug history, jokes, etc; we're slaves to the system, bound to our Hollywood (Submitted RGSS/2 Scripts forums) and our technical help center (RGSS Help forum), forced, like Sisyphus, to labor again and again, reinventing the wheel day after day, toiling under the unflinching stare of our monitors to fulfill other's needs (no, not like that you pervert!).

Well, I say, no more! This fancy introduction was my attempt at making you (un)comfortable, and hopefully I have (not)succeeded. So, after all this talk, I can already hear you yelling out into the cold, lonely night : "But what is the Scripter's Corner, etheon?".

It is, as I've said in a rather long and bizarre series of incoherent and overly descriptive sentences, a place where fellow scripters (coders, programmers, rubyists, Priests of the Why, etc.) can gather 'round and share their experiences. And by that, I mean anything, literally anything that could prove useful to others: your most recent discoveries, in-depth explanations of how certain classes work, tips on original and useful ways to use built-in classes and modules, code snippets, your own classes and modules which, although not scripts in themselves, can be useful to others. That, and much, much more. Found a bug, and then a work around? Post it! Made a small library that handles common physics, such as gravity, acceleration and force? Post it! Found a quick, simple way to determine whether or not there are any events currently running? By all means, post it!

Hopefully, by now, you have a fair idea of where I'm heading with this. This is a global effort, a community effort, which will persist only if everyone chips in a little of their work. I understand some of you might feel that your hard earned work is not to be shared, because it would be stolen, and I respect that; however, I believe that sharing information amongst ourselves can only bolster the global quality of the submitted scripts and, in the long run, can be nothing short of beneficial for the community.

Now, there are no real requirements. I'll be starting off the dance, and I hope more of you will join me. I'm looking at you, Yautja! :shades:

Note : When posting your libraries/classes/modules or snippets, please make sure to share with us not only the code, but how it can/should be used and such; programmers will only use something if it is useful (though non-useful stuff can still be interesting).

I'll start off with a little class I've been working on today : my own implementation of the simple CircularList.

Class : CircularList
A circular list is a data structure which is part of the List family. More importantly, lists are a type of collections, very much like arrays. For more on lists, please see Wikipedia.

Circular lists are, as I've said, data structures; in other words, they're useful collections to handle a variable amount of related data, such as strings, integers or objects. Since in Ruby everything is an Object, this matters little to us. The difference between circular lists and lists in general is that a circular list, although it has a beginning, has no real end; it wraps around and comes back at the beginning. Now, why would we need such a thing, you wonder; I needed it, for instance, to create a generic polygon class that would handle most transformations and calculations. As such, I stored the summits' coordinates (x,y) into a collection, and I needed it to wrap on itself (so that the last summit would be connected to the first).

Long story short, here's the code. Not very well commented, I'll grant you, but eh, sue me.

Expand to see the code.


Usage : The class itself is fairly easy to use. I tried to keep a set of methods which are common to all collections, such as the .each, .length, .size and .delete methods. Usually, most method comments are self-explanatory, but in some case they might not be. The each method will work in an array like manner; it will not wrap around. That would've been an endless loop.

Instantiation of a list is done with the following :

Expand to see the code.


The [object] part can be replaced by any type of object; it will be encapsulated within a Node class, which is an internal class of the CircularList class (it shouldn't be used elsewhere; at list, not until someone makes a List module). My node class goes both way; you can go forward or backward, as you please. Just don't use it directly; instantiation requires a reference to its list.

Method : events_running?
Someone asked the following question in the RGSS Help forums : "How do you check if there are any events currently running?"

I was quite puzzled by this, and after some research, I found a very, very simple solution, which was buried beneath layers of (weird) code.

Expand to see the code.


It will return true if there are any events currently running; a better version, although with a slight overhead, would be :

Expand to see the code.


Seems useless, but it would allow a scripter to add code before or after the following line, which might eventually be useful. Always think flexibility, kids!

Any questions, I'll be glad to help. I have a couple more classes and modules to share; for instance, I'm working on a basic Geometry module which will allow of some of the most common 2D shapes manipulations, including ellipses, (ir)regular polygons, circles, etc.


Last edited by e on Tue Mar 04, 2008 6:18 am, edited 1 time in total.

Top Top
Profile      
 

    khmp
  Wed Mar 05, 2008 5:42 am
The glass is helpful.
User avatar
Sponsor


Location: Haddonfield, NJ
Good job starting a topic like this etheon! My bit of contribution is actually a request someone asked of me once. I hope he doesn't mind me posting it here. For those that read the first four letters of the alias_method, loip is not the requester. It stands for Lorem Ipsum, filler text, not a user. Coincidentally there is also a user by that name, again nothing to do with him/her.

Class : Window Base
Its an extension of Window_Base. You ever see those screens with the Windows that slide onto the screen shifting between translucent to opaque. That's exactly what this can accomplish. Small little features like these are just eye candy but can add a nice touch to a project.

Expand to see the code.


Usage : Sliding does not occur if you don't want it to so no worries if you install this script. The most important addition is calling the method slide_to. It requests four parameters. First is the x coordinate, that when the window is active will attempt to get to. Next is the y coordinate where the window will attempt to get to. Then the number of frames you would like it to take to reach start to finish and vice versa. Last is the opacity of the window when it reaches its final destination. Lastly and most importantly the active boolean of the window dictates when and where its moving. When it reaches a location it will not move until the active flag changes.

Sorry for stealing your post's formatting style etheon. Trying to keep it consistent.

_________________


Top Top
Profile      
 

    e
  Wed Mar 05, 2008 6:30 am
shittybutt
User avatar



Location: Berlin
Pretty neat. You know, games weren't really made for the usability people; every gamer wants eye candy, and (s)he wants it now! Well, you do have the weird ASCII gamers, but...eh, what can I say? They're ASCII addicts. ASCII art? Pfah! ;)

Anyway, I haven't quite gotten around to making animations and the likes; I've actually never tinkered much with "smooth" animation, in any language, and I'm not too sure about where to begin. Making a huge number of a graphical updates on every tick always seems so inefficient to me, but I suppose it's not. You know, I reckon that, if you know your way around the various graphical classes, perhaps you could share a little tips on animating objects with RGSS...efficiently? I know I'd appreciate!

Also, I'm not sure I understand what your "tolerance" variables are. Care to explain how they're used, and why?


Last edited by e on Wed Mar 05, 2008 6:32 am, edited 1 time in total.

Top Top
Profile      
 

    khmp
  Wed Mar 05, 2008 7:35 am
The glass is helpful.
User avatar
Sponsor


Location: Haddonfield, NJ
Tolerance. Because I wanted to avoid computing the distance between where it was and where it should be I created tolerance. This variable lets me know how much is left over. If I'm close enough to tolerance stop moving. There might be a noticeable gap between where you actually want it to go and where it is on the screen.

Animation. As a school assignment using a C++ win32 console project we had to make an animation class which contained a dynamic array of frames which were also classes. And we only had to prove that it could idle and perform three different actions. I wonder if I still have it. I made a cat that could puke a hairball, scratch the curtains, and die. The first two went back to the idle animation after 2 seconds. The third... well it exited. That is the only experience I have in creating animation more of state machine but animation to me. No textures or 3D models though only a ":3" cout. :lol:

_________________


Last edited by khmp on Tue Apr 08, 2008 10:15 pm, edited 1 time in total.

Top Top
Profile      
 

    DrakoShade
  Wed Mar 05, 2008 7:57 am
User avatar
Member

Removed

_________________
Give a man a fire, and he's warm for a day...
Set a man on fire, and he's warm for the rest of his life.


Last edited by DrakoShade on Sat Jan 16, 2010 11:03 pm, edited 2 times in total.

Top Top
Profile      
 

    e
  Wed Mar 05, 2008 8:12 am
shittybutt
User avatar



Location: Berlin
Seems cool, and I like how it uses the generic distance between points function. However, I'd point out a few things :

1. Using a switch/case for solely two cases is pretty useless. You'd be much better of with an if/else, especially since Ruby does not differentiate between cases and ifs. Once interpreted, it's exactly the same byte code. Hence, using case is useful only with a larger amount of cases that would require more than one elsif.

2. Parameter names. "param1" or "param2" doesn't mean much to me; it confuses me more than anything, and I'll have a harder time trying to remember the syntax of your function. You should, instead, give them names such as "method_flag", "round_flag", "character", etc.

3. Remove the useless param4. Instead, if the method is 2, assume that param3 will be either an array such as [ x, y ] or an hash such as { :x => #, :y => # }. That's not really needed, but it's so when you use method 1, you don't have to do : get_distance(1, -1, 1, nil, 1). See the useless nil? Eh.

4. Why is param5 an integer? Shouldn't it be a boolean? That way, you could replace :

Expand to see the code.


By more elegant and rubyesque :

Expand to see the code.


Those are all suggestions; I simply think it'd improve the readability. All in all though, pretty useful method!


Top Top
Profile      
 

    DrakoShade
  Wed Mar 05, 2008 8:22 am
User avatar
Member

Updated with your suggestions.  I'm still learning the art of clean code...

_________________
Give a man a fire, and he's warm for a day...
Set a man on fire, and he's warm for the rest of his life.


Top Top
Profile      
 

    e
  Wed Mar 05, 2008 8:27 am
shittybutt
User avatar



Location: Berlin
Eh. Ruby is wonderful for clean, crisp code. I'll admit, though, learning Rubyisms (as they're called) and their conventions takes some practice (and time...lots of time).  :thumb:


Top Top
Profile      
 

    killer_873
  Fri Mar 07, 2008 3:14 am
User avatar
Member


Location: Your Mother's Danger Zone
Is there anyone who could give me tips on how to script Rpg maker xp into an over the head shooter?

Ven: This is not the place for that stuff, bub.

_________________
A GIANT BURRITO WILL EAT YOUR FACE!!!!!!!!!!!!!!!!!


Last edited by Venetia on Fri Mar 07, 2008 4:33 am, edited 1 time in total.

Top Top
Profile      
 

    e
  Fri Mar 07, 2008 4:17 am
shittybutt
User avatar



Location: Berlin
That wouldn't be here; you should probably ask this in the RGSS Help forum. This topic is for scripters who want to share ideas and code, and not for requesting help.


Top Top
Profile      
 

    Zeriab
  Sun Mar 09, 2008 1:55 am
Hugging Lion
User avatar
Sponsor

Great idea etheon ^_^

I have looked at your circular list and in general it looks nice ^^
Notes on your circular list:
Why do you say the Node class is private when it is public?
The comments for the insert methods in the Node class talks about an object argument that is not present in the actual method.
You should include the Enumerable class in the CircularList class, especially since the class you already have written an each method. A simple include Enumerable and you get loads of sweet functions for free: http://www.ruby-doc.org/docs/Programmin ... rable.html

Here are a few contributions:
Linked List


The next is something I have submitted as a script, but it really fits better to this thread than as a separate script.
Module add-on (Copy of the topic)


I hope the best for this topic ^^
*hugs*
- Zeriab

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    e
  Sun Mar 09, 2008 2:08 am
shittybutt
User avatar



Location: Berlin
That's pretty neat Zeriab. I hadn't really thought about using the Enumerable module as a mix-in for my CircularList; the only time I've created such a structure was in C, so I kind of just modified my existing logic to fit Ruby. Good idea though; I'll play around with it.

As for me specifying my Node class is private, believe me, I know it isn't. But, theoretically, the programmer shouldn't use it directly; instead, let the CircularList, or any List which uses the node, deal with it. It was more of a warning not to use it directly.

Oh, and as for the object parameter in the insert method, it must be a remnant of a previous version and I simply forgot to remove the comment :tongue:

Nice list, by the way. And I have to agree with you: double-linked list are usually a much better and safer choice their single-linked counterparts.


Top Top
Profile      
 

    khmp
  Fri Mar 14, 2008 9:28 pm
The glass is helpful.
User avatar
Sponsor


Location: Haddonfield, NJ
Another new addition to Scripter's Corner. Well its for anyone that can wield it really. I would have released it to Submitted RGSS/RGSS2 Scripts but its somewhat incomplete and I would rather much hear if any of you more knowledgeable types have any advice or notes for me on this subject matter.

History:
Probably the first month I was here I suggested to myself to make a script that would join maps together. I quote myself in saying it would take me two weeks. That was Septmember '07. I think jbrist asked me about it but I'm not sure if that's correct. Regardless I think after I thought about it for about 5 minutes total I dropped it. I had almost completely forgotten about it until a week ago when I found a text file containing the psuedo code. I then spent the past 4 days of this week working hard, and the last 2 trying to figure out why I had eventing bugs and various other crashes. Note that there is a big difference between:
Expand to see the code.

and
Expand to see the code.


I know I'm not the sharpest tool in the shed but that took way too long to find. Once that was finished it clicked together and it's alpha is done. I say alpha only because it doesn't do start position events. It's hard coded that you start at the top left of the first piece. It also leaves trash lying around until next run time. Maps I mean. I should probably have more error/valid data checking. Events are renamed in most cases so if you have events that depend upon other names someone ensure they are only copied once.

class : Map_Joiner
What practical use would this serve? Well let's say you want to design a game like .hack//. In .hack// games, for those that don't know, maps are constructed via a keyword entry system. Different keywords generate different results. So rather than create a million and one maps. You would have pieces that could be assembled differently to obtain unique results during run time. This class does not task itself with how the map is assembled. It only assembles the pieces algorithm tells it to. It's up to the user of this script to determine how the algorithm method decides what pieces are placed where.

Zed Code:
[code]#==============================================================================
# Script Name: Map Joiner
# Author: khmp
# Version: 0.0.1
# Date Last Modified: 3/14/2008
#==============================================================================

=begin
Psuedo-ASCII art per Sir. etheon's request. 
    / \
  /___\
  (/^@^\)
  \_-_/        <- Is it a face or a lawn gnome from behind?
â €Å’â € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ € ‚¬Ã¢ €

_________________


Last edited by khmp on Sun Mar 16, 2008 12:29 am, edited 1 time in total.

Top Top
Profile      
 

    e
  Fri Mar 14, 2008 9:42 pm
shittybutt
User avatar



Location: Berlin
Looks good. I can't really see when I'd use such a thing, although I suppose it could work for things like dungeon generators? I have no idea what algorithm I'd use. Perhaps some kind of weight/cost or classification of the "tiny" maps. Eh.

Oh, and you should raise a NotImplementedError in methods to override. Just to make sure the scripter gets it :thumb:


Top Top
Profile      
 

    e
  Mon Mar 17, 2008 6:13 am
shittybutt
User avatar



Location: Berlin
You'll excuse me for the double post, but I've redone my Circular list structure; it's now a class "Circular" within the "List" module, which also contains the "Element" class. It also includes the Enumerable module, and I think I've generally adapted it to Ruby in a much better way.

Module : List
Please review the first post of this topic for what exactly is a list.

The following is a module, called List, which contains the following classes : Element and Circular. Theoretically, one could create many types of Lists, not necessarily Circular, and embed them within this module to use the Element class; thus, you could quickly swap from one list type to the other.

Anyway, I think the code is well commented enough. Please remember that the Circular class also includes and works with ALL methods from the Enumerable module.

Expand to see the code.


Usage
I'll elaborate more on this tomorrow, but for now, here's a little tidbit:

Expand to see the code.


Last edited by e on Mon Mar 17, 2008 6:49 pm, edited 1 time in total.

Top Top
Profile      
 

    DocClox
  Mon Mar 17, 2008 5:47 pm
Member

etheon wrote:

Note : I still have a memory leak problem when clearing the list. If anyone has a good solution/idea to remove ALL reference to an element EFFICIENTLY, please post it!


Could it be that the garbage collector isn't reclaiming your list because of the circular reference? Every object in the chain is pointed at by another, so it looks to ruby as if they're all in use?

If so you might find you can fix it by  breaking the circle before you clear it.  You might need to clear the back links as well since it's a double linked list. Shouldn't have any great overhead issues unless you're either clearing the list a lot or else you have very big lists.


Top Top
Profile      
 

    e
  Mon Mar 17, 2008 6:50 pm
shittybutt
User avatar



Location: Berlin
I've updated my Element#dispose and Circular#clear methods; it shouldn't have memory leaks anymore. I think I've pretty much managed to remove all references to my Elements.


Top Top
Profile      
 

    khmp
  Tue Apr 08, 2008 11:13 pm
The glass is helpful.
User avatar
Sponsor


Location: Haddonfield, NJ
I bring a new toy. Math_Vector3, but he is only a tool to get the toy to work properly. Also I owe a lot to a Mr. verballydecapitating for helping me with the Sprite_Float class. Anyway another little addition to a project someone might want to include is a picture that assembles in blocks to form the larger image. You shouldn't need to physically split the image to get this effect thus my reasoning.

Class : Math_Vector3

Expand to see the code.


That class has all the standard uses for a 3D Vector nothing special.

Class : Sprite_Float

Expand to see the code.


Again what's the use of Math_Vector3 containing Floating point numbers if the object that uses them is stuck using Fixnum.

Now for the biggie. These classes are used to represent parts of an image in individual sprites. This way they can moved around separate from each other and create some assembly effects. Sprite_Chunk is just a solitary sprite that holds part of an image within itself. Sprite_ChunkS err Sprite Chunk System is used to maintain these individual Sprite_Chunk's updating and disposal. It's utilization is pretty simple.

The standard three.
init:
Expand to see the code.

A word to the wise. Only the first parameter is required. The 4th parameter defaults to nil and if left nil than the pieces will start at random locations on the screen. Also size is despair in a cape. Low numbers mean more sprites that need to be created. Putting a one in there for example is a terrible idea and will eat up too much memory. I capped it at 4 I think.

update:
Expand to see the code.


disposal:
Expand to see the code.


Class : Sprite_Chunk, Sprite_ChunkS

Expand to see the code.

_________________


Last edited by khmp on Tue Apr 08, 2008 11:27 pm, edited 1 time in total.

Top Top
Profile      
 

    Zeriab
  Sun Apr 20, 2008 8:38 pm
Hugging Lion
User avatar
Sponsor

Here is a rather useful snippet I just cooked up.
This prevents the F12 key from resetting the game.
For some reason pressing the F12 key now seems to speed up the game in many cases and in other pauses the game.

Expand to see the code.


For an extreme example of the speed up issue I mentioned here is a picture:
http://img89.imageshack.us/img89/438/speedboostlx8.png[/img]

I don't know whether it actually went with 410 FPS or if something broke.

_________________
Image
Image
Image
Image
Image


Last edited by Zeriab on Sun Apr 20, 2008 10:21 pm, edited 1 time in total.

Top Top
Profile      
 

    e
  Mon Apr 21, 2008 12:18 am
shittybutt
User avatar



Location: Berlin
Correct me if I'm wrong, but usually, before doing a transition, you do a Graphics.freeze, right? I'm guessing that would prevent the FPS count from jumping up.

Or I might be wrong. That was just off the top of my head.


Top Top
Profile      
 

    Zeriab
  Mon Apr 21, 2008 7:27 am
Hugging Lion
User avatar
Sponsor

If the player press F12 during a transition the transition will reset and start again.
If F12 is kept pressed the game will feel like it has been paused. The FPS registered will typically be registered as higher although game playing will not change. Nor will it if it's Graphics.update being cancelled. The shown timer will however run faster.
Here is a snippet where it feels like the game simply pauses when pressing F12, if that is what one prefer:

Expand to see the code.

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    boon
  Mon Apr 21, 2008 12:24 pm
"What's this, Hubert?"
User avatar



Location: London
That now seems to make the game take 2-3 times the time to load as it normally does.

EDIT: It's all to do with the arrangement of the scripts. I moved it up to below Scene_Debug and it loads the same speed as before I Installed it. It's very useful. The Speed-Up one kindof nulled having to get running shoes, as the FPS made the character walk very fast.

_________________
twirly is a *bleep*


Last edited by boon on Mon Apr 21, 2008 12:29 pm, edited 1 time in total.

Top Top
Profile      
 

    DrakoShade
  Wed Apr 23, 2008 8:28 pm
User avatar
Member

I've edited my first post in this thread with what I feel is an improvement upon the older code.  The method is now much easier to call without having to input unnecessary arguments.

_________________
Give a man a fire, and he's warm for a day...
Set a man on fire, and he's warm for the rest of his life.


Top Top
Profile      
 

    hanmac
  Mon Apr 28, 2008 9:50 pm
Member

Multidimensional Array and Hash.

makes automatic n-dimensional without a size limit.

Content Hidden


call this with:

Expand to see the code.



PS: this is in development.

Bugs:
-this array is not homogen. -> have not equal size
-without a sizelimit, you can make a space overflow
-has no each or include method. -> so you can't search


i hope you gus help me.

_________________
every thing is true, if true has a specific value.


Top Top
Profile      
 

    Dargor
  Sat Jul 05, 2008 4:22 pm
User avatar
Retired Staff

Party Mascot

Location: Quebec / Canada
It's been a while since someone posted here. Well, I have something new for you!
That's a class_defined? method for the Object class.
Object class_defined?

call this like that:
Expand to see the code.

_________________
Final Fantasy VI SDK
Image

Stay in touch, ask me anything, receive updates and try out the lastest versions!

Image Image Image Image Image

Tutorials


Last edited by Dargor on Sat Jul 05, 2008 4:41 pm, edited 1 time in total.

Top Top
Profile      
 

    rey meustrus
  Sat Jul 26, 2008 6:08 am
Master of Dark Magic
User avatar
Sponsor

Party Mascot
I sure hope that 20 days isn't considered necroposting...

I just wanted to compliment khmp on that "chunks" addition.  I tried it out and it looked quite spiffy.  Though, I did have to write Math::distance to make it work.

I'm going to make an addition to this place soon, something that as I understand it SephirothSpawn likes enough to put in the SDK once I'm finished debugging and rewriting some of the classes to use it.

_________________
Image


Top Top
Profile      
 

    rey meustrus
  Mon Jul 28, 2008 9:21 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
Alright...nobody likes to post.  This place is far slower than I remember it, although the last time I was really active was on .net right before it went under...

This is a Scene_Base which is capable of layering scenes on top of each other.  What that means is, the new scene will act as an instance variable to the parent scene, causing some of the parent scene to cease updating while the layer is active, but some of the parent scene will still update.  To put it less abstractly, you will not only have the spriteset for the map under the menus, you will also see the events working behind the menu as well.

New scenes are called by new_scene(object_name[, *args]).  If this is called from $scene, which is the root scene and has no parents, then it will end up calling $scene = object_name.new(nil, *args) (that nil represents the parent of the object, which doesn't exist because $scene is the root scene).  If called from a layered scene, it will replace that layer with whatever scene is being called, or, if the object is the same as the parent, it will simply remove that layer and return operation to the parent scene (this is also accomplished with new_scene(nil))

New layers are called by new_layer(object_name[, *args]).  As soon as the layer is called, it is completely initialized (all of the main_ classes from main_variable to main_transition) and def update of the parent class ceases to be processed (though def update_background will always be processed).  The layer creates a Graphics.freeze and Graphics.transition to fade into the new "scene."  The function basically calls @layers.push(object_name.new(self, *args).

Each scene has its own array of layers, rather than just one, and each layer has an @active variable.  If a layer is inactive, it will not call its own update functions (SephirothSpawn's auto_update will still update anything that isn't a Window_Selectable), nor will it prevent its parent from updating.  This would allow the creation of intentionally inactive layers which simply add windows or sprites on top of an existing scene, like Scene_Map.  A HUD, for example, could be easily created and disposed of as a layer, with a call script something like $scene.new_layer(Scene_HUD) and $scene.clear_layers (which, OMG, clears all layers of that scene!)

On top of that, this class contains standardized methods for animating the entry and exit of any and every scene.  main_animation_loop is called every frame until main_animation_loop_done? returns true (it always does so by default).  When the scene is disposed of for any reason, it starts to call main_out_animation_loop every frame until main_out_animation_loop_done? (which is also set true by default), at which point it disposes (def dispose calls main_out_transition, main_dispose, and main_end, among other internal things).

This was designed to fit into the SDK, so its class name is SDK::Scene_Base.  If you want to change it to something else, make sure to run a Ctrl + H replace on all instances of the name as the script checks to make sure that all layers and parents are based on that class.  Additionally, it comes with alterations to SDK parts III and IV which provide the new functionality by ensuring that a) Scene_Map has its update divided between background processes and those which aren't updated if a layer is present, b) All def initialize functions have "parent" as their first value, which they super() to Scene_Base, and c) All new scenes and layers are called with the new_scene and new_layer functions.  If there is demand I may look into porting this to VX.

SDK::Scene_Base
SDK Part III Scene Class Modifications
SDK Part IV Scene Class Modifications

_________________
Image


Top Top
Profile      
 

    trebor777
  Tue Aug 05, 2008 11:11 am
Member

Simple syntax tips:

Math, Power by:
Expand to see the code.


use "unless", instead of "if not"

Lighten your code: include your modules into classes
Expand to see the code.


Use constants over Global Variables if they don't have to change.
If a constant isn't defined into a class, then it's accessible from everywhere.

you can also use Class variables, to act as constant, or as uniq variables, for a class.

Basically use Global variables if you don't have any other choice.

You don't have to write parenthesis to pass an argument for a method. just a space is enough, though it might improve readability.

Special Method name:
how do  -1 works? or -variable ?

well there is a method defined like this: 
Expand to see the code.

Pretty usefull to know when you're scripting math related class. ^^


Rotate arrays, can be usefull sometimes :p
Expand to see the code.


Top Top
Profile      
 

    rey meustrus
  Sun Aug 10, 2008 9:16 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
I've updated the Scene_Base again, and I'm going to give you an example of how easy it is to create useful layers with it.  First you need to install the SDK, including part 3.  Then install my SDK::Scene_Base and the modifications to SDK part 3.  You're all set to begin.

Put in this very small and very simple script:
Expand to see the code.

Now call this script from the map:
Expand to see the code.

You've got a little window there now to tell you what the map's display X and display Y are!  This isn't necessarily an important feature, but you can fill your HUD with whatever you want.  The important part is @active = false, as this tells Scene_Base that this layer isn't important enough to stop the processing of Scene_Map.  The window will stay there until you call a script that says:
Expand to see the code.

Alternatively, you could simply delete all layers:
Expand to see the code.


EDIT: I feel like I'm not up with the spirit of this thread all the way.  Maybe this is for smaller tips, not full-blown scripts like this.  It might be better to split this post and my last one into a new thread entitled "Scene_Base with Layering Capabilities" for RMXP.

_________________
Image


Last edited by rey meustrus on Sun Aug 10, 2008 9:19 pm, edited 1 time in total.

Top Top
Profile      
 

    Zeriab
  Sat Jan 03, 2009 4:59 pm
Hugging Lion
User avatar
Sponsor

Here's a little something if you want to be able to print out the contents of a Table:
Expand to see the code.


You can simply use p table after inserting this.

*hugs*
- Zeriab

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 148 posts ]  Go to page 1, 2, 3, 4, 5  Next


Who is online

Users browsing this forum: No users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

We are an independent, not-for-profit game making community.
Homepage
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group