MV SDJB_Base (Tweaks and more for SDJB_Plugins)

PluginName: SDJB_Base
Author: ShadowDragon

This plugin is my base, and would be required for most of my plugins, as I add and modify
functions for my plugin (personal) as well for public plugins (free/paid).

What this base can do and what functions that are "improved", "new", "added" and more.
some plugins are not independent on this one, but I rewrite some of plugins to SDJB as
I improve the functions as well.

All functions available inside spoiler.
Spoiler: SDJB Tier List
The tier list I use use to organize my plugins.
This list is also required for ALL plugins for different authors to be
set in the same order for maximum compability.

→ Tier 0: Core
→ Tier 1: Battle
→ Tier 2: Item
→ Tier 3: Skill
→ Tier 4: Equip
→ Tier 5: Status
→ Tier 6: GamePlay
→ Tier 7: Movement
→ Tier 8: Quest
→ Tier 9: Options
→ Tier 10: Eventing/Misc
→ Tier 11: Utility

Spoiler: SDJB Functions
This has function to improve the game, have various fixes along the
way for a smoother gameplay, so it won't be noticed much.

The most imported function is the Base is my core code that is used
through my other plugins.

Spoiler: SDJB Base MV
Spoiler: Copyrights
Set a Copyright text on the bottom of the game screen.
as it is optional, leave empty for not using it.
Spoiler: Blur Background
Blur Background is the snap that is taken when you open a menu,
when ON, the background is shown, when OFF, it is removed.
Spoiler: Max Picture
when setting "Max Picture" higher than 100, use the scriptcall as default
to call the ID above 100, for "Battle" use PictureId + MaxPicture.
if Max Picture = 2000, than Battle Picture start at 2001.
$gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode)
Example:
$gameScreen.showPicture(1742, "File", 0, 10, 10, 100, 100, 255, 0)
Other scriptcalls are required as normal:
$gameScreen.movePicture(pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, duration);
$gameScreen.rotatePicture(pictureId, speed);
$gameScreen.tintPicture(pictureId, tone, duration);
$gameScreen.erasePicture(pictureId);
Spoiler: Enemy Plural names
Remove the plural letters A, B, C, D, ...etc from the same enemies in battle,
set it in the parameter to keep it or remove it.
Spoiler: Max Item Limit
Set how many items you can carry per item, weapon, armor (if they can stack).
You can use JavaScript to control the item like: <Item Limit: $gameVariables.value(12)>
to store the max Item Limit in there whatever the value may be.
Spoiler: Consume Items
Set in the item notetag <prevItem> or <onUse: x>, upon using the item, with <preVItem>
it will take the item Id before the current item.
Example, you have the next in the database:
2: empty Bottle
3: empty Vial
10: potion 1/3 (in notetag <onUse: 2) you lose item 10 and gain item 2
11: potion 2/3 (in notetag <preVItem>) you lose item 11, and gain item 10
12: potion 3/3 (in notetag <preVItem>) you lose item 12, and gain item 11
the notetag <onUse: x> is optional, x can be a valid JS if it returns a number.
if you dont use the notetag <onUse: x> the item is lost as normal.
You can also have a change to consume the item upon using the item.
use the tag <useChance: 0.5> for 50% change.
You are able to combine them, so you can get a previous item <prevItem> or <onUse: x>
when the item is used when you use the tag <useChance: x>.
Spoiler: Show Item Amount
Show the items number when you reach the amount for items, armor, weapons, keyitems.
default is 0 which always shows the item number when reaching 1.
if set to 5, the item number is drawed at when the item possession reached 6.
it's recommended to either either choose 0 (always) or 1 (at counting 2 or more.)
Spoiler: Debt System
There are times you can buy stuff, but not enough gold, if you set it to ON,
you can go under your currency.
When that happens, you can decide what happens when they go under it.
you can kick the party out of the store or pay back the gold they owned first
before they can buy new stuff.
When its OFF, it uses the default behavior.
Spoiler: Shop Buy/Sell Variables
Set a variable to store the gold spent/gained from buying/selling items,
the same can be done for variables bought items and sold items.
BECAREFUL WITH ACHIEVEMENT AS THEY CAN CHEAT ON IT!
Spoiler: Run Common Event After Load
Run a Common Event after loading a saved game.
Spoiler: Real Time System
(for variables or conditional check on users System)
getTime() function has some usefull time parts that can set in a variable
or multiple variables to get the date you want to show.
Samples you can use in a variable or a Real Time System (must be set manually).
getTime() => returns default: "day" "fullMonth", "hour":"minutes"
getTime("string") can return the following if you them seperatly to read the systemTime.
"format" => get the format you set inside the parameters or default: DD-MM-YYYY
"hour" or "hr" => get the hours, number lower than 10 will convert it with a "0" in front
"minutes" or "min" => get the minutes, number lower than 10 will convert it with a "0" in front
"seconds" or "sec" => get the seconds , number lower than 10 will convert it with a "0" in front
"day" => get you the day of the week (1, 2, 3, ...)
"week" => get you the full Name of the week ("Sunday", "Monday", "Tuesday", ...)
"month" => get the month Name fully ("January", "February", "March", ... etc)
"monthN" => get the month value, number lower than 10 will convert it with a "0" in front
"year" => get the full year (2023)
"curTime" => returns the time "16:50"
"curDate" => returns "wednesday 29 march 2023"
Inside the Parameter, you can set a custom Time Format (like the samples above).
The possible options for this format are slightly different.
"YYYY" = Year
"MM" = Month Number
"DD" = Day Number (1,2,3, ... 30, 31)
"HR" = Hours
"MIN" = Minutes
"SEC" = Seconds
"WDAY" = WeekDays (Sunday, Monday, Tuesday...)
"MONTH" = Month Name
Format samples:
getTime() => defaul: 11 August, 19:10
getTime("format") => get default parameter setup DD-MM-YYYY
getTime("format", "YYYY/MM/DD HH:mm"); => "2025/08/11 14:42"
getTime("format", "DD-MM-YYYY"); => "11-08-2025"
getTime("format", "DAY, DD MONTH"); => "Monday, August 11"
Spoiler: Skip event content with comment tags
For debugging the event page to skip from start to end or parts can be done easy.
Use comment tag to start with "=>"" and end with "<=" to rule out a section.
sample:
text 1
text 2
=>
text 3
text 4
text 5
<=
text 6
text 7
text 8
This example show in the text message, text 1, text 2, text 6, text 7 and text 8
Spoiler: Conditional Brance Scriptcalls
SDJB.DistanceEP(eventId, distance)
SDJB.DistanceEP(4, 6) <= checks if event 4 is 6 tiles away from the player (in diamond shape)
SDJB.DistanceEE(eventId1, eventId2, distance)
SDJB.DistanceEE(12, 6, 5) <= checks if event 12 is 5 tiles away from event 6 (in diamond shape)
Spoiler: Scriptcalls Lock and Unlock events and/or player
SDJB.lock(); <= This will lock both events and player movement
SDJB.unlock(); <= This will unlock both events and player movement
SDJB.lockEvents(); <= This will lock all events
SDJB.unlockEvents(); <= This will unlock all events
SDJB.lockPlayer(); <= This will lock the player
SDJB.unlockPlayer(); <= This will lock the player
Spoiler: TriggerBoth Tag
This unique trigger can be helpful, so what does <TriggerBoth> tag do.
By default, Event can be triggers with either "Event Touch" or "Player Touch".
By putting a NoteTag or Comment Tag <TriggerBoth>, this trigger both the
"Event Touch" and "Player Touch".
There are times you require both, now you can, permantly or temporarily.
Spoiler: Fancy Debug Log
The Fancy Debug Log is intergrated into my base and for use easier use
for the shortcut to use.
sucLog(success, message)
infoLog(info, message)
warnLog(warning, message)
errLog(error, message)
set success, info, warning or error into quotes, message in qoutes unless a function
baseLog(message)
this uses the default console.log window
Spoiler: Disable F5
F5 button can be disabled (default: false).
When Disabled: the game won't reboot.
When Enabled: the game will reboot as normal.
NOTE: this does NOT work online because the refresh button still works.

