Scriptlets - A Common event like library for Scripts

pivoo

Haphazardous Scripter
Member
Joined
Jun 6, 2014
Messages
24
Reaction score
18
First Language
English
Primarily Uses
RMMV
Scriptlets V1.1.2
Pivoo

Introduction
Hello! I am Pivoo and I guess its about time to release my first plugin to the world!
This is Scriptlets. It is a database of Script Calls in a similar vain of how Common Events work. it was created to be able to shrink down and organize code that sometimes gets out of hand or too long. some of its uses include shortening down damage formulas and other plugins note-tags, and having code run via Auto-run or a Parallel Process.

Features
- The ability to create and store an infinite number of Scriptlets inside the plugin parameters
- the ability to run large amounts of code in small amounts of characters.
- the ability to have code run when the game boots up.
- the ability to run code as a parallel process or auto-run loop.

Screenshots




How to Use
most of the plugin is set up in the parameters. simply create a Scriptlet, add an item to the list and fill out the parameters. some of the parameters are.
- Name: Mainly for organization, not required to be filled in.
- Script: The Meat and Potatoes of the script. put js in here and watch it run(or crash)
- Type: The type of Scriptlet it will be, there is currently 4 types of Scriptlets.
*Note: all Scriptlets can also be run using a Script Call or Plugin Command,
regardless of what type of Scriptlet it is.
- Normal: A normal Scriptlet. Will not run unless specifically called for.
- Initialize: This Scriptlet will run at the start of the game(The Creation of the Boot
Scene)
- Parallel: This Scriptlet will run once a frame while in map or in battle.
- Autorun: Similar to the Parallel but will lock down the game instead of working in
the background
*new*
- Close - this will run when the game window is closed, currently only works for
Desktop Versions of RPG Maker

- Condition: this is a bit of js that runs to check whether or not this Scriptlet will run.

To run a Scriptlet. you can choose one of two ways. one way is to do a Script Call. to do this simply run this in a script box or anywhere else that accepts Js.
Code:
$js.run(id, arguments)
the other way to run Scriptlets is via a plugin Command. to do so just type this into a plugin command.
Code:
RunScriptlet id arguments
*new*
you can now use Escape Codes in text boxes and such! to use it now use
Code:
/js[id]
Script


FAQ

Q: How do I call arguments?
A: simply use this
Code:
args[x]
just make sure that x is equal to the argument number. remember, id is also an argument

Change-log


V1.1.2
- cleaned up a-lot of code
- changed Condition from an evaluation to an anonymous function
- changed how Type Scriptlets are handled to help reduce lag with alot of scriptlets loaded
V1.1.1
- fixed a few bugs with Escape Character Scriptlets
V1.1.0
- added Close Type Scriptlets
- added Escape Character Support
- added args[x] to replace arguments[0][x]
- shifted the index of Scriptlets up by one, as well as making Scriptlet # 0 return null

Credit and Thanks
- Pivoo
- SumRndmDude & LTN Games for helping me solve a few bugs!
- Kino and Waynee95 for helping with Closing Scriptlets Types
 

Attachments

Last edited:

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
556
Reaction score
794
First Language
English
Primarily Uses
RMMV
Well done on the release and I hope everyone gets use out of this; this is good work that's been done. Being able to run scripts on initialization is great, and so is being able to catalog them.:kaopride:
 

dahlys

Meatbun
Veteran
Joined
Aug 28, 2017
Messages
95
Reaction score
99
First Language
English
Primarily Uses
RMMV
This looks useful! I have entire common events that consist of 10+ script calls from start to end. It's just so much faster and easier to do a script call than search through rmmv's GUI, and so much more can be done (elegantly). I don't really understand how it works from your explanation though, do I just dump the stuff that were in the script calls into your plugin parameters box and have your plugin call it? Can I include script calls and conditions from other plugins within the scriptlet? Is value for when the scriptlet returns something? What about setValue?

E.g. If I toss a for loop into the scriptlet, it writes a string and stores that into a variable. What will happen when I try to use value and setValue? Does that only work when the scriptlet returns an object or variable?

Also, it is possible to have a condition in a scriptlet and use that for if/else in the GUI? E.g. If ($js.run(x,y,z)) {}

Lastly, can I do anything javascript within the scriptlet? Define new var and functions etc.

Sorry for bombarding you with questions.
 
Last edited:

pivoo

