Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Command 2054 - Get ID By Name #3214

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jetrotal
Copy link
Contributor

@jetrotal jetrotal commented Apr 28, 2024

This command allows you to store the ID of a database asset by searching for its name.

The syntax always comes in pairs. The first parameter of each pair indicates whether you are using a direct value or a variable/indirect variable, through ValueOrVariable().

Syntax (TPC):

@raw 2054,
      "",          // Name to search for: "MAP0001", "MyVar", etc.
      0, 0,        // Type of asset (0-18) -  0: Actor, 1: Skill, 2: Item, 3: Enemy, 4: Troop, 5: Terrain, 6: Attribute, 7: State, 8: Animation, 9: Tileset, 10: Switch, 11: Variable, 12: String Variable, 13: Common Event, 14: Class, 15: Battler Animation, 16: Map, 17: Map Event, 18: Party Member
      0, 5,        // Variable where the ID will be stored
      0, 1,        // Min range: "0" sets it to the start of the list of assets, any other value specifies the minimum index
      0, 100,      // Max range: "0" sets it to the end of the list of assets, any other value specifies the maximum index
      1, 1         // Usage of string variable instead of the search string, through StringOrVariable()

@Ghabry and @carstene1ns commented about hashing the data for better searching and retrieving data by name.
https://github.com/greg7mdp/parallel-hashmap

image

But this may look good enough for a first version (it's fast enough with the 9999 variables limit from vanilla).

Through it you can store the ID of a database asset through by searching for its name.

Syntax (Maniacs):
```js
@raw 2054,
			"", 	 // name to search
			0, 11,	 // type of database Asset
			0, 5, 	 // variable where it will be stored
			0, 0,	 // Min Range
			0, 0, 	 // maxRange
			1, 1 	 // use stringVar

``

New Command 2054 - Get ID By Name

Through it you can store the ID of a database asset through by searching for its name.

Syntax (Maniacs):
```js
@raw 2054,
			"", 	 // name to search
			0, 11,	 // type of database Asset
			0, 5, 	 // variable where it will be stored
			0, 0,	 // Min Range
			0, 0, 	 // maxRange
			1, 1 	 // use stringVar

``
It mirrors ManiacPatch::GetLcfName structure.

Update game_interpreter.cpp
@Ghabry
Copy link
Member

Ghabry commented Apr 28, 2024

How do you plan to handle translatable strings? Some of them will require a search via the translated string when a translation is loaded and others are not translatable (not exposed by lcftrans).

A string translation must happen here and we actually have a problem: We rewrite all strings on load. Here the string has different meanings based on the context so is the first time where this cannot be used. 🤔

@jetrotal
Copy link
Contributor Author

I forgot about those... Would be hard to have an extra entry called defaultName that only exists when dealing with a translated game?

@Ghabry
Copy link
Member

Ghabry commented Apr 28, 2024

There is no simple way to get the original because we really overwrite them completely.

You must translate your string and do the lookup. Have to check if we have an API already for this...

@Ghabry
Copy link
Member

Ghabry commented Apr 28, 2024

Yes this is solvable, just needs a few more Getters.

What is also interesting (?) is that the command can use String Vars and String Vars are only active when Maniac Patch is on.

I will encounter the same issue soon with my "Language Config" event command which allows altering the active translation and... needs string vars for the getter part 😅

@jetrotal
Copy link
Contributor Author

question: would be better to move here the code from this pr: #3124 ?

Seems better fitted than editing control variables.
also thought about including stuff like screen size, map size and any other unavaliable data.

@fdelapena fdelapena added the Awaiting Rebase Pull requests with conflicting files due to former merge label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Rebase Pull requests with conflicting files due to former merge
Development

Successfully merging this pull request may close these issues.

3 participants