PlayStation Trophies in Naninovel

Using Naninovel C# APIs: adding custom actor implementations or commands, overriding engine services, integrating with other systems, etc.
Post Reply
Orenn16
Posts: 14
Joined: 09 Oct 2022 11:52

PlayStation Trophies in Naninovel

Post by Orenn16 »

Hello!

I'm currently developing a game in Unity using Naninovel, and the plan is to publish the game on PS4/5. I know any questions about PlayStation specific development issues should be done on their forums, but I had an inquiry that's more specific to naninovel that I figured I'd try asking about here.

So I'm trying to add PlayStation trophy triggers to my game and, while the ins and outs of that process I can inquire about on the playstation forums, I was curious where in the Naninovel assets I would find the engine code I should be working with to implement this kind of unlockable? Is it within the editor folder?

I guess what I'm asking is where in Naninovels assets is the code that is running the script itself, where I could place a trigger that would essentially say "when this choice is selected, unlock Trophy"?

I appreciate any help you can provide! Coding is not something I'm super familiar with and naninovel has made this project so much easier, but I still run into issues like this lead me to asking dumb questions like these, haha.

idaot
support
Posts: 262
Joined: 01 Aug 2020 08:25

Re: PlayStation Trophies in Naninovel

Post by idaot »

I suggest using custom commands (https://naninovel.com/guide/custom-commands.html#custom-commands) to access the API of the trophy system to perform the desired action. If you got any trophies that require multiple actions then consider using conditional execution (https://naninovel.com/guide/naninovel-scripts.html#conditional-execution).

Orenn16
Posts: 14
Joined: 09 Oct 2022 11:52

Re: PlayStation Trophies in Naninovel

Post by Orenn16 »

Thank you so much! I’ll give this a go and report back with results. This is the last step before we can submit to publish on PS4 so with any luck this will get us across the finish line!

Thanks again for the reply and helpful info

Orenn16
Posts: 14
Joined: 09 Oct 2022 11:52

Re: PlayStation Trophies in Naninovel

Post by Orenn16 »

idaot wrote: 05 Jun 2023 06:42

I suggest using custom commands (https://naninovel.com/guide/custom-commands.html#custom-commands) to access the API of the trophy system to perform the desired action. If you got any trophies that require multiple actions then consider using conditional execution (https://naninovel.com/guide/naninovel-scripts.html#conditional-execution).

Hello again! Just a quick follow up to this; where do we code these custom commands? Is this done within the main narrative scene/script itself, or is there an engine script I should be pulling up to add this code in? I worked with PlayStation to get a piece of sample code that essentially "initializes" the trophy pack but I'm having the same dilemma there: when working with nani novel I'm unsure if all of my coding should be done in the narrative script where I'm writing the dialog, moving characters, playing music etc, or if there is another script within naninovel that I should be coding these higher level behind the scenes functions such as enabling trophies for the PlayStation platform.

Elringus
admin
Posts: 521
Joined: 11 May 2020 18:03

Re: PlayStation Trophies in Naninovel

Post by Elringus »

No coding should be performed in naniscript since it's a DSL designed for scenario writing. All coding should be in C#; see the code snippets in the article and built-in commands in the package for examples.

Orenn16
Posts: 14
Joined: 09 Oct 2022 11:52

Re: PlayStation Trophies in Naninovel

Post by Orenn16 »

Sorry to bring up an older post, but following up on this, I have the code using the customer commands in a way that looks like this:

using Naninovel;
using Naninovel.Commands;
using UnityEngine;

[CommandAlias("UnlockAchievement")]
public class UnlockAchievement : Command
{
public StringParameter ID;

Code: Select all

public override UniTask ExecuteAsync (AsyncToken asyncToken = default)
{
    if (Assigned(ID))
    {
        Debug.Log($"Unlocked Achievement: {ID}!");
        
    }
    else
    {
        Debug.Log("No ID provided for Achievement!");
    }

    return UniTask.CompletedTask;
}

}

So my question now would be, where do I place this code in Naninovel within Unity? Does this go in the engine folder? The resource folder? I'm not sure where this goes so that it can be called upon in the script of the game itself. Thanks so much in advance for your help!

idaot
support
Posts: 262
Joined: 01 Aug 2020 08:25

Re: PlayStation Trophies in Naninovel

Post by idaot »

The Naninovel folder shouldn't be modified as Naninovel itself may break as a result of it and we cannot provide support for modified packages. As long as it's not located in a Naninovel or Resources folder, the location doesn't matter.

Post Reply