Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -



Post new topic Reply to topic  [ 148 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
    rey meustrus
  Tue Apr 07, 2009 11:33 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
What I'm saying is, when I test play, $TEST == false, and $DEBUG == false. There is no indication the editor has set any debug variables at all.

_________________
Image


Top Top
Profile      
 

    kyonides
  Sat Apr 11, 2009 1:48 am
Member

Here's a snippet I made based on Main class to help me get some debugging info that could make my life easier. I don't know if I really had to do this anyway. I hope you'll find it useful, if not, eh, well, it may be forgotten in the sands of time...

Expand to see the code.


I obviously included the #=begin and #=end just in case you feel like it should be commented out once it doesn't need to be debug anymore.

Edit:

OK, you could also paste this:

Expand to see the code.


But you'll need to paste this module above Main.

Expand to see the code.


Here's a sample of the data stored in the ErrorsLog.txt log after exiting the program abruptly due to some (stupid) errors I committed while getting a script ready to be published.

Content Hidden


If the RPG Maker had included some debugging / error logging class this would have been easier, but it isn't something we couldn't handle, is it?

Edit...

I included another method that would log some basic info regarding the events present on a map...


Top Top
Profile      
 

    kyonides
  Sun Apr 12, 2009 7:03 pm
Member

Here's another good Backup Utility for RPG Maker. It's completely based on Ruby (and its C implementations obviously) but it still runs on both of the most recent versions of the maker.

First get FileUtils, it's quite useful, even on the RPG Maker XP or VX.

Download
(This script is free software.)

Paste is above Main.

Just include this simple wrap module above Main.

Expand to see the code.


...and include this line in Main, just below "begin".

KyoBackup.project

And you'll see a pop up window telling you that it already backed up your project!!!

The directory path is the following:

If your projects are stored in...

C:/The full path to your current projects working directory/Name of your project

Then the Backup folder should be found here...

C:/The full path to your current projects working directory/Backup/Name of your project Date Time

NOTES:

On VX you might get some error message popping up regarding some file requirement (require 'etc').

There are about 3 lines that mention 'etc' or Etc., comment them out and it'll work smoothly for sure.


Top Top
Profile      
 

    silver wind
  Mon Apr 13, 2009 7:56 am
Chompil
User avatar
Member

A window to add to your scene, which handles number input.
This window will show the input number screen + text
and return the number.

new window_Input
Expand to see the code.

To use, add a window_input to your scene:

@window = Window_Input.new(text, digits)
@your_number = @window.get
@window.dispose
# no need to update/loop in the scene, just those lines above.


Top Top
Profile      
 

    hanmac
  Wed Apr 15, 2009 8:57 pm
Member

new: getter and setter for class_variables

1. version: with eval
Expand to see the code.


2. version: without eval but with more evil
Expand to see the code.


Top Top
Profile      
 

    kyonides
  Wed Apr 15, 2009 11:29 pm
Member

Shouldn't these new methods for Module class be private? AFAIK attr_reader and attr_writer or attr_accessor are already private in Module...


Top Top
Profile      
 

    hanmac
  Thu Apr 16, 2009 5:59 am
Member

yes ... you could make it private if you like


Top Top
Profile      
 

    trebor777
  Thu Apr 16, 2009 2:45 pm
Member

Hanmac, you should have precised it was creating a method for instancied object of that class, to access the class variable.

Like so:

Expand to see the code.


As it's a class variable, wouldn't be better to make a Class method instead?
Expand to see the code.


Top Top
Profile      
 

    hanmac
  Thu Apr 16, 2009 3:25 pm
Member

if you would like to have class methods use:
Expand to see the code.


PS: the second version need Ruby 1.8.3


Top Top
Profile      
 

    Zeriab
  Fri Apr 17, 2009 11:53 am
Hugging Lion
User avatar
Sponsor

That's an interesting little snippet Hanmac ^^
I do not like the name, why is it called akkr_reader? Why not attr_class_reader or something other more intuitive and better self-documenting name? I believe the price for the shorter name is in this case not worth it.

Secondly I find it odd from a design perspective that instance methods have getters and setters which refer to the class variable. It would be more intuitive to have class methods instead. Of course the could be cases where having instance methods return a class variable rather than an instance variable is preferable.
It's not so much that you can create class methods, but more the conceptual meaning of the functionality you provide. Basically, I agree with Trebor777 or at least make its purpose clear in the documentation.

*hugs*
- Zeriab

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    rey meustrus
  Sat Apr 18, 2009 11:35 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
attr_class_reader is really convoluted, class_reader is probably good enough. I would agree that having it as a class method is preferable,

_________________
Image


Top Top
Profile      
 

    trebor777
  Thu May 21, 2009 10:39 pm
Member

Equivalent of a OR statement for the same variable:

Expand to see the code.


Of course only applies for the same kind of condition ( == )
Can be useful to write shorter version if the variable or the values have long names. ;)


