[Solved] Using GSQ.CONTROLS.CHARACTER_SELECTION's variableButton

● ARCHIVED · READ-ONLY
Started by FoxySeta 6 posts View original ↗
  1. I'd like to do some character selections in certain scene commands using variables, but I noticed that strings variables are used. I tried using a string containing the name of a character, but it didn't worked. Looking deeper in the engine, i found this:
    Code:
    characterId = @interpreter.stringValueOf(@params.characterId)
    //other stuff
    record = RecordManager.characters[characterId]
    I only know how to access RecordManager.characters as an array, so that's probably the matter.
    Thanks in advance!

    EDIT: I just realized that the UID is needed, which makes sense. (I'm not marking this as solved yet cuz I'm not sure I know how to to get a character's UID)
  2. Hi FoxySeta, is that still an issue?

    I am not sure what you are trying to do but in a command-function, @interpreter is a reference to the Component_CommandInterpreter and the stringValueOf method will check if the specified value is a string-variable. If so, it will return the string-value of the string-variable and if not, it will just return the passed value without modification.

    Thanks to that mechanism, it doesn't matter if @params.characterId is a direct selected character or a variable. In both cases, the local variable characterId will contain the correct character UID after.

    With that correct character UID, which is a 36 characters long string, you can get the character record from the database via RecordManager.characters[characterId].

    The character's UID is automatically stored into @params.characterId if the user directly selected a character from the dropdown box. Nothing you have to take care of yourself.

    Let me know if that helps you out.
  3. Well, yeah that kinda anwsers my question.
    FoxySeta said:
    EDIT: I just realized that the UID is needed, which makes sense. (I'm not marking this as solved yet cuz I'm not sure I know how to to get a character's UID)
    I figured out that you're being asked a string containing an UID here, but there's a single case where I can't make it work.
    Here's part of a common event of mine:
    1.PNG 2.PNG 3.PNG 4.PNG
    (This command here is a show text)
    5.PNG
    Since the show text works just fine, I assumed that using UID could actually work. When I added the Join Scene scene command, though, I noticed that no character was being displayed.

    EDIT: actually, in place of the first get object data I used a script in order to convert the character's position inside its collection of records in its UID, but it still works fine:
    Code:
    //Saves the profile's character's ID in the local string 1
    GameManager.variableStore.setStringValueAtIndex(0, 0, lcs(RecordManager.characters[GameManager.variableStore.numberValueAtIndex(0, 0)].index));
    except for the join scene part.
  4. Hi FoxySeta, we already got a few people who wished to calculate a character by variable too, so we are working on that. Right now, only Show Picture's File Name can be calculated by variable in all cases. The problem with characters is that they are associated with a character expression which is associated with one or more image files.

    So if you calculate a character by variable, the engine has no chance to preload the character expression assets because it is only known at runtime which character should join. In Show Picture, as a first experiment, we implemented it in a way that we pause/freeze the entire game and game loop until the asset has been loaded. It seems to work fine so maybe we will apply the same approach for Join Scene in the future.

    So Join Scene by variable only works if the asset of the character already has been preloaded somewhere. So I can see two solutions here:

    1. Use Join Scene only for the character and Show Picture or Show Animation for the expression.

    2. At the beginning of your game, place a bunch of Show Picture commands, which all intending/shifted to the right showing all your character's images. With that, since the commands are shifted they are not executed BUT the preloaded will see that and preloads all your character's images at game start. Then Join Scene by variable just works because everything has been preloaded already. But that only works well if the amount of character assets is small, otherwise it would take too much memory.



    Let me know if that helps you out.
  5. Kentou said:
    Use Join Scene only for the character and Show Picture or Show Animation for the expression.
    Guess I'll go with this one since I'm working on an extension meant to be pubished (I need to make it work for all kinds of character collection's sizes).
    Thanks again!
  6. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.