| 02-05-2008, 03:38 AM | #1 |
Okay, basically I am making a Quest system. Everything is working fine except for one part of the system, in which I tried to make a method to detect which QuestSlot a particular named quest is in. However, I get a syntax error when I try to compile. The system allows each player to have a unique QuestLog (called PQuest). Each QuestLog can contain up to 3 quests. Basically Slot[0], Slot[1], and Slot[2] can all hold a quest, which is shown in the AddQuest method (this works fine and was tested ingame). What I want to be able to do is to check and see if a person already has a quest based on the name of the quest. It should work in theory but I am getting a compile error on it: "s___QuestLog_Slot[s__QuestLog_Slot[this]+i] is not of a type that allows . syntax". I am guessing that it is not able to access the data using Slot[number].QD.name for some reason. Anyone have any ideas to make it be able to get that information? Thanks in advance! THE PROBLEM METHOD: JASS:method GetQuestSlot takes string QuestName returns integer local integer i = 0 loop exitwhen i == 3 if (.Slot[i].QD.name == QuestName) then return i exitwhen true else set i=i+1 endif endloop endmethod THE ENTIRE LIBRARY FOR THE SYSTEM JASS:library QuestStuff globals QuestLog array PQuests endglobals struct QuestLog integer array Slot[3] method AddQuest takes Quest q, player p returns nothing local integer i = 0 loop exitwhen i == 3 if (.Slot[i] <= 0) then set .Slot[i] = q call DisplayTextToPlayer(p,0.0,0.0,"|CFF00FF00Quest Added in Slot:|R " +I2S(i)) exitwhen true else set i=i+1 endif endloop endmethod method GetQuestSlot takes string QuestName returns integer local integer i = 0 loop exitwhen i == 3 if (.Slot[i].QD.name == QuestName) then return i exitwhen true else set i=i+1 endif endloop endmethod endstruct struct Quest Quest_Data QD endstruct interface Quest_Data string name string description integer goldreward integer itemreward method onFinish takes Quest q, player p returns nothing defaults nothing method onStart takes Quest q, player p returns nothing defaults nothing endinterface struct MyQuest extends Quest_Data string name = "My Quest" string description = "hey guys did this work?" integer goldreward = 200 method onFinish takes Quest q, player p returns nothing call DisplayTextToPlayer(p,0.0,0.0,"You have completed: "+this.name) call q.destroy() endmethod endstruct endlibrary |
