The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: jet10985 on April 15, 2010, 11:46:13 PM

Title: Jet's Code Snippets (44 Total)
Post by: jet10985 on April 15, 2010, 11:46:13 PM
Jet10985's code snippets

Introduction

Spoiler for:
This is my collection of code snippets i make for fun. I just release to the public in case they want them or see them as handy. This is not a shop, don't ask me to write you a snippet. I write these in my spare time and therefore, requests ruin my fun.

Snippets

Spoiler for:
Due to the post character limit, I cannot post my snippets all seperate and such...

So, i'll post a link to my updated script collection which contains all my snippet/scripts in their newest forms. Please note the collection does not demonstrate them, it just holds all of them into convenient categories. =)

Here is the collection for you to enjoy.

Link is broken, so I attached it to the bottom of this post (http://rmrk.net/index.php?action=dlattach;topic=38168.0;attach=23300)


If you use any of these snippets, please credit me and anyone I credit in the snippet
Title: Re: Jet's Code Snippets (34 Total)
Post by: modern algebra on April 15, 2010, 11:52:23 PM
Wow, that's a ton of scripts. I'll have to check them out :)
Title: Re: Jet's Code Snippets (34 Total)
Post by: jet10985 on April 15, 2010, 11:54:15 PM
Well, most are pretty small, but thanks for checking them out ;)
Title: Re: Jet's Code Snippets (34 Total)
Post by: Mr_Wiggles on April 16, 2010, 01:12:10 AM
Some times the small ones make the biggest im packs.

[edit] your menu is odd, when you click load it moves the selector up to save.  NVM, i just realized that its not a demo only a holder for the scripts, my bad.  Nice collection.
Title: Re: Jet's Code Snippets (34 Total)
Post by: Zeriab on April 16, 2010, 08:07:54 AM
I had a quick look and have some comments for your JetEngine
I would suggest that you don't expose the inner data structures through global variables, but rather provide module methods for what you currently are using them for.
You already have come a good way with current module method.

Instead of
Code: [Select]
unless $engine_scripts.nil?
  JetEngine.active("Run/Guard Hotkey", 1)
end

you can use
Code: [Select]
if Module.constants.include?("JetEngine")
  JetEngine.active("Run/Guard Hotkey", 1)
end

*hugs*
Title: Re: Jet's Code Snippets (34 Total)
Post by: modern algebra on April 16, 2010, 02:27:32 PM
Well, it looks pretty good jet :) I'm adding them to the index now.

A couple things have popped out at me so far. First of all, this:
Code: [Select]
   if $engine_scripts.include?(name)
      return true
    else
      return false
    end

It's not a big deal, but it could be replaced with:
Code: [Select]
return $engine_scripts.include?(name)

It's just a little nicer. If you take Zeriab's advice, then you'd be getting rid of that global variable, but all I'm talking about is the if else branch aspect of it.

Also, your Change Actor Options script doesn't really work - it modifies the $data_ array but it doesn't actually modify the data file (which you wouldn't want either), so the next time you load the game it will revert to the default.

Also, when you use the change_two_swords_style method you should be careful and unequip whatever the actor might have in his second hand before doing it. Otherwise, it will convert whatever armor/weapon he has in it to the weapon/armor of the same ID.
Title: Re: Jet's Code Snippets (34 Total)
Post by: jet10985 on April 16, 2010, 10:27:05 PM
@zeriab: Thanks for the advice, i really appreciate new ways to do things. I think i'll keep it the way it is for now though, so i don't have to go through changing stuf ;)