Haphazardous Scripter
Member
Joined
Jun 6, 2014
Messages
24
Reaction score
18
First Language
English
Primarily Uses
RMMV
This looks useful! I have entire common events that consist of 10+ script calls from start to end. It's just so much faster and easier to do a script call than search through rmmv's GUI, and so much more can be done (elegantly). I don't really understand how it works from your explanation though, do I just dump the stuff that were in the script calls into your plugin parameters box and have your plugin call it? Can I include script calls and conditions from other plugins within the scriptlet? Is value for when the scriptlet returns something? What about setValue?

E.g. If I toss a for loop into the scriptlet, it writes a string and stores that into a variable. What will happen when I try to use value and setValue? Does that only work when the scriptlet returns an object or variable?

Also, it is possible to have a condition in a scriptlet and use that for if/else in the GUI? E.g. If ($js.run(x,y,z)) {}

Lastly, can I do anything javascript within the scriptlet? Define new var and functions etc.

Sorry for bombarding you with questions.
Hey Thanks for checking out my plugin. I'll try to answer your questions from top to bottom.

First; Most of your script calls should work as long as they don't mention 'this'. ex; this._window = {}; the issue there is that this typically for script boxes will call the game interpreter; whereas Scriptlets run in their own functions generated at the beginning of the game.

Script call's should work from other plugins. although I haven't done too much testing with this, as long as whatever the other plugin is referencing has been loaded in(which could be an issue for some initialize Scriptlets).

Value is actually the string of the script itself; although realizing now that this could cause confusion; it is meant as a way for people to be able to view their Scriptlets, and setValue is made for them to edit their Scriptlets in-game if that is so desired.

as for having the Scriptlet return something. Scriptlets function almost identically to Js functions. so to get them to return something; you simply need to add 'return' to the beginning of the line that you want to return. ex.
Code:
var x = args[0];
x++;
return x;
using said return method; you can use Scriptlets to do if statements.

as for defining new variables and functions inside of a Scriptlet. unfortunately everything defined inside of a Scriptlet is local and will be deleted at the end of the Scriptlets run. this can be solved by using existing global objects such as $gameVariables and global.

Feel free to ask me more question's. I'm sometimes here.

Best of luck with all your game making dreams.

-Pivoo
 
Last edited:

dahlys

Meatbun
Veteran
Joined
Aug 28, 2017
Messages
95
Reaction score
99
First Language
English
Primarily Uses
RMMV
@pivoo Thanks for your quick answer!

Okay, it seems that your first answer is actually my biggest problem -- most of my script calls involve this._mapId or this._eventId in some way. I'm trying to make events respond to the player's actions dynamically, which involves a lot of event remote control, tons of self switches and variables to give my npcs an "identity". I do stuff like give npcs their own pocket money so the player gets to pickpocket them with differing difficulty per npc --> pick-pocketing is a common event containing loads of this.eventId. Even my own plugin was thrown into game interpreter so I could abuse this. stuff.

The scriptlets for if statements will definitely come in useful when I have long conditions like if (a || b && (c || d)) {return true;}

I'm fine if everything defined within a scriptlet is local, as long as I get to make script calls 10 pages long without the limit of the rmmv box.
 

pivoo

Haphazardous Scripter
Member
Joined
Jun 6, 2014
Messages
24
Reaction score
18
First Language
English
Primarily Uses
RMMV
@pivoo Thanks for your quick answer!

Okay, it seems that your first answer is actually my biggest problem -- most of my script calls involve this._mapId or this._eventId in some way. I'm trying to make events respond to the player's actions dynamically, which involves a lot of event remote control, tons of self switches and variables to give my npcs an "identity". I do stuff like give npcs their own pocket money so the player gets to pickpocket them with differing difficulty per npc --> pick-pocketing is a common event containing loads of this.eventId. Even my own plugin was thrown into game interpreter so I could abuse this. stuff.

The scriptlets for if statements will definitely come in useful when I have long conditions like if (a || b && (c || d)) {return true;}

I'm fine if everything defined within a scriptlet is local, as long as I get to make script calls 10 pages long without the limit of the rmmv box.
What you can do is add 'this' as an argument, then call it by doing arguments[1]. for example
Code:
$js.run(1, this);
and in the scriptlet do
Code:
var x = args[1];
 
