foxtacles
05-20-2012, 05:41 PM
The next snapshot will come with the revised scripting interface. You can now write scripts in C, C++ and PAWN. C++ scripts are fully binary compatible, so you should be able to use any C++11 compiler to write scripts for vaultmp.
The C++ part now includes game object class wrappers to enable scripting in an object-oriented manner (with little to no overhead, though). For example, the rewritten example OnSpawn:
Void VAULTSCRIPT OnSpawn(ID object) noexcept
{
Player player(object);
if (player)
{
player.UIMessage("Hello, " + player.GetName() + "!");
Base pipboy = static_cast<Base>(0x00015038);
if (player.GetContainerItemCount(pipboy) == 0)
{
player.AddItem(pipboy);
player.EquipItem(pipboy);
}
}
}
In addition to that, C++ functions are now much more typesafe. Consider CreateTimer (CreateTimerEx, now overloaded):
Result example(const char* var1, UCount var2, ID var3) noexcept
{
return static_cast<Result>(0);
}
Void VAULTSCRIPT exec() noexcept
{
CreateTimer<const char*, UCount, ID>(example, static_cast<Interval>(500), "Example text", 123, static_cast<ID>(123123123123));
}
Template metaprogramming auto-generates the type specifier string for you. No chance to make an error anymore.
The C++ part now includes game object class wrappers to enable scripting in an object-oriented manner (with little to no overhead, though). For example, the rewritten example OnSpawn:
Void VAULTSCRIPT OnSpawn(ID object) noexcept
{
Player player(object);
if (player)
{
player.UIMessage("Hello, " + player.GetName() + "!");
Base pipboy = static_cast<Base>(0x00015038);
if (player.GetContainerItemCount(pipboy) == 0)
{
player.AddItem(pipboy);
player.EquipItem(pipboy);
}
}
}
In addition to that, C++ functions are now much more typesafe. Consider CreateTimer (CreateTimerEx, now overloaded):
Result example(const char* var1, UCount var2, ID var3) noexcept
{
return static_cast<Result>(0);
}
Void VAULTSCRIPT exec() noexcept
{
CreateTimer<const char*, UCount, ID>(example, static_cast<Interval>(500), "Example text", 123, static_cast<ID>(123123123123));
}
Template metaprogramming auto-generates the type specifier string for you. No chance to make an error anymore.