Top Top
Profile      
 

    Zeriab
  Thu May 21, 2009 10:53 pm
Hugging Lion
User avatar
Sponsor

Nice find trebor :D

@meustrus:
I agree that name is convoluted, which I believe fits when its an object method. (Sorry about the late reply, I didn't notice your reply before ._.)

*hugs*
- Zeriab

_________________
Image
Image
Image
Image
Image


Last edited by Zeriab on Fri May 22, 2009 9:34 am, edited 1 time in total.
Removed the script since it fits better with its own topic.


Top Top
Profile      
 

    rey meustrus
  Thu May 28, 2009 6:59 am
Master of Dark Magic
User avatar
Sponsor

Party Mascot
I must share this, because I wrangled with a solution to this problem before just looking it up in the Ruby documentation. Sometimes the RMXP help file's scripting section is really lacking...

You can create a Hash with default values by calling Hash.new(default) or Hash.new {|hash, key| default}. Further documentation. Such functionality isn't available for Array, but I determined that it would be more trouble than it's worth to give it to Arrays; just use Hashes instead if you need default values.

_________________
Image


Top Top
Profile      
 

    Zeriab
  Thu May 28, 2009 9:44 am
Hugging Lion
User avatar
Sponsor

The RMXP help file is generally lacking when it comes to the default ruby stuff.
It is a nice find with a default value constructor based on the key you have found. Something worth remembering

^_^

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    Kain Nobel
  Sun Jun 28, 2009 1:05 pm
No Rest for the Wicked!
User avatar
Member

This ain't much but when I was working on a timer request just now I made it... I'll probably hold onto it for convenience sake.

Expand to see the code.


What it does is allows you to change Graphics.frame_rate by holding CTRL and pressing F5 (decrease), F6 (increase) or F7 (reset to 40).

One thing that bugs me is Enterbrain decided to secure the Graphics.frame_rate value between 0 and 120, which I understand why but it sucks. I tried overwritting/aliasing the method to go beyond 120 just to see what it does but its something more than just doing @frame_rate = n, damn hidden internal methods!


Also, what I posted on the Milliseconds in Timer request...

Interesting find about changing Graphics.frame_rate


Go ahead, run the default timer and use this snippet to change your frame rate, you'll see exactly what I'm talking about! The timer's time will jump all over the damn place! Window_Playtime doesn't appear to be effected much, but the Timer is! You might want to keep this in mind when timing things in your own scripts too :P

Use 40 (XP) or 60 (VX) instead of Graphics.frame_rate! Also, never use Time.now for anything outside of checking what the actual time is! If you use Time.now to count-down actual in-game timers, that is a big no-no!

Ask ImmuneEntitiy! He had a Skill Timer script, meaning you have to wait [x] ammount of frames to use certain skills again. What that meant is when a player clicks off-screen and deactivates the window, then comes back his skills are already filled and he can cheat! Its because its checking the *real time* that has lapsed, and not the game's *internal frame time*

Anyways, thats my submission and tip of the day! Enjoy! :thumb:


Top Top
Profile      
 

    trebor777
  Sun Jun 28, 2009 1:41 pm
Member

Actually the timer should be frame_rate independant, and decrease the timer by the time which passed between 2frames not by the number of frames.


Top Top
Profile      
 

    Zeriab
  Tue Jul 07, 2009 11:51 am
Hugging Lion
User avatar
Sponsor

Here is a project I have created while playing around.
It removes the comments and indention from Scripts.rxdata and Scripts.rvdata: http://webgel.net/bb/files/Remove_Comments.zip
(No guarantees that it doesn't alter the semantics of the scripts)

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    Kain Nobel
  Thu Aug 13, 2009 5:46 pm
No Rest for the Wicked!
User avatar
Member

Holy cow Zeriab, nice one!!! I've got a whole buttload of scripts in my project so it made a good test, it appears that everything still works fine. For those of you who like to penny-pinch (sort to speak) on your HDD space my old script file was 477 KB and the new one was 224 KB so that a little more than halfed the space the Scripts.rxdata took up in the project.

I always figured something like this would shrink the filesize and that is simply amazing! Interesting how much memory in a file that indentation and comments take up. I haven't the time to test tonight, but I'd imagine that maybe it might make your game run just a little bit faster, (or at least start up a little faster, if it takes a second to load everything.) Running my project after I did that, it does seem to eliminated alot of those 'quick pause' moments, like when transitioning between scenes and such.

It would be silly as a scripter or general project developer to do this in mid-development, but I'd probably do this before posting a large scale project, just to save those few grams of file size lol. Not to mention, although people can crack your project and steal your work it'd be harder for them to 'understand' the scripts coding itself, since it makes it harder for a human mind to seperate and keep track of without comments/indents. =P

Next big thing is if you came up with a way to do this and then encrypt all that data, maybe even put every individual script into the one same section, that would really fry people's brains to try and decypher, especially with comments and indentation/excess whitespace removed!

Good job on this man, I was really impressed ! *Hugs*


Top Top
Profile      
 

    rey meustrus
  Thu Aug 13, 2009 6:02 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
That sort of thing is most commonly done with javascript, as normally a difference of 200kb, however large proportional to the data, is a pittance. I'm surprised it actually improves performance, though. I guess the Ruby interpreter just isn't the absolute greatest, unlike say the PHP interpreter which can compile scripts to machine code every time to improve speed (PHP 6 may have some sort of versioning system that can tell if it needs to recompile a script or not, to cache compilations and save more time?).

Will have to keep this in mind for the future.

_________________
Image


Top Top
Profile      
 

    Zeriab
  Sat Aug 15, 2009 2:01 pm
Hugging Lion
User avatar
Sponsor

And first now I realize that I released the encrypted version >_<
I did it to make it simpler for non-scripters to use. But this is the Scripter's corner so it was a mistake to upload that version here.
Here is an unencrypted version: http://webgel.net/bb/files/RemoveComments.rar
Note that only the Scripts.rxdata is included, so you'll have to provide the missing files if you want to upon it in the editor.
Feel free to mess around with it. ^^

Thanks for the nice comments Kain :cute:
I am happy to hear that it didn't mess anything up. My motivation to make it was indeed to see if you could increase the speed, both loading time, but also at runtime. I admit I didn't know whether it will have an effect other than speeding up the initial load time. (So my main focus was to remove parts which had no semantic significance)
I totally agree that you should only use it for the version you publish. It does decrease the value of the scripts due to the lack of comments.

Encrypting the data would be silly because one would have to decrypt the data again which requires modification of the DLL file.
Obfuscation is another matter, which I believe is what you actually mean.
With my other projects that I prioritize higher I won't have time to work on it for a very long time, but feel free to work on it.
You can see how I work with the library I include which makes everything loads easier.

@rey: There are no compilation of the scripts to any intermediary format. There are in version 1.9.x, but not in the version XP and VX uses. That is why this is interesting. More interesting is that the speed up seems to be actually noticeable.
I believe it's lexing, parsing and then interpreting, but I am not sure. Luckily the library means I don't have to understand how it works.

*hugs*
- Zeriab

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    Kain Nobel
  Sun Aug 16, 2009 2:14 pm
No Rest for the Wicked!
User avatar
Member

Yeah the only thing performance-wise that was improved was going from Scene_A to Scene_B and all that; ie your menu opens quicker when you call it, with the code compressed, than it would without deleting comments and excess whitespace. My theory is that it takes a nanosecond more to skip past all our optional human-readable notes and spacing while initializing an object, but without all that extra baggage the object gets created and sent to its respectable variable quicker.

I doubt this would improve the FPS on your map or anything, especially if you have a laggy event or some script bogging your project down it'll still drag it down with or without compressing the code in this fashion. My speculation is, again, it just speeds up the 'initialize' of the object, nothing less nothing more.


Top Top
Profile      
 

    Glitchfinder
  Sun Aug 30, 2009 8:28 pm
BEWARE: Glitchfinder's sense of humor sucks.
User avatar
Staff

Party Mascot

Location: Approximately 93 million miles from Sol.
After some recent experimentation, I've realized that I had an interesting tip for scripters. I've been playing around with the interpreter, and I realized that the event's "Call Script..." function actually behaves as though the script you were calling is a part of the interpreter class. Actually, to be more specific, your script is contained within the call script method in the Interpreter class. Now, this presents both opportunities and potential problems.

First off, lets list the opportunities. Since the call script function is interpreted as part of the interpreter, that means you can call any method in the Interpreter class. This means that, if you wanted to, you could call custom methods inserted into the class. You can even call methods already there, such as the one used to get the instance of any character or event on the current map.

Now, there are potential issues with this as well. For example, if you call any of the other interpreter commands, it will probably crash, because it tries to read the necessary data from the current event command, which is call script. When it tries that, it will fail. Guaranteed. Another point to be raised is that if you ever modify the @index variable, you can do one of several things. You can set the event into a loop, by putting the index at a point its already passed. You could also crash it by putting it to a point where there are no commands for it to process. Or, you could crash it by making it into a data type other than an integer.

All of this and probably more is possible with a little bit of creative thinking, and it's simple enough to actually do.

_________________

Just call me Glitch.


Top Top
Profile      
 

    rey meustrus
  Sat Jan 09, 2010 9:32 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
I've got some cool stuff for RPG::MapInfos. Mostly this is for traversing the data tree that you see in the editor, which might look like:

Expand to see the code.


Now, you can find $data_mapinfos[map_id].parent to figure out that if you're in the Mayor's House, you're actually in Town 2, or you can iterate through each sibling ($data_mapinfos.each_sibling {|sibling| print sibling.name}), or find out how many children a map has (Town 2 has 2 children) with $data_mapinfos.children.size. There is also a bit of regular expression to read bracketed data and remove it from the name of the map when it is returned for, say, a location script.

Expand to see the code.


Also, expanding on the GSM module, here is an entire User32 module. It definitely doesn't include all of the User32 functions, but it has all of the ones I was using for resolution changing, mouse input keyboard input, and part of a debug console window (making a console window is kernel32, but I wanted to bring the main window back to the front afterward and that's SetForegroundWindow in user32). It also conveniently defines HWND as User32::HWND. If you "include User32" in your class or module, you can do something like SetWindowPos.call(HWND, HWND_TOP, 0, 0, width, height, SWP_NOMOVE | SWP_SHOWWINDOW) in order to bring the window to the top and change its width and height, but not change its position, and show the window.

Expand to see the code.

_________________
Image


Top Top
Profile      
 

    rey meustrus
  Thu Feb 04, 2010 8:59 pm
Master of Dark Magic
User avatar
Sponsor

Party Mascot
I've been working on a new RMXP Tilemap script. It didn't work for what I needed it for (because it lags horribly when you zoom the whole thing out) and I haven't checked its speed against SephirothSpawn's original rewrite, but here it is. It does priorities correctly, unlike any rewrite before it, and it does this by making a Sprite for each 32x32 square. It also has animated autotiles. It is a Ruby equivalent to the built-in Tilemap class. The built-in is faster, of course, but can't zoom or have automatic Plane-like capabilities. Do with this what you will; it's probably best for educational purposes.

Expand to see the code.


EDIT: Added flash data, which is criminally easy with this approach.

_________________
Image


Top Top
Profile      
 

    trebor777
  Sat Feb 13, 2010 6:21 pm
Member

Stupid but useful...

how to swap variables without the use of a temporary variable? MAke use of parallel assignement !
Expand to see the code.


Top Top
Profile      
 

    Zeriab
  Thu Feb 18, 2010 12:02 pm
Hugging Lion
User avatar
Sponsor

It is definitely useful trebor ^^

I don't know how many of you know __END__.
The rest of that section will not be run. In fact I believe the parser will stop at __END__ and therefore won't even build the abstract syntax tree for what comes afterwards. (An effect is the lack of syntax checking)
This can be used for preventing the inclusion of test code except when you want to use it.

Here is a conceived example:
Expand to see the code.


Just comment the __END__ when you want to test.

*hugs*

_________________
Image
Image
Image
Image
Image


Top Top
Profile      
 

    SephirothSpawn
  Thu Feb 18, 2010 9:35 pm
Support/RGSS Bitch
User avatar
Retired Staff


Location: Kansas City, Mo
A neat little equipment optimizer. Can be customized for each actor, so aluxes may like weapons with atk, but hilda prefers int.

Expand to see the code.


Horray for filtering. :box:

_________________
I want to review your script!
I am always looking for scripts to look over and offer my advice on people's coding. If you want your script reviewed and to further develop your scripting skills, just put a [Review] tag in your topic. I will always post in any scripting topic marked [Review] offering whatever advice I can give.

Image


Top Top
Profile      
 

    kyonides
  Fri Feb 19, 2010 5:34 am
Member

Nice one.

I bring you another scriptlet for map names. Since we already now that we should forget about using more $variables than the ones the Maker loads if possible, this solution might help you a lot. Actually it works for both, XP and VX.

Expand to see the code.


Script call:

Map.name(id) #=> Dark Castle


Top Top
Profile      
 

    SephirothSpawn
  Fri Feb 19, 2010 6:19 am
Support/RGSS Bitch
User avatar
Retired Staff


Location: Kansas City, Mo
Ok. Here's a little something I wanted to try out. Basically works like an animated message window, but made this into a single sprite class and made it pretty easy to use.

Expand to see the code.


You create your sprite like always, and when you want to draw the animated text, just call
your_sprite.refresh(text, speed, resize)

text is just your long line of text. speed is just a simple Graphics.frame_count % speed == 0 test. Higher the speed, the slower the text. Resize is a checker I added that will resize the sprites height to make sure the text will be drawn on the bitmap.

If you want to test it:
Expand to see the code.


Just press alt when you are in the title screen. Works like a charm.

_________________
I want to review your script!
I am always looking for scripts to look over and offer my advice on people's coding. If you want your script reviewed and to further develop your scripting skills, just put a [Review] tag in your topic. I will always post in any scripting topic marked [Review] offering whatever advice I can give.

Image


Top Top
Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 148 posts ]  Go to page Previous  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