General Tips and Tricks POL Development
Posted: Fri Dec 30, 2016 3:30 pm
Hi there! I'm blckfire and I've been developing code under a POL96 shard version. I also work as software developer/engineer.
These are just a collection of random tips and tricks I've gathered during these 2 years and how to improve testing and development time in POL.
These are just a collection of random tips and tricks I've gathered during these 2 years and how to improve testing and development time in POL.
- "If you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.", as said by Linus Torvalds (Linux creator).
Try to gather your exiting conditions in the beginning of your function to avoid "if" nesting.
Code: Select all
function GreetCustomer(customer) if (customer.isA(POLCLASS_NPC)) return; endif if (customer.concealed) return; endif if (!CheckLineOfSight(me, customer )) return; endif ... endfunction
- Include files should not contain "use ..." or "include ..." lines (since they are not compiled) they should contain a comment that mentions all the uses and includes needed to compile that include file.
Code: Select all
/* * File: includename.inc * * Version: 1.0 * * Description: General description of the includes content * * Creator: Unknown * Maintainer: blckfire * Email: blckfire@gmail.com * * Dependencies: modules and includes the functions are dependent. * so that you include them in the script file that uses this include * * * * Changelog: * 14/06/2015 - Some change * * * * * Function List: * */
- Make sure to use Notepad++ as your software development tool it's free and it has tons of potential:
- When you add NPP Exec extension you can use the following snippet to compile the script you're working on and get feedback inside Notepad++, thus gaining a lot of time.- Has an amazing search functionality allowing you to specify which kind of files you want to search a term for. Usually helpful when trying to access where a package/file/function is used across your server or when searching data files.Code: Select all
SET compiler = C:\POL\scripts\ecompile.exe NPP_SAVE cd C:\POL\ "$(compiler)" "$(FULL_CURRENT_PATH)" UNSET compiler
Note: I can write a more detailed HOWTO on this matter if people are interested in taking full advantage of Notepad++ - Move your execution to another script file to ease your testing process, extremely useful while coding bits of code that normally would need a server restart. By moving the execution to another script your main script stays the same while your secondary script (which does all the work) can be unloaded and tested on the fly.
This last one I'm not really sure if it affects performance but I find it makes it easy to write and test your code. I personally favor this method while coding NPCs and item interaction (there might be some other situations where it can be made useful).Code: Select all
function handle_request(event) var character := event.source; ... var parms := array; parms[1] := me; parms[2] := character; start_script(":package:npcs/scripts/workscript", parms); return; endfunction