Last edited:
Joined
Feb 18, 2015
Messages
560
Reaction score
296
First Language
English
Primarily Uses
RMMV
I'm attempting to use a bit of code from here (https://rpgmakermv.co/threads/useful-missing-javascript-functions.2805/) to make a scriptlet that will allow me to capitalize the first letter of a variable that's set to a string. I pasted the code snippet into the "Script" area, but when I try to use the escape code \js[1], the text instead says "undefined" and then the value of the variable.
Am I just missing a step?
 

pivoo

Haphazardous Scripter
Member
Joined
Jun 6, 2014
Messages
24
Reaction score
18
First Language
English
Primarily Uses
RMMV
@GameFire could I see specifically what you did? cause if you put in
Code:
return args[1].charAt(0).toUpperCase() + args[1].slice(1).toLowerCase();
it should work.
P.S. Sorry for the late reply, I don't check the forums too often :rswt
 
Joined
Feb 18, 2015
Messages
560
Reaction score
296
First Language
English
Primarily Uses
RMMV
This is what i have right now, in the script box:
Code:
String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase();
};
However, when I try the code you posted, this error pops up as soon as the text that's supposed to be capitalized comes up:
The event that I'm using the escape code in:
Code:
◆Script:$js.value(1)
◆Text:None, Window, Bottom
:    :\c[30]Napo\c[0] is \js[1]\v[15], \c[30]Numir\c[0] is \v[16],
 

pivoo

Haphazardous Scripter
Member
Joined
Jun 6, 2014
Messages
24
Reaction score
18
First Language
English
Primarily Uses
RMMV
ok so, replacing the script with what I have should work with scriptlets, though. you may need to go to my website to get the most recent website, since uh. maybe haven't kept the forum post up to date. http://pivoo.me/scriptlets/
 
Joined
Feb 18, 2015
Messages
560
Reaction score
296
First Language
English
Primarily Uses
RMMV
Oh, didn't know there was a core/utility/base plugin. Almost wonder if that's part of it.
Downloaded the Utility plugin and the newer version of the Scriptlets plugin.
Using the code you posted, this is what happens:
 

pivoo

Haphazardous Scripter
Member
Joined
Jun 6, 2014
Messages
24
Reaction score
18
First Language
English
Primarily Uses
RMMV
oh, you also need to provide the argument for it to work.
So, when you do \js[1], you need to add a second argument.
Code:
\js[1,'foobar']
\js[1,$gameVariable.value(15)]
 
Joined
Feb 18, 2015
Messages
560
Reaction score
296
First Language
English
Primarily Uses
RMMV
Oh, I see. Didn't realize it needed to be in the actual escape code.
Weird, doing it like that just makes it print out "$gamevariable.value(15)"
And no, I did paste it exactly as you typed it, ie gameVariable.
Code:
◆Text:None, Window, Bottom
:    :\c[30]Napo\c[0] is \js[1,$gameVariable.value(15)], \c[30]Numir\c[0] is \js[1,$gameVariable.value(16)],
Then I tried this:
Code:
◆Text:None, Window, Bottom
:    :\c[30]Napo\c[0] is \js[1,\v[15]], \c[30]Numir\c[0] is \js[1,\v[16]],
and that worked, even though I was expecting it to throw an error or just print out "\v[15]" like it did with $gameVariable.value(15).
 

pivoo

Haphazardous Scripter
Member
Joined
Jun 6, 2014
Messages
24
Reaction score
18
First Language
English
Primarily Uses
RMMV
yeah... it's supposed to be
Code:
$gameVariables.value(id)
My bad:kaoswt2:
 
Joined
Feb 18, 2015
Messages
560
Reaction score
296
First Language
English
Primarily Uses
RMMV
Ah. Well, apparently \v[15] works just as well, so that's good to know.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just finished composing a boss battle theme!
Scripted a multi-variable weather system that randomizes wind speed, cloudiness, rain, fogginess, etc, while attempting to realistically account for interactions between them (e.g. wind speed affects fogginess, cloudiness affects rain, etc), the current weather pattern, and the player's biome e.g. swamp, beach, etc. Now I "just" have to tie visuals and sounds to the variables so stuff actually happens...
I'm having a headache balancing the combat using flat defense so I'm gonna use percentual armor, in this pic, Simon has 16 on Defense which means all the incoming damage will be reduced by 16% this will ease my burden a bit.
!Have a nice day everybody¡
SO glad they patched outer worlds for switch! I can finally play it! Weird that other peeps are still having issues. I know it was really chugging on my lite when it first came out.

Forum statistics

Threads
105,555
Messages
1,014,631
Members
137,233
Latest member
hokiterus787
Top