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

Room Numbers as enum #2625

Open
ivan-mogilko opened this issue Dec 20, 2024 · 7 comments
Open

Room Numbers as enum #2625

ivan-mogilko opened this issue Dec 20, 2024 · 7 comments
Labels
ags 4 related to the ags4 development context: script api type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor

Comments

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Dec 20, 2024

This is from an interesting proposal in comments here.

Autogenerate eRoomName enum constants for rooms. Have these constants declared in a form rmRoomName, where RoomName is converted from Room's Description string with all invalid symbols removed (meaning - symbols that are not allowed to be in script keyword).

Alternatively, have a separate Room's property for this. Probably a Name or ScriptName, which is restricted to be script-compatible, just like any other script name.

Change the signature of the ChangeRoom function to Character::ChangeRoom(eRoomNumber room).
Similarly change Character.Room to return eRoomNumber.

For example, this would result in a generated enum like:

enum eRoomName 
{
    rmKitchen = 1,
    rmAttic = 2,
    ...
    rmKeypad = 301,
    rmTitleSceen = 302,
    ...
}

Then users can code player.ChangeRoom(rmLivingRoom); instead of player.ChangeRoom(37); if they wish. The room names will appear in Autocomplete, making it easier to find and type them.

See Also: #1175

@ivan-mogilko ivan-mogilko added type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor ags 4 related to the ags4 development context: script api labels Dec 20, 2024
@ivan-mogilko ivan-mogilko changed the title Generate room numbers as enum Room Numbers as enum Dec 20, 2024
@AlanDrake
Copy link
Contributor

I feel the description may not be enough in itself. One could have rooms under folders and subfolders, yet use similar descriptions for ingame purposes.
We could try doing tricks like prepending folder names... but perhaps it's just simpler to go with a Name/ScriptName property.

Then you can enforce uniqueness, unlike with on-the-fly generation from Description, where you might end with naming collisions, forcing you to append numbers, and possibly users renaming things and shifting those numbers unexpectedly.

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Jan 24, 2025

Suppose we add ScriptName to the Room, how do we initialize a default value there? I assume that if ScriptName is empty, then we should not generate any constant for it. Perhaps room's script names should be suggested as rmX, or rmRoomX, with X as a room's number. Then this room may be added into enum right away, even if the user does not write anything.

@AlanDrake
Copy link
Contributor

rmRoomX sounds good

@messengerbag
Copy link

What happens to the default ScriptName if you change the room number?

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Jan 24, 2025

Another thing that I wonder about is, how to display the room in the explorer. Right now the room is the only item that displays its description, while others display script names. Should we display room's script name too instead, or both?

What happens to the default ScriptName if you change the room number?

I suppose that it's possible to make so that it is renamed if it matches the default pattern. But that will of course won't work if user renamed it using another pattern.

@fernewelten
Copy link
Contributor

fernewelten commented Jan 24, 2025

What happens to the default ScriptName if you change the room number?

That's not unique to rooms. When you create, e.g., a new Character, it'll be assigned the autogenerated name cCharNUM. Normally as an AGS user, you'd then change the name to your liking, but you don't need to do that. You can proceed and change the Character number as a next step. As far as I know, the autogenerated name, once autogenerated, will simply stay as it was until the user assigns a different name manually. And I propose we handle the rooms the same way.

@fernewelten
Copy link
Contributor

Another thing that I wonder about is, how to display the room in the explorer.

I vote for consistency. That is, when all the other entities display their name in the explorer, also do this for the rooms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ags 4 related to the ags4 development context: script api type: enhancement a suggestion or necessity to have something improved what: editor related to the game editor
Projects
None yet
Development

No branches or pull requests

4 participants