Eli Find Id By Name - Get the id of anything from database through its name!

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,678
Reaction score
1,095
First Language
Portuguese - Br
Primarily Uses
RMMZ

Author: Hakuen Studio

Introduction

• Sometimes is hard to keep an organized database. Because we can make a list of all kinds of swords and after that a list of shields. But during the development, maybe we can add a new kind of sword. So we have to add it to the bottom of the list, or push all shields to the bottom and clear some
space for the new sword. Or, you can do what most people do, leaving a free space in the list and put separators:

----Swords-----
Middle Sword
Long Sword
empty
empty
----Shields----
Wooden Shield
...

• This plugin, provide a method for you to build your game that you don't have to worry about these anymore!
• You can set your database and organize it anytime you want, without worry about the list order that affects in-game references!

Features

• Assigning values by name: Adds a method of assigning, returning, and checking values of various data/objects of the Rpg maker MV through their names and not just by ID.

• Currently supported: Actors, switches, variables, classes, items, weapons, armors, skills, enemies, troops, equipment types, states, common events, armor types, weapon types, skill types, maps, and events.
NOTE: For now, access to events id by their names, are only supported in the current map.

• You can better organize your database using these methods since you can rearrange them in the list without worrying about their id. It means this is not affecting your game at all since you will don't need to change the in-game references.

How to use

• In the plugin parameters you can choose to use the automatic mode or manual mode.

• Manual Mode - In the manual mode, it will not alias, change, or overwrite any function of the default code, so It will be more compatible with other plugins too!
But instead of simply replacing the argument of the script calls by a name, you have to call another function:

eli.getId('name', 'dataType')

• Auto mode -
In the automatic mode, you can use the default script calls from MZ to search by data through its name.
However, it aliases the default functions of MZ and maybe can get you some plugins incompatibilities, if they, perhaps, overwrite some of these functions. It also can be expensive depends on the machine, since some functions are updated every frame, so you have to use and see for yourself if it will cause performance issues in your project.

Please, see more details on the help section inside the plugin.


Update Log
Version 1.2.0 - 10/15/2020
- Created a new class for find id instead of using game temp.
- Changed the function getId() to eli.getId().
Version 1.0.1 - 10/09/2020
- Fixed an issue with change formation inside the menu.
Version 1.0.0 - 09/23/2020
- Plugin release!
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,678
Reaction score
1,095
First Language
Portuguese - Br
Primarily Uses
RMMZ
Version 1.2.0 - 10/15/2020
- Created a new class for find id instead of using game temp.
- Changed the function getId() to eli.getId().
- Adapted to work with Eli Book 2.0.0
Version 1.0.1 - 10/09/2020
- Fixed an issue with change formation inside the menu.
 

Point08

Veteran
Veteran
Joined
Feb 10, 2015
Messages
123
Reaction score
119
First Language
English
@Eliaquim this is a great plugin! I have a question. I see you can search 'maps' based on 'mapName' but are you able to actually return the ID to set the mapId?

For example, using:
$gameMap.mapId(eli.getId('mapName', 'maps'))

in a Control Variables event command to set a variable to the mapId for mapName?

If yes, do you know if it's possible to use a variable in place of entering the mapName directly?

I'm trying to create a common event that will transfer the player to the same position on a copy of the current map. As some maps will have copies and some won't, and due to adding and removing maps so IDs not being predictable, I was hoping I could do it by name. I'm sure the below is incredibly inefficient, even if it worked, but this is just a start.

◆Control Variables:#0008 Shadow = "Shadow"
◆Text:None, None, Window, Bottom
: :Variable 8 value: \V[8]
◆If:#0010 is OFF
◆Text:None, None, Window, Bottom
: :This will transfer you to the Shadow Realm.
◆Control Variables:#0005 CurrentPosMap = $dataMapInfos[$gameMap.mapId()].name
◆Control Variables:#0006 CurrentPosX = $gamePlayer.x
◆Control Variables:#0007 CurrentPosY = $gamePlayer.y
◆Text:None, None, Window, Bottom
: :You are at Map ID: \V[0005]
: :You are at Position (\V[0006], \V[0007])
◆Control Variables:#0008 Shadow += CurrentPosMap
◆Control Variables:#0009 NewMapID = $gameMap.mapId(eli.getId($gameVariables[8], 'maps'))
◆Text:None, None, Window, Bottom
: :New Map ID: \V[8]
: :\V[9]
◆Transfer Player:{NewMapID} ({CurrentPosX},{CurrentPosY})
◆Control Switches:#0010 = ON

