Web3 Trigger
Using Trigger Names
NAREON supports a simple “trigger” mechanism so you can automatically transfer tokens or mint NFTs when certain events happen in your game (like completing a quest or finishing an NPC dialogue).
1. Setting triggerName in NAREONSettings
triggerName in NAREONSettingsIn your NAREONSettings.asset, open the tokens list. For each TokenConfig:
tokenName: e.g."GoldCoin"contractAddress:"0x12345..."tokenType:ERC20orERC721(etc.)defaultAmount: The usual amount or 1 for NFTstriggerName: e.g."OnQuestComplete"(the magic string for this token)
You can enter the same or different triggerName for multiple tokens if you want them all to be rewarded together.
2. Calling HandleTokensForTrigger
HandleTokensForTriggerIn your game code, when you want to trigger the reward or mint, do something like:
using UnityEngine;
public class QuestCompletion : MonoBehaviour
{
public NAREONTokenManager tokenManager;
public string playerWalletAddress = "0xPlayerWallet...";
public void OnPlayerCompletesQuest()
{
// This matches the triggerName in NAREONSettings
// for any tokens with triggerName = "OnQuestComplete"
tokenManager.HandleTokensForTrigger("OnQuestComplete", playerWalletAddress);
}
}What Happens:
HandleTokensForTrigger("OnQuestComplete", "0xPlayerWallet...")loops over all tokens in yourNAREONSettings.tokens.Any token with
triggerName = "OnQuestComplete"is transferred or minted automatically, depending on whether it’s ERC20 or ERC721.If multiple tokens share the same trigger, they all get rewarded together.
3. Example Use Cases
NPC Dialogue: When the player’s dialogue ends, call
HandleTokensForTrigger("OnDialogueEnd", playerWallet).Quest Completed: As shown above,
"OnQuestComplete".Boss Defeated:
"OnBossDefeat"— mint a rare NFT or distribute special tokens.
This flexible approach lets designers or game scripters define custom triggers in NAREONSettings.asset without having to change code every time they want a new reward event.
Last updated

