Hello There, Guest! Login or Register


Classes and PreCompiler features
#1
The PreCompiler is under more active development again... and now that im rewriting parts of the gamemode it would be a good time for each of you devs to learn how to write code with them.

Pick an isolated feature (such as the pirate ship or the tax system) and re-write it. Revision 2274 shows you roughly how to start.

The steps for writing a feature are:
1. Write up a short document about what it is, should do, and some rough ideas you have (example).
2. Write up a diagram about the code structure on LucidChart. Ask in #LVP.dev for our account.
3. Write the code.

After you've done this once or twice, you can probably skip steps 1 and 2. Initially, however, it's important that you understand the principles.

Some important things to keep in mind:
1. Long names are good. The LVP PreCompiler adjusts the Pawn compiler to allow function names of more than 32 characters. Utilize it. "CashPointController::sendMessageToPlayersWithinRangeToCashPoint" is much clearer than "checkRange". Why? Because you don't need to read the code in order to know what it does.
2. Thinking about your feature is good. Everyone can just start typing some code, but the interesting thing about programming is writing your code as efficient as possible. What are possible future additions, and what would they mean on architecture?
3. Encapsulation and isolation are good. Pretty much every feature should be able to be written in one source-file, and require little to no modifications to other files. Strongly utilize invocation lists (@list) and switches (@switch) to achieve this. The file "Features/Account/EnterPasswordDialog.pwn" shows a completely self-contained dialog, with no external code at all.
4. Ask. There's plenty of smart people around. Ask.

Start trying... Let me know when you committed something and I will review it. The idea there is that I'll add a lot of @review annotations in the code, which you then can pick up.

Once you learn to write code using classes you'll never want to go back again :)
Reply
#2
Thanks! I'm already working on the tax system, it should be done soonish. :)
Reply
#3
I know I said I'd do the bar feature, but on second thoughts I don't think this has much priority right now since it's not that popular.
I'll work on the pirate ship.

Perhaps we should collect a list of things to do and start using the trac, and develop an appropriate roadmap.

EDIT: Regarding the document from step 1 - perhaps this could also be included in the header of the source file.
EDIT2: I remember you wrote a zone plugin - was it ever finished and commited? Is it usable? (If not, we have other options such as the Streamer Plugin).
Reply