Won't accept custom c9mmand

Using Naninovel C# APIs: adding custom actor implementations or commands, overriding engine services, integrating with other systems, etc.
Post Reply
AmberRose
Posts: 8
Joined: 22 Jan 2022 01:40

Won't accept custom c9mmand

Post by AmberRose »

I Can't figure out what I'm doing wrong:
(disclaimer, I'm not a pro at all)

Here's the code, but @showAd does nothing still..

Code: Select all

using Naninovel;
using Naninovel.Commands;
using UnityEngine;

[CommandAlias("ad")]
public class SHOWAD : Command
{
    public StringParameter AdType="";
    public override UniTask ExecuteAsync (AsyncToken asyncToken = default)
    {
        if(Assigned(AdType))
        {
            if(AdType == "ask" || AdType == "Ask")
                AdManager.instance.ShowRewardBasedVideo();
            else
                AdManager.instance.ShowRewardedInterstitial();
        }
        if(Random.Range(0,3)==0)
        {
            AdManager.instance.ShowInterstitial();
        }
        return UniTask.CompletedTask;
    }
}

There are no errors, so the only hint I may have is that using naninovel.commands is apparently not being used right now, according to vs code.
The goal is to be able to select a good time for an ad to show.

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

Re: Won't accept custom c9mmand

Post by idaot »

It works fine on my end. The problem is likely with the Admanager.

A simple tip, use Debug.Log in case you're unsure whether something is working. https://www.youtube.com/watch?v=sCoLgvmj0Ws

AmberRose
Posts: 8
Joined: 22 Jan 2022 01:40

Re: Won't accept custom c9mmand

Post by AmberRose »

Thanks for letting me know, and its not that the process doesn't work. I haven't gotten a chance to try it. It shows up as an error in my nani scripts itself. So I assumed it didn't properly become a usable command.

AmberRose
Posts: 8
Joined: 22 Jan 2022 01:40

Re: Won't accept custom c9mmand

Post by AmberRose »

Okay, an update. It DOES work, I just hadn't went ahead and tested due to the red squiggle errors that showed up in the script and made me assume the namespace did have my command in it correctly.

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

Re: Won't accept custom c9mmand

Post by Elringus »

If you mean error in VS Code, make sure the bridging is working: https://naninovel.com/guide/ide-extensi ... e-metadata

Post Reply