I wrote the following code while looking at the manual.
Code: Select all
@set enemy_HP=100
@showUI HPUI
# battle
@hidePrinter
@choice handler:ButtonArea button:MapButtons/Home pos:-300,-300 goto:.attack
@choice handler:ButtonArea button:MapButtons/Shop pos:300,200 goto:.defend
@stop
# attack
PC: attack!
@set enemy_HP-=10
@goto .battle
# defend
defend!
@goto .battle
@stop
The following code was written to utilize 'enemy_HP' in C#.
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Naninovel;
public class HP_Bar : MonoBehaviour {
void Update()
{
var variableManager = Engine.GetService<ICustomVariableManager>();
variableManager.TryGetVariableValue<int>("enemy_HP", out var intValue);
enemy_HP = 55;
variableManager.TrySetVariableValue("enemy_HP", intValue);
}
}
However, the following error occurs:
The name 'enemy_HP' does not exist in the current context
I think I wrote it as it is while looking at the manual, is there anything I made a mistake?