hasitem available for perl quests
This is an implementation of the hasitem() for perl quests.
mOoni9 had started to work on it in another post, while the code here does not call C++ back, instead it does push the hasitem variable when an event is triggered, ala itemcount. in PerlembParser::Event, creates a variable that the perl interpreter makes available to the perl script in the quest. This variable is created (and reset) for each event where a character is involved (including EVENT_SLAY, EVENT_DEATH, ...) The variable is a hash of array references. It may seem complicated at first, but usage in perl is easy. It complies to .qst behavior in most (if not all) ways, and extends it. The following code is to be added to embparser.cpp, in PerlembParser::Event, at line 189 for example (0.5.3dr3, feb 2004). Code:
#define HASITEM_FIRST 0 It builds a hash where item id is the key, and the value is a reference to an array containing the slots. This allows to test for existence (if the key exists), count number of slots occupied by this object type (size of array), and get the slots id from the array (for example to check if character is currently wielding a weapon, or just has it in his inventory). Here is a sample perl quest, that leads to the screenshot. Code:
sub EVENT_SAY{ |
I haven't really been looking at the emu at all lately :cry: .. the whole point of the hasitem thing was to call code from the server from the perl script. That was really just an example function. I was able to get fairly far on it I think (ie: no shared library needed, but still needed module.pm file, and I never figured out how to get around that). What you have looks workable, though.
The reason I was looking at calling code back from the server was so that all of these variables wouldn't have to be declared beforehand. It seems like a lot of unnecessary overhead, for the most part. On another note, I was just looking at bugzilla again (http://www.bugzilla.org), and kind of wished the emu team had something more along these lines to keep track of bugs/feature requests. It may not seem necessary due to the volume of messages on the board, but I'm sure there are some good ideas being lost by the wayside. |
Quote:
Still switching from perl context back to EMU is not easy, as you noticed. It's a design issue to know whether to export exactly what is required (using export masks as the qglobal flag for example can be a solution), or allowing perl parser to switch back and access C structures. i have no definite position on this. |
All times are GMT -4. The time now is 01:27 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.