[Tool/Web/Other] Header file generator - generate .inc file from your gamemode - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (
https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Tools and Files (
https://sampforum.blast.hk/forumdisplay.php?fid=82)
+---- Thread: [Tool/Web/Other] Header file generator - generate .inc file from your gamemode (
/showthread.php?tid=477796)
Header file generator - generate .inc file from your gamemode -
mick88 - 26.11.2013
Yesterday I came up with a script to extract all function headers from gamemode and put them into an .inc file.
You can use this to get auto completion working for all your gamemode functions!
Attached are 2 scripts:
functions - outputs list of all function headers from given .pwn file
generate_headers - gets headers from functions script and saves them into given .inc file in includes/ folder
You have to put both files in your sa-mp directory and run in a bash shell (git's MingW works fine) and type this:
Code:
generate_headers gamemodes/convoy.pwn a_convoy.inc
put your gamemode name instead of "convoy".
Run this every time you add new functions. All of your functions should appear in the panel on the right, additionally, Pawno will suggest function names and parameters when you press CTRL+SPACE.
You can add this to your build script (if you have one) to generate headers every time you build the gamemode - it's a good idea to have a build script when you use git for version control, or instead of using pawno's compile to have your warnings in errors visible in a secondary window.
DO NOT INCLUDE THE .inc FILE IN YOUR SCRIPT - just having it in includes/ directory should work for you.
Here's how the script works:
Code:
cat $input | grep '^\(\|public \|stock \)\(\|[A-Za-z][a-z]*[:]\)[a-zA-Z0-9_]*([^\(\)]*)[^;]*$' | sed -e 's/public //' -e 's/stock //' -e 's/^/native /'
The
cat $input bit prints contents of the, then | (pipe) symbol sends output to the next commands as input - it's used multiple times.
grep '^\(\|public \|stock \)\(\|[A-Za-z][a-z]*[:]\)[a-zA-Z0-9_]*([^\(\)]*)[^;]*$' uses regex to match the string lines to get only functions that start at the beginning of the line (stock, public, and other functions).
Lastly,
sed -e 's/public //' -e 's/stock //' -e 's/^/native / strips all lines from 'public ' and 'stock ', and adds 'native' to each line.
The generate_headers script just dumps all this into an .inc file and adds comments.
Re: Header file generator - generate .inc file from your gamemode -
iPrivate - 27.11.2013
Can't believe that the guy whom I donated 3$ like about 5-6 months ago and got nothing is still active on forums! How's the CVT going on buddy?
OT: The script sounds really good. I'll be downloading it and test it step by step. Looks pretty good and what I was looking for. Still one of your amazing works. Good job.