Perl Question with "my $item" using an OR statement
Ok, here is the basic script I am wanting to do. This isn't exactly what I have it as, it is only an example. The only line I am concerned about is the one with "$item2" in it.
Code:
sub_EVENT_ITEM { This is what I have tried so far and the comments are what happens when I tried them: my $item2 = 1201 || 1202 || 1203; #Turning in 1200 and 1201 result in a reward, but 1200 and 1202 or 1203 do not. my $item2 = (1201 || 1202 || 1203); #Same my $item2 = 1201,1202,1203; #Turning in 1200 and 1203 result in a reward, but 1200 and 1201 or 1202 do not. my $item2 = (1201,1202,1203); #same my $item2 = 1201 Or 1202 Or 1203; #Eats all items turned in my $item2 = (1201 Or 1202 Or 1203); #Same Also tried: my $item1 == 1200; my $item2 == 1201 || 1202 || 1203; And for that one, ANY 2 items I turn in result in the reward, but it is any 2 items in the game, as in a short sword and tattered note, or a ration and water. That doesn't work at all! I think what I want should be doable and I imagine it is just a minor change to format or something. Any help would be greatly appreciated. I will probably mess with it more tonight, but if I don't get an answer I may just have to do it the long way :( Thanks in advance. |
Maybe I am just incorrect in how I think $item works. I don't know if it would even work properly if I made a $item definition for all 7 armor slot pieces. From what I am reading, $item is mainly for slots 1-4 on turn in, so you would normally only use $item1 to $item4.
I tried experimenting a little with it last night and I think I was able to get it to work with any variable I defined. For example, if I wanted to set it to: Code:
sub_EVENT_ITEM { |
I wouldn't use $item1, $item2 etc. as variables, they are already defined when an item is handed in.
You could do it by creating a hash of the possible "$item2" handins and loop through it to see if any of that item was turned in. Something like this should work for you. Where the keys in the hash represent the itemID's of the handed-in item, and the values are the item to give back to the player. Code:
sub EVENT_ITEM { |
Thanks for the response! And, I am using "plugin::return_items(\%itemcount);" at the end of my sub EVENT_ITEM to return all handed in items if they don't match any of the quest turn ins. Will that still work with the hash? I don't know a ton about perl (obviously), so I have to experiment a lot to get things working properly.
I am not sure if I am reading your script correctly, but here is how I think my script would apply if I used what you supplied: Code:
sub_EVENT_ITEM { Writing that did give me an idea of how to get it working like I want. I will try it when I get home and post here if I get it working or not. Thanks again. |
Here is the current armor quest I use for 1 single slot. I am wanting to make a similar one that lets them turn in their class armor and 1 item for an upgraded armor piece. I am putting this here as a reference, and this does work fine:
Code:
sub EVENT_ITEM { I tried using Theeper's script, but it just eats my items. The items in this are 1577 (main drop), 1579, 1581, and 1582 (which I want any to work for turn in along with main drop), and 1658 which is supposed to be the reward. Of course, if I could get this working, the reward would be different for each possible turn in combo. So, if a paladin turns in a bracer and the 1577 drop, he would get an upgraded bracer. Here is exactly what I used as a test: Code:
sub EVENT_ITEM { |
Woot, I finally figured it out by trying something I was already using in some of my previous armor quests! It was a little tricky, but it is flawless now as far as I can tell!
I posted the entire quest in the quest submissions forum here. As it is written now, it is fully complete with itemids for armor upgrades from Elemental Armor Class Sets to GoD Armor Class Sets. There are 4 custom quest items I have in my quest, but that could easily be replaced by 1 item, or as many as you like. I hope someone finds this thread useful if they ever want to do something similar to this :D |
Uncapitalize the F in "For". It must be all lower case. Otherwise, that script works fine for me.
|
Quote:
|
All times are GMT -4. The time now is 10:38 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.