This site has been archived and made available for preservation purposes. No edits can be made.
-
New C++ script interface
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:
Code cpp:
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):
Code cpp:
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.
Last edited by foxtacles; 05-20-2012 at 05:43 PM.
-
Junior Member
Is the next snapshot come with database ?
-
Senior Member
Awesome, I'm going to try to train my C++ skills by making scripts in it .
I'm getting a little tired of PAWN's syntax therefore it is necessary.
Originally Posted by
Oufz0r
Is the next snapshot come with database ?
I'm sure someone is going to create a simple file system with PAWN or C++.
I'm curious as to whether we can use includes such as Vectors, and Strings in the STD.
Last edited by Aeronix; 05-21-2012 at 11:42 AM.
I just come here to view whether there has been any progress or not, and review the wonderful progress that Recycler and the development team has made.
My sincere thanks goes to them and to others who value my contributions the community, not to mention the ones that solely contribute.
-
Originally Posted by
Aleksander
I'm curious as to whether we can use includes such as Vectors, and Strings in the STD.
You can use everything from the C++11 standard library, basically every C++ extension / code you want. The only restriction is that you must not throw exceptions in your code (at least, you must not allow exceptions to leave the scope of your script)
-
Neat. Looking forward to trying this out properly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules