Hi all,
I just committed LVP PreCompiler 5.0 to the repository. It's the first new major version in a while, and I believe it warrants it because it addresses one of the largest outstanding issues in the gamemode's architecture: how to handle commands. I'll briefly walk through the changes.
The @invocationList and @invocationSwitch annotations have been removed.
These were quite verbose, and @list and @switch simply seem nicer. I did update the LVP codebase to remove all coinsurance of the longer versions.
@switch now accepts a string as the conditional.
This is a nice one: previously, conditionals for the @switch annotation had to be either a constant or a number. This worked fine in most cases, especially when using it together with @counter for, for example, dialog Ids, but imposed limits when trying to use it for textual options. For example, this is now valid:
This doesn't only work, but is really fast as well. Instead of doing a lot of string comparisons, we create a hash of the input string (using the Super Fast Hash algorithm) and do numeric comparisons against hashes of the conditionals defined in the @switch annotations. Part of this is done by the PreCompiler, part of it by the script itself.
The @command annotation may now be used.
While it secretly already existed, it's implementation has now been ironed out and it's available for usage in Las Venturas Playground. The syntax is rather easy:
And, yes, the /scream command is now available for all players to use. Of course, you have to call Annotation:
rocessCommand() somewhere. In our case, we do this as one of the first things in the OnPlayerCommandText callback.
Under the hood, @command actually is a @switch with "Command" as the command name. If you insist, using @switch(Command, "scream") would have exactly the same effect.
As usual, the binaries are available on the repository. If you use the LVP Pawn Editor from the default location, just doing an SVN update should get you set up right away.
Happy New Year!
I just committed LVP PreCompiler 5.0 to the repository. It's the first new major version in a while, and I believe it warrants it because it addresses one of the largest outstanding issues in the gamemode's architecture: how to handle commands. I'll briefly walk through the changes.
The @invocationList and @invocationSwitch annotations have been removed.
These were quite verbose, and @list and @switch simply seem nicer. I did update the LVP codebase to remove all coinsurance of the longer versions.
@switch now accepts a string as the conditional.
This is a nice one: previously, conditionals for the @switch annotation had to be either a constant or a number. This worked fine in most cases, especially when using it together with @counter for, for example, dialog Ids, but imposed limits when trying to use it for textual options. For example, this is now valid:
Code:
class MyFeature {
@switch(MySwitch, "foo")
public onFoo() { }
@switch(MySwitch, "bar")
public onBar() { }
};
main() {
Annotation::ExpandSwitch<MySwitch>("foo"); // will call MyFeature::onFoo()
}This doesn't only work, but is really fast as well. Instead of doing a lot of string comparisons, we create a hash of the input string (using the Super Fast Hash algorithm) and do numeric comparisons against hashes of the conditionals defined in the @switch annotations. Part of this is done by the PreCompiler, part of it by the script itself.
The @command annotation may now be used.
While it secretly already existed, it's implementation has now been ironed out and it's available for usage in Las Venturas Playground. The syntax is rather easy:
Code:
class MyFeature {
@command("scream")
public onScreamCommand(playerId, params[]) {
SendClientMessageToAll(0xFF000000, "NOOOOOOOOOOOOOO OMGZ");
}
};And, yes, the /scream command is now available for all players to use. Of course, you have to call Annotation:
rocessCommand() somewhere. In our case, we do this as one of the first things in the OnPlayerCommandText callback.Under the hood, @command actually is a @switch with "Command" as the command name. If you insist, using @switch(Command, "scream") would have exactly the same effect.
As usual, the binaries are available on the repository. If you use the LVP Pawn Editor from the default location, just doing an SVN update should get you set up right away.
Happy New Year!