:Else
◆Text:None, None, Window, Bottom
: :This will transfer you to the Normal Realm.
◆Control Variables:#0005 CurrentPosMap = Map ID
◆Control Variables:#0006 CurrentPosX = $gamePlayer.x
◆Control Variables:#0007 CurrentPosY = $gamePlayer.y
◆Text:None, None, Window, Bottom
: :You are at Map ID: \V[0005]
: :You are at Position (\V[0006], \V[0007])
◆Control Variables:#0005 CurrentPosMap -= 3
◆Transfer Player:{CurrentPosMap} ({CurrentPosX},{CurrentPosY})
◆Control Switches:#0010 = OFF

:End
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,678
Reaction score
1,095
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!
For example, using:
$gameMap.mapId(eli.getId('mapName', 'maps'))
Unfortunately not, this will not set the map Id. The function $gameMap.mapId() Does not set anything, it will only return the current map Id.

I don't know if I really understand what you want to do. But I will give it a try ^^

but only with this: eli.getId(mapname, 'maps') you can already return the id of any map, according to their name.

in a Control Variables event command to set a variable to the mapId for mapName?
I don't think there is a way for you to set an Id for a map. Their ID are already set when you created them on the editor. So my guess that is not work.

If yes, do you know if it's possible to use a variable in place of entering the mapName directly?
But this you can do, like put the map name inside a variable:
1603915977452.png

Then you can use the script call:
eli.getId($gameVariables.value(id), "maps")

on a copy of the current map
But the map names are the same? Or they differ?

About your event, I believe you can replace that:

Control Variables:#0009 NewMapID = $gameMap.mapId(eli.getId($gameVariables[8], 'maps'))

with this:

Control Variables:#0009 NewMapID = eli.getId($gameVariables[8], 'maps')

Did I get it? xD
 

Point08

Veteran
Veteran
Joined
Feb 10, 2015
Messages
123
Reaction score
119
First Language
English
Let me try to explain a bit better. Most of my maps have a copy that is not an exact copy, because some details are changed (might have less light, some damaged walls, etc.).

I wanted the player to be able to, by using a common event, to switch between MapA and CopyMapA. So if the player triggered the common event and they were on MapA, they would transfer to CopyMapA at the exact same coordinates. If the player triggered the event again, they would transfer from CopyMapA to MapA.

As I add more maps, the IDs won't always be in any particular order, so I was hoping to use the names of the maps, to control the transfer. So if the player was on MapB, I could get the name of the current map (MapB) and store it in a variable, add the string "Copy" to the variable so it contains "CopyMapB". I wanted to then use your function to get the ID of CopyMapB so I could transfer the player there.

In the end I found another plugin that does what I need, using note tags. I do wish I could have gotten this to work though, just because I like being able to do things with events.

I'll definitely still be using this plugin for other things though. This function is incredibly useful.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,678
Reaction score
1,095
First Language
Portuguese - Br
Primarily Uses
RMMZ
Right, I get it!
I wanted to then use your function to get the ID of CopyMapB so I could transfer the player there.
It's like I said, you can do this using the variable like you are almost doing:

var = $gameVariables

var currentMapName = $dataMapInfos[$gameMap.mapId()].name - Return the name of the current map.
var copyMapName = "Copy"
var copyMapName += currentMap

var copyMapID = eli.getId(copyMapName , "maps")

Then you execute the transfer with the variable copyMapID.

But hey, glad you found a way to solve your problem! ^^
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Why is there so much month left at the end of money? D=
Hello humans! How goes your day in this journey of living? I hope it is good, for I am human like you, and I am feeling great! Worship the altar.
Sand is basically small rocks

Forum statistics

Threads
105,608
Messages
1,014,969
Members
137,273
Latest member
Parzival
Top