0

I have a class (NpcCommands.cs) that contains general methods like GetPlayer(), SendMessage(), etc.

Is there a way to write scripts in javascript, lua, python, ruby, etc that my program can load and execute that are in some way connected to my class. By this I mean if in the script I called

NC.GetPlayer().SetHealth(15);

Where NC is a reference to my NpcCommands class it would run the GetPlayer() method which returns my player object, then be able to run a method from that object such as SetHealth();

The reason why I want it to be scripted is because there are going to be multiple Npc each with their own conditions and responses such as

if (NC.GetPlayer().HasItem(cookie)) {
    NC.GetPlayer().SetHealth(15);
} else {
    NC.SendMessage("No cookies :c");
}
Kabistar
  • 13
  • 2

1 Answers1

0

There are plenty of samples for all lnaguages you've mentioned. Here are some links:

Python (IronPython version) is one possible choice - Integrating IronPython into your Applications.

LUA have .Net bindings too - i.e. starting links from Channel9.

C# was used for scripting since very beginning too as you can compile at run time.

JavaScript.Net (part of .Net Framework) is probably another option. AS well other JavaScript implementations for .Net.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
  • Thanks a ton! The reason why I listed those languages is because while I was searching for a method I found these languages can be implemented but I wasn't able to find out how. – Kabistar Jul 25 '12 at 00:47