QUALITY OF LIFE FUNCTIONS
Spoiler: Toggle Switch
Scriptcall: toggleSwitch(id)
this will toggle any switch ID to be OFF => ON or ON => OFF.
Spoiler: Set SelfSwitch
Scriptcall: setSS(mapId, eventId, letter, state)
Set a SelfSwitch on MapId, EventId, "A" "B" "C" "D", true/false.
Spoiler: Run Common Events
Scriptcall: runCE(id)
Run a Common Event with the id specified.
Spoiler: Total Variable
Scriptcall: setTotalVar(base, calc)
Example: setTotalVar(1, 5)
This set the number in variable 1 to variable 5.
In case variable 5 has already a value, it will add the number to it.

IMPROVED FUNCTIONS / FIXES
Spoiler: Fix PlayTime, FrameCount, Bitmap Pixels
Fix PlayTime to be accurate and FrameCount to avoid Game Freezes
as well for pixels on bitmap images.
Includes Mac15001900 SceneManager.update and SceneManager.updateMain
Spoiler: Window_Selectable
Fix scrolling function (move cursor down, left, right, up)
Improve selection in window, what is last, return to the first, up and down last item on the bottom.
this is not default as it stops on the last index and wont scroll/jump back to the top, so this is
implemented to make it work like that for smoother navigations.
Spoiler: Font Size Setting
Able to manipulate the fontSize settings.
Set a minimum MAX FontSize and a minimum MIN FontSize,
as well for increasing/decreasing with \{ and \}
Spoiler: Preload Fonts
Preload fonts that you use inside the game.
You can use it with plugin that change fonts midgame like YEP_MessageCore.
Spoiler: Window_NameEdit
Fix letters on the Name Input window that aren't centered by default.
This fix it as many forget to do this when name input is used.
Spoiler: Custom Escape Characters & Process Escape Characters
\S[id] checks the status "false" or "true" and could be used for debug
\MAP[n] will show you MapId's Names (not the Display Name). (no more typo's in Map Names).
\VA[id][index] will take a value from a variable array, arrays needs to be manually initilized.
Example : Variable 4 = [1,3,5,6,9,12], so \VA[4][1] takes the value 3 (array index starts with 0)
Example 2: Variable 4 = ["3", 4, "power", 5, "8"], so \VA[4][2] takes "power" (array start with 0)
\JS{eval code} will evaluate any javaScript code (under construction)
\CALC[3]+[4] ~ \CALC[3]-[4] ~ \CALC[3][4] ~ \CALC[3]/[4] are calculations of 2 variables values.
...add up....~...subtract...~...Multiply...~....Divide....