@MA: Yeah, the method isn't my best.
As for the change Actor Options, i had no idea about the reverting thing. Any way you can help me with that?
Title: Re: Jet's Code Snippets (34 Total)
Post by: modern algebra on May 13, 2010, 01:57:50 PM
Sorry, I never got back to you with that I just realized :( Whoops. Anyway, it's not too difficult - all you'd need to do is save the change in a variable, probably in Game_Actor. Then you could just make it so that those methods in Game_Actor, instead of returning the data, return the one you saved.
Title: Re: Jet's Code Snippets (44 Total)
Post by: jet10985 on June 25, 2010, 03:59:25 PM
Well uh, been a while since i was on here, just letting ya know i updated the demo to hold all my current snippets (44 now, not 34) and scripts. Also MA, i fixed that Actor Options snippet ;)
Title: Re: Jet's Code Snippets (44 Total)
Post by: cozziekuns on June 25, 2010, 04:50:32 PM
Nice job Jet! These snippets seem to be nice ways of adding in small features that make the game look more professional, or ways of making things easier for regular people. I took a look at your demo and I walked around a bit and I got an error.

Script: 'Hunger/Thirst' line 546 NoMethodError
undefined method 'hunger' for Nil:NilClass

I kept everything as it was in the demo.

Also, I looked around at some other scripts. They should work fine, but there are some parts that could look a bit nicer. Unless I'm mistaken,

Code: [Select]
def screen
    if $game_temp.in_battle
      return $game_troop.screen
    else
      return $game_map.screen
  end
end

Could just as easily be:

Code: [Select]
  def screen
    return $game_troop.screen if $game_temp.in_battle
    return $game_map.screen
  end

Which doesn't really matter, but it looks nicer IMO and takes up less lines in the Script Editor.
Title: Re: Jet's Code Snippets (44 Total)
Post by: ddewerg on July 01, 2010, 06:26:55 AM
Help it dosent work! :'( when i run demo it says
Script hunger/thirst no method error undefined method hunger for nil:nilclass
Title: Re: Jet's Code Snippets (44 Total)
Post by: Linkx7 on September 18, 2010, 07:00:51 AM
On mediafire can't download so it's delete
Title: Re: Jet's Code Snippets (44 Total)
Post by: rofl1337 on October 13, 2010, 06:14:35 PM
link is broken. please give us a new one.
Title: Re: Jet's Code Snippets (44 Total)
Post by: modern algebra on October 13, 2010, 06:21:48 PM
Here's a link: http://www.mediafire.com/?z3iw7cw1asii2o2
Title: Re: Jet's Code Snippets (44 Total)
Post by: merryjest on June 10, 2011, 07:18:16 PM
Please forgive me if this is an egregious necropost, but I searched on the forum for any other posts dealing with issues concerning the snippet collection and found only one- unresolved. So, I thought it would be best to post on the original thread in the slim chance someone was watching. Here it is:


Jet, I get two errors using your script:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg.photobucket.com%2Falbums%2Fv22%2Fmerryjest%2FApprovalError-1.png&hash=8a0877e18d3835881a36b24d79ca8e95f213d686)


The first, A, is from my own game, when I try to increase actor approval by a called script.
The second, B, is from your own demo with no add-ons, again trying to do the same thing (I decided to test it on the demo itself to see what was going on)---  the instructions say to use the format of change_approval(1,2)  in called script (actor 1 gets +2 approval), but this is the error that pops up when you try them. Any ideas of what could be wrong?
Title: Re: Jet's Code Snippets (44 Total)
Post by: pacdiggity on June 10, 2011, 11:12:59 PM
For the second error, put a line in after line 196 that simply says:
Code: [Select]
include ActorApprovalRating
For the first error, can you tell us what you used as the script call?
Title: Re: Jet's Code Snippets (44 Total)
Post by: merryjest on June 10, 2011, 11:53:09 PM
Thanks for replying, Pacman!

Well, in the instructions it says:

To increse/decrease approval, use this in the event "Script..." command:
change_approval(actor, amount)
actor = actor id you want to change approval of.
amount = how much you want to change it by. Use a negative number to subtract.


