Help with Calling Method from dialogue system
Posted: Mon Jan 08, 2024 7:09 pm
So back again and not sure how to make this work correctly, or if just over thinking. I want to be able to call from dialogue system these methods to basically allow players a teleportation system, but not sure how to do this or if I need to with lua extensions. Any help would be appreciated.
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class ShellTeleportationSystem : MonoBehaviour
{
public Transform ViernesLocation;
public Transform PortNethreanLocation;
public Transform EasternWatchLocation;
public Transform PlayerTransform;
private void Awake()
{
}
void OnEnable()
{
// Register functions for Lua (if needed).
Lua.RegisterFunction(nameof(DebugLog), this, SymbolExtensions.GetMethodInfo(() => DebugLog(string.Empty)));
}
void OnDisable()
{
// Unregister functions from Lua (if needed).
Lua.UnregisterFunction(nameof(DebugLog));
}
public void DebugLog(string message)
{
Debug.Log(message);
}
public double AddOne(double value)
{
// Note: Lua always passes numbers as doubles.
return value + 1;
}
public void TeleportViernes()
{
if (ViernesLocation != null && PlayerTransform != null)
{
PlayerTransform.position = ViernesLocation.position;
}
}
public void TeleportPortNethrean()
{
if (PortNethreanLocation != null && PlayerTransform != null)
{
PlayerTransform.position = PortNethreanLocation.position;
}
}
public void TeleportEasternWatch()
{
if (EasternWatchLocation != null && PlayerTransform != null)
{
PlayerTransform.position = EasternWatchLocation.position;
}
}
}