-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quests moved to Lua #4261
Quests moved to Lua #4261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Feels like moving forward.
LGTM on dropping XML support here, I don't think it made sense to have it so I won't be pushing for backwards compatibility on this. |
Here the example of the xml reader from lua for compatibility with previous versions. load_questsxml.lualocal questXml = XMLDocument("data/XML/quests.xml")
local child = questXml:child("quests")
local firstChild = child:firstChild()
while firstChild do
local missionNode = firstChild:firstChild()
local missions = {}
while missionNode do
local mission = {
name = missionNode:attribute("name"),
storageId = missionNode:attribute("storageid"),
startValue = missionNode:attribute("storagevalue"),
endValue = missionNode:attribute("endvalue"),
ignoreEndValue = missionNode:attribute("ignoreendvalue"),
description = missionNode:attribute("description")
}
if not mission.description then
local missionState = missionNode:firstChild()
local description = {}
while missionState do
description[missionState:attribute("id")] = missionState:attribute("description")
missionState = missionState:nextSibling()
end
mission.description = description
end
missions[#missions + 1] = mission
missionNode = missionNode:nextSibling()
end
Game.createQuest(firstChild:attribute("name"), {
storageId = firstChild:attribute("startstorageid"),
storageValue = firstChild:attribute("startstoragevalue"),
missions = missions
}):register()
firstChild = firstChild:nextSibling()
end It's basically placed in some .lua file in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets go
needs rebase and will be merged |
msg:addByte(0xD0) | ||
msg:addByte(1) | ||
|
||
local trackedQuests, trackeds = TrackedQuests(self, missionsId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TrackedQuests
is a bad name, makes it look like you are constructing a new value, but it's just a function. getTrackedQuests
maybe? And you don't need to return trackeds
just use #trackedQuests
function Player.sendQuestLog(self) | ||
local msg = NetworkMessage() | ||
msg:addByte(0xF0) | ||
local quests = Quest.getQuests(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getQuests
does not return all quests so it should be clear about it. getPlayerQuests
Also, I think it should be in the Game
or Player
namespace, not Quest
<event class="Player" method="onQuestTracker" enabled="1" /> | ||
<event class="Player" method="onQuestLog" enabled="1" /> | ||
<event class="Player" method="onQuestLine" enabled="1" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change these event names to be more explicit about what they are reacting to:
<event class="Player" method="onQuestTracker" enabled="1" /> | |
<event class="Player" method="onQuestLog" enabled="1" /> | |
<event class="Player" method="onQuestLine" enabled="1" /> | |
<event class="Player" method="onRequestQuestTracker" enabled="1" /> | |
<event class="Player" method="onRequestQuestLog" enabled="1" /> | |
<event class="Player" method="onRequestQuestLine" enabled="1" /> |
Or open
instead of request
. All other events are (or should be) in the format on<action><subject>
Also, onStorageUpdate
-> onUpdateStorage
. onInventoryUpdate
is incorrect.
|
||
setmetatable(Quest, {__call = function(_, id) return Quest.getById(id) end}) | ||
setmetatable(Mission, {__call = function(_, id) return Mission.getById(id) end}) | ||
setmetatable(TrackedQuests, {__call = function(_, player, missionsId) return TrackedQuests.getByMissionsId(player, missionsId) end}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These belong to Game
or Player
, no need to create metatables. Game.getQuestById(id)
, Player.getTrackedQuests()
then Quest.getMissionById(id)
} else if (methodName == "onQuestLog") { | ||
info.playerOnQuestLog = event; | ||
} else if (methodName == "onQuestLine") { | ||
info.playerOnQuestLine = event; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these can be removed if you move the packet parsing to Lua :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah <3
Closed for inconsistency, I will reopen it in another PR already refactored and applying the suggestions mentioned here |
Pull Request Prelude
Changes Proposed
/reload scripts or all
(This is because we don't want ghost quests that have been removed, changed, or replaced.)onStorageUpdate
,onQuestTracker
,onQuestLog
,onQuestLine
If you have suggestions or find any bugs please let me know, I've tested it, but your revisions are always needed.
Issues addressed: Nothing!