So that's basically what I did, I had it call a script after a conversation branch choice with: change_approval(1,2)
Title: Re: Jet's Code Snippets (44 Total)
Post by: pacdiggity on June 10, 2011, 11:57:48 PM
Interesting. Try changing all mentions of approval_rating from lines 200-208 to
Code: [Select]
approval_rating?
That error occurred because there's no method for "approval_rating" in Game_Actor, but there is one for "approval_rating?". That's all I can do for now.
Title: Re: Jet's Code Snippets (44 Total)
Post by: merryjest on June 11, 2011, 01:04:44 AM
Unfortunately that causes a syntax error :/
Title: Re: Jet's Code Snippets (44 Total)
Post by: digdarkevil on August 03, 2011, 09:49:53 PM
Your Scripts Are Awesome  ;D
but
im having some problems with the cheats scripts   ;9
and i dont know how to pm you cuz im new to this website
ok so here my problem.. when i put the script below materials OR above main,i run the game and everything is going fine until i open the menu window ,, its said scipt ''window_selectable'' line 100
no methoderror Occur undefined method for (nil,nil,nil,nil,nil,nil,nil,nil,nil)array  ;9
can You Please Help Me out? :(
Title: Re: Jet's Code Snippets (44 Total)
Post by: Jensen on August 05, 2011, 11:50:18 AM
Yo!

Nicely done!

I´m using the Set Actor's Max Level-snippet, and I wonder if there
is some way (maybe via a script call) to change the max level for
the actors in-game?

EDIT:

Jet updated his script to support this feature:

Code: [Select]
#===============================================================================
# Set Actor's Max Level Snippet
# By Jet10985 (Jet)
#===============================================================================
# This snippet will allow you to set each actor to have an individual maximum
# level that they can reach in-game.
# This script has: 1 customization options.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Game_Actor: make_exp_list
#===============================================================================
=begin
How to Use:

Below these instructions is the area to choose actor maximum levels. The format
is stated next to the example. If you want more actors on these, add a comma
then follow the format of

actor id => max level
--------------------------------------------------------------------------------
To change an actor's max level, use this in an Event "Script..." command:

change_max_level(actor_id, new_max_level)

actor_id = the database id of the actor
new_max_level = the new max level of course
=end

module ActorMaxLevel

  MAX_LEVELS = {
 
  1 => 99, # actor id => max level
  2 => 20, # actor id => max level
  3 => 30,
  4 => 2   # actor id => max level
 
  }
 
  MAX_LEVELS.default = 99 # The max level for any undefined actor.
 
end

#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
class Game_Actor
 
  include ActorMaxLevel
 
  alias jet8888_make_exp_list make_exp_list unless $@
  def make_exp_list(*args, &block)
    jet8888_make_exp_list(*args, &block)
    if @exp_list[MAX_LEVELS[@actor_id] + 1] != 0
      @exp_list[MAX_LEVELS[@actor_id] + 1] = 0 if MAX_LEVELS[@actor_id] != nil
    end
  end
 
  def exp_list
    return @exp_list
  end
end

class Game_Interpreter
 
  def change_max_level(actor_id, new_max_level)
    f = $game_actors[actor_id]
    f.change_exp(f.exp_list[ActorMaxLevel::MAX_LEVELS[actor_id]], false)
    ActorMaxLevel::MAX_LEVELS[actor_id] = new_max_level
    f.make_exp_list
  end
end
Title: Re: Jet's Code Snippets (44 Total)
Post by: oriceles on October 06, 2011, 01:43:47 AM
I'm new at the forum and I'm sorry for the necroposting, but i'm using the "learn skill item" snippet. There's no way to exclude the actors that can consume an specific Item? I'm not a programmer but i'm sure it would be something like this:

Code: [Select]
21 => 3, 1 # Item id => Skill id, Classes that can use this item
  22 => 5, 1 # Item id => Skill id, Classes that can use this item
  23 => 7, 8  # Item id => Skill id, Classes that can use this item

EDIT: Bump, and have another request. Theres no way to call the  the cheat system from a NPC instead of the menú?  :'( I'm really looking for that feature
Title: Re: Jet's Code Snippets (44 Total)
Post by: nemrog on December 31, 2011, 04:44:03 PM
I don't know if it's cause I'm using a Laptop or what but I can't get the Record Window to Pop up. Is there a quick fix to that problem?