\WAIT[n] will wait x frames, this gives you a bit more control when the text continues.
More might come or with idea's to add them.
Spoiler: Custom Item/Skill Sound
Add the following to any Item or Skill notetag you want to use a custom SFX:
<SE:[{
"name": "Filename",
"pan": 0,
"pitch": 100,
"volume": 100
}]>
Alternatively:
<SE:[{"name": "Filename", "pan": 0, "pitch": 100, "volume": 100}]>

Enclose the Filename in quotes ("File") without extension (.ogg).
Pan/Pitch/Volume are all numbers between 0-100
Leaving it empty will result in the default System SE.
Spoiler: Play all Common Events
Play all Common Events in a row that is set, otherwise, only the last one will play.
This will remove a common event in the queue and play the next one.
Spoiler: Game_Character Fix MoveRoute
Fix the MoveRoute from events than start over from a move route when you interacted with it.

Mini Version of the base MV & MZ
Spoiler: SDJB_BaseMVZ
This version has the Base Core function
The RealTime System and Consume Item functions (confirmed).

I cannot test which version works in MZ from the MV base, but feel free to test.


=== TERMS OF USE ===
Free for Non-Commercial and Commercial use when credit is given.
credit one of the following:
ShadowDragon
ShadowDragonJB

Version + UPDATE'S
24-04-2024 Version 0.1.0 first release
04-06-2024 added Copyright, made changes, fixes
30-07-2024 changes <Hide Item> to Show Item parameter
18-11-2024 Added missing functions to the helpfile

=== WARNING ===
YOU ARE NOT ALLOWED TO:
* MODIFY without permission
* EXTEND without permission
* TAKE CODE without permission
* CLAIM AS YOU MADE IT
* REDISTRIBUTE but link back to the forum or itch.io
* SELL this product as standalone.
* DO NOT REMOVE THE HEADER.

Itch page will be later added, with some of the functionals this plugin can do.
Along with some samples and tutorials to various mechanics in my own way and
some that I use for your game.

This plugin is in WIP, but if there are issues, please let me know.

Download from itch.io

MV and MZ version can be downloaded from the link above.
Keeping the version number the same. despite a few fixes.

- Fix regex issues on \JS{ code } not working anymore
- Fix \SV (selfvariables) on an regex issue

+ added \S for Switch ID to show "false" or "true" as it could be used for debug
adding a function to Consume Item.
+ new notetag <onUse: x> which is any valid JS or a number
example: <onUse: 5>
example 2"<onUse: $gameVariables.value(32)>

this can give you an empty bottle or vial upon using the last item
or items that can be used once, or get gold chunk into some dust leftover.
SDJB_Base updated with some new features (alter main post later)

