Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Using methods in a script

$
0
0
Hey everyone.

I'm working on a game server for a game client and I'm using ClearScript as my scripting interface.

I have an abstract class called 'ScriptBase' and classes that inherit from it: 'NpcScript', 'PortalScript' and 'ReactorScript'.

'ScriptBase' contains all the necessary fields and methods like the script's engine, the 'Run' method and everything else.

'NpcScript', 'PortalScript' and 'ReactorScript' are basically the implementation of each game object's script. So, when I interact with a NPC for example, I run a new instance of NpcScript like so:
new NpcScript(104000).Run();
The 'ScriptBase' class does all the work - it looks for the appropriate file and executes it. However, I want to be able to include methods to expose to the engine from within each class. In 'NpcScript' class, for example, I have a few methods: 'SendNext(string text)', 'SendYesNo(string text)' - how would I expose them to the engine if 'ScriptBase' is abstract so I can use them like so (in a script file):
SendYesNo("hello");

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images