Adding Perl Functions in New Quest System
In this tutorial I will be demonstrating how to add functions using the new perl quest system by FatherNitwit; similar to the tutorial for the old system written by Cofruben.
In this example I will be creating a completely useless function but it should show how all the features work. It will be quest::qcalc();. The function will bascially just add the 2 numeric parameters and display them to the client. First, start by opening up questmgr.h and go to line ~109 or about here: Code:
void clear_proximity(); Code:
void qcalc(int numberone, int numbertwo); Code:
void QuestManager::clear_proximity() { Code:
void QuestManager::qcalc(int numberone, int numbertwo) Now open up perlparser.cpp and go to line ~193, where you should see the ending of Code:
XS(XS_EntityList_new) Code:
XS(XS__qcalc); //Defines the function Code:
XS_VERSION_BOOTCHECK ; Code:
newXS(strcpy(buf, "qcalc"), XS__qcalc, file); |
some additions:
1. you shouldent need to call GetInitiator()... you can access it directly as 'initiator'... as well as the npc the quest is running on as 'npc'. Be careful as initiator is allowed to be null... on the other hand, npc is garunteed to never be null. 2. if you want your methods to work with the old non-XS based system, you need to do this: Code:
If you want it to work in old mode perl and .qst, edit parser.cpp The SvUV thing can take several forms: SvUV == string to unsigned value (char->ulong) SvIV == string to signed value (char->long) SvNV == string to real value (float,double) SvPV_nolen == string with no length restriction |
Thanks fnw.. but when i was compiling it on VC++ 6 I did indeed have to use GetInitiator() for some reason, because id get a compiliation error (undefined controller) if I just used initiator-> (which i saw other XS entries use fine)
So, im not sure. |
All times are GMT -4. The time now is 09:25 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.