- copyright text only when it set to TRUE
- manipulate fontSize with \{ and \} instead of 12, you can use 4.
you can also manipulate min fontSize and max fontSize
- FancyDebugLog is intergrated in case you want a short cut function.
updated my base as added all missing features to the helpfile.
this includes 2 functions from @Mac15001900 FPS issues on high end pc's.
as I misses SceneManager.update and SceneManager.updateMain, I added it to
the base so the entire fix is complete 🙂
The 784 line “ } catch {” seems to report a bug that forbids this plugin from performing. I thought it should be catch(e) ?
The 784 line “ } catch {” seems to report a bug that forbids this plugin from performing. I thought it should be catch(e) ?
maybe, but not in this case as it return an element for parsing the parameters used,
not an error, catch(e) would return an error if it does.

I can't see why it blocks it, do you use MV version 1.6.x? as some function
use ES6 and higher.

as I also use an higher version of nwjs and pixi.js (cannot tell if this is the cause of it).


for example:
try {
FireThisFunction()
} catch {
console.log("simple error")
}

with show "simple error", if you do catch(e), and return e, it throws
the reference error to whatever cause it, else the element giving or none at all.
but in this case, it should grab the element as callback as it works fine on my end.
I use MV 1.6.1, maybe nwjs and pixi.js are old that "catch {" without (e) or (sth else) reports an error.
My NWJS = 0.48.4
Pixi = 4.8.9

so maybe because of it, so try equal version or higher, you may try "catch(err)"
but the way I set it to catch one else the other.

I don't know otherwise as it works fine on my end to pinpoint the cause of not working.
if you have a different way that it keeps working, I'm all ears though, as long it won't
break my recursive setting.
I updated my NWJS and Pixi, and the "catch {" bug is sloved.
Unfortunately the SDJB_VisualPlayerLocation.js still stops the console.log function.
Wired.
I don't set console logs, but can you try in the console log (F8/F12)
just type in SDJB to see what it logs?
if it doesn't show the shadows sprites, a small demo (you can send via DM)
so I can see why it fails.
This is when I turn on the SDJB_VisualPlayerLocation.js.

This is when i turn it off.
SDJB_Base updated.
rewritten fuctions for adjustX and adjustY to respect my
new plugin SDJB_UltimateCameraControl (even without that plugin, its smoother)!
This plugin does not play well with some of my plugins... Just off the top of my head, from my memory and a brief time playing:
  1. YEP_CommonEventMenu
  2. VE_InformationWindow

for starters.... I haven't tried all the plugins yet, but these ones were what I saw immediately when I was testing the plugin out. VE_InformationWindow is integral to my banking system, so it's unfortunate that the plugins don't play well together.

Also, when i was playing the frame rate dropped from 60FPS to around 40FPS as long as this plugin was ON and running. I turned it off and the FPS remained at 60 in the same spots it dropped before. Just FYI.
can you DM me with the error logs of console and plugin database?
I know YEP_CommonEventMenu on name, don't know VE.
but I can try to patch them. when possible to see what exactly is colliding.

a mini demo would be helpful as well, so I can do some tests here.
so make sure the event on those are ready so I can figure out what went wrong.
Updated SDJB_Base for MV, small clean up, helpfile adjusted.
might do it later for in my first post.

Updated SDJB_Base MVZ clean up, remove Time, better parsing,
more streamlined as of my MV base, to keep the core intact and the same.
included helpers.

easier if you don't need the packed version.
packed MV version is only required for the following plugins (MV Only)
SDJB_DecimalCurrency & SDJB_UltimateCameraControl.
Super ambitious! And there's some serious functionality here, that real time system would have been killer when starting a project. I'll try this out over the next week with the carnival of dipshit plugins I've got running and let you know how it works.

Do you anticipate any problems running this in 1.5.1?
Do you anticipate any problems running this in 1.5.1?
if you use 1.5.x than there might be problems, specially if running nwjs 0.29.

I run mainly on 1.6.1 with nwjs 0.48.4 with PIXI 4.8.4.

based on coding, 1.5.1 might not support "let" and "const" as you need to
revert that and maybe, it might work, so I cannot promise though.

if that doesn't work, let me know, I try to see what I can do.

but if possible, try to update if able 🙂

Edit:
There is an issue with the time system (this is fixed and updated).
the patch will be released in a few hours after updating some other stuff.
Updated and fixes:
Real Time System had 2 issues (stupid mistake on
getDay() not getting the week name.

incorrect month number.

Added feature to the Real Time System is the custom format.
can do getTime("format", "DD-MM-YYYY Time: HR:MIN")
or even: getTime("format", "YYYY/MM/DD") to show the time

(more in helpfile on the explanation).

Another thing added to the core is the tag <TriggerBoth>.
this tag trigger Player Touch and Event Touch together.

use it as notetag or as comment tag if its only temporarily used.
the tag only works in if the event is on Same as Character (for to set in helpfile).

I might let it count on any (below, same, above). (maybe next update).
added a new function to my base.

this new function is required for the following plugin:
- SDJB_MoreCustomVehicles which is needed for the airship.
- SDJB_UltimateCameraControl once the zooming in implemented.

this make sure, zooming out works correctly, as well for zooming in.
those 2 get update later together to guard off zooming while in a vehicle.
to avoid miscalculations.

keep in mind that Camera plugin is MV only, custom vehicles MV and MZ.

Original thread: https://forums.rpgmakerweb.com/threads/sdjb_base-tweaks-and-more-for-sdjb_plugins.168037/