Won't accept custom c9mmand

Posted: 22 Jan 2022 13:17
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.


Re: Won't accept custom c9mmand

Posted: 22 Jan 2022 17:14
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


Re: Won't accept custom c9mmand

Posted: 22 Jan 2022 17:22
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.


Re: Won't accept custom c9mmand

Posted: 22 Jan 2022 18:49
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.


Re: Won't accept custom c9mmand

Posted: 22 Jan 2022 21:59
by Elringus

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