[Mod] Quest framework [1.1] [quests]

User avatar
TeTpaAka
Member
Posts: 141
Joined: Sat Dec 28, 2013 21:54

[Mod] Quest framework [1.1] [quests]

by TeTpaAka » Post

Hello minetest,

I made a quest framework to make it possible to give the players quest.

You can see a full list of your active quests with the chatcommand /quests
+ Spoiler
+ Spoiler
Current translations:
  • German by TeTpaAka
Quests have to be translated by the registering mod.

Version: 1.1

Dependencies:
intllib (optional for translating the interface)
inventory_plus (optional) or unified_inventory (optional)
central_message (optional for visual and audio notifications)

License: WTFPL
Sounds: CC-BY
Textures: CC-BY
Download: https://github.com/TeTpaAka/quests/archive/master.zip
Github: https://github.com/TeTpaAka/quests

TODO (unordered):
    Last edited by TeTpaAka on Thu Jul 16, 2015 19:17, edited 23 times in total.

    User avatar
    domtron vox
    Member
    Posts: 111
    Joined: Thu Feb 20, 2014 21:07
    GitHub: DomtronVox
    IRC: Domtron
    In-game: Domtron

    Re: [Mod] Quest framework [quests]

    by domtron vox » Post

    This is awesome. :D

    I was planning on making this very idea myself when I got time. I have been wanting to make an RPGEntities modpack for a while. It would add RPG elements mostly for the player (like skill, I'm working on this now, and quest frameworks) but also adds RPG like mobs and NPC's.

    Thanks for making it!

    User avatar
    rubenwardy
    Moderator
    Posts: 6189
    Joined: Tue Jun 12, 2012 18:11
    GitHub: rubenwardy
    IRC: rubenwardy
    In-game: rubenwardy
    Location: United Kingdom
    Contact:

    Re: [Mod] Quest framework [quests]

    by rubenwardy » Post

    You should round the progress numbers.

    User avatar
    TeTpaAka
    Member
    Posts: 141
    Joined: Sat Dec 28, 2013 21:54

    Re: [Mod] Quest framework [quests]

    by TeTpaAka » Post

    rubenwardy wrote:You should round the progress numbers.
    Done. The Display of the progress is now rounded to two digits.

    guideahon
    Member
    Posts: 37
    Joined: Mon Jan 26, 2015 12:49
    In-game: guideahon

    Re: [Mod] Quest framework [quests]

    by guideahon » Post

    Your mod would be great if you added killing mobs awards, and the graphics of this mod, viewtopic.php?id=4870 and finally, giving objects on difficult achievments

    User avatar
    Wuzzy
    Member
    Posts: 3981
    Joined: Mon Sep 24, 2012 15:01
    GitHub: Wuzzy2
    IRC: Wuzzy
    In-game: Wuzzy

    Re: [Mod] Quest framework [quests]

    by Wuzzy » Post

    Interesting mod with a lot of potential.

    Some suggestions:
    • There should be human-readable quest titles.
    • Longer quest descriptions should be possible. Ideally multi-line descriptions (I know it can be a bit tricky to do so)
    • There should be a log of finished and failed quests
    • Quests should not force a value, it should be possible to add quests without any value, for example for quests like “Find Old Shatterhand's home”.

    @guideahon: As far I understand this mod, it fully lies in the modder's responsibility to decide when a quest is finished, so I doubt your mob killing awards get added.
    But I agree HUD could be improved.

    User avatar
    domtron vox
    Member
    Posts: 111
    Joined: Thu Feb 20, 2014 21:07
    GitHub: DomtronVox
    IRC: Domtron
    In-game: Domtron

    Re: [Mod] Quest framework [quests]

    by domtron vox » Post

    guideahon wrote:Your mod would be great if you added killing mobs awards, and the graphics of this mod, viewtopic.php?id=4870 and finally, giving objects on difficult achievments
    Because this is a framework it is primarily intended for use by other modders to make their life easier. Awards from killing mobs and completing hard achievements is easy to implement in your own mod by using quests.register_quest() with autoaccept=true and providing a callback function that gives the player loot on completion.

    I'm not sure what you mean by graphics unless you are talking about allowing a representative image for each quest shown when it is selected (like the mod you linked does). And I agree that could be a nice addition.

    User avatar
    TeTpaAka
    Member
    Posts: 141
    Joined: Sat Dec 28, 2013 21:54

    Re: [Mod] Quest framework [quests]

    by TeTpaAka » Post

    Wuzzy wrote:Interesting mod with a lot of potential.

    Some suggestions:
    • There should be human-readable quest titles.
    • Longer quest descriptions should be possible. Ideally multi-line descriptions (I know it can be a bit tricky to do so)
    • There should be a log of finished and failed quests
    • Quests should not force a value, it should be possible to add quests without any value, for example for quests like “Find Old Shatterhand's home”.
    • The API has changed. Now you can specify a title, which is shown in the HUD and a seperate description, which can be seen, if you click on info in the formspec
    • see above
    • added
    • Quests with a value of 1 don't show the progress anymore. (May Winnetou guide you.)

    User avatar
    Wuzzy
    Member
    Posts: 3981
    Joined: Mon Sep 24, 2012 15:01
    GitHub: Wuzzy2
    IRC: Wuzzy
    In-game: Wuzzy

    Re: [Mod] Quest framework [quests]

    by Wuzzy » Post

    Cool, thanks! :-)

    guideahon
    Member
    Posts: 37
    Joined: Mon Jan 26, 2015 12:49
    In-game: guideahon

    Re: [Mod] Quest framework [quests]

    by guideahon » Post

    Maybe integration with unified inventory would be a good idea.

    User avatar
    TeTpaAka
    Member
    Posts: 141
    Joined: Sat Dec 28, 2013 21:54

    Re: [Mod] Quest framework [quests]

    by TeTpaAka » Post

    Sorry for changing the API again. I hope, now it is stable.
    With the newest change, a lot of redundant data got removed. Now you have to register a quest and later apply it to a player. This way, not the whole quest text is saved on a per player basis. It isn't saved at all, so you can debug the quests more easily. Before, the quest was player specific, so you couldn't correct mistakes in the quest text. Now, when you restart, the new entered text will be displayed and not an old version with mistakes in it.
    For usage, see the first post.
    guideahon wrote:Maybe integration with unified inventory would be a good idea.
    I added it on my TODO list.

    User avatar
    Wuzzy
    Member
    Posts: 3981
    Joined: Mon Sep 24, 2012 15:01
    GitHub: Wuzzy2
    IRC: Wuzzy
    In-game: Wuzzy

    Re: [Mod] Quest framework [quests]

    by Wuzzy » Post

    TeTpaAka wrote:Sorry for changing the API again. I hope, now it is stable.
    As long as nobody uses the API, it is probably safe to break the API. ;-)
    And your mod is still very young, so that's understandable.

    User avatar
    TeTpaAka
    Member
    Posts: 141
    Joined: Sat Dec 28, 2013 21:54

    Re: [Mod] Quest framework [quests]

    by TeTpaAka » Post

    Wuzzy wrote:But I agree HUD could be improved.
    I hope, it is better now.

    Now the progress is show with a small bar.

    User avatar
    Wuzzy
    Member
    Posts: 3981
    Joined: Mon Sep 24, 2012 15:01
    GitHub: Wuzzy2
    IRC: Wuzzy
    In-game: Wuzzy

    Re: [Mod] Quest framework [0.2] [quests]

    by Wuzzy » Post

    Yay, cool! The HUD is now much better. Double-yay for progress bars. :-)

    Oh, and the example quest should have its dependendy on default listed.

    I discovered a bug: If you have an empty quest list (no matter which tab) in the quest dialog and hit “Info”, Minetest freezes.

    Further HUD suggestions:
    - When there are no open/failed/finished quests in a tab, don't show a textlist or table (whatever formspec element you used), show a label instead saying something like “There are no open quests.”.
    - When there are no more open quests and no more quest which have been just finished or aborted or failed, the HUD should say something like: “No more open quests.”, maybe it gets automatically hidden after 10 seconds or so, so it does not get in the way (auto-hide should be configurable).
    - Quests which have been “just finished” become green in the HUD and are auto-hidden after a few seconds. I like this. But I think there is still a minor flaw in it, because the quest which has been just finished is still listed under a label which says “Open Quests:”, which is of course untrue at this moment. It's not very important, but a possible “fix” for this would be to create another list saying “Just finished quests:”, which only appears when there is at least one such quest. The downside of this is that the quest info tends to “jump around” in the HUD. The lazy and probably saner fix would be to simply rename the label “Open Quests:” to “Quests:”. This would not be a problem, because the state of a quest can already be inferred from its color (yellow=open, green=finished, red: failed or aborted).

    Other comments:
    - I do not like how the long quest descriptions are implemented. Currently, it is just a text field, which can be edited, but it should be read-only. This is not really your fault, however, since the engine does not provide multi-line text labels at the moment. I have made an issue on GitHub about that already: https://github.com/minetest/minetest/issues/2249
    There is an ugly workaround, however: Simply by using a textlist instead, but then you have to align each line of text manually, or you move this responsibility to the modder, which is even worse. So its best to just stay with (the ugly) textfields for now and lets hope multiline labels get implemented some day. ;-)


    Edit:

    I have tried out the API now and played around with sample_quest a bit, and it seems weird.
    So at the beginning you register 4 quests, all with auto-accept. To my understanding, an auto-accept quest is active immediately, no need to call start_quest, right?
    But if that's the case, why is it that at the beginning, only the quest “Walk 200 nodes” is active, but not the other ones? I have not seen any start_quest for the walk quest. So how could the mod possibly have known that you intended to only start the first “autoaccept” quest, but not the other 3? This doesn't look right.

    User avatar
    TeTpaAka
    Member
    Posts: 141
    Joined: Sat Dec 28, 2013 21:54

    Re: [Mod] Quest framework [0.2] [quests]

    by TeTpaAka » Post

    Wuzzy wrote:Yay, cool! The HUD is now much better. Double-yay for progress bars. :-)
    Thanks!
    Wuzzy wrote: Oh, and the example quest should have its dependendy on default listed.
    Fixed.
    Wuzzy wrote: I discovered a bug: If you have an empty quest list (no matter which tab) in the quest dialog and hit “Info”, Minetest freezes.
    I hope this fixes it. Now the window says: No quest specified. Is this OK?
    Wuzzy wrote: Further HUD suggestions:
    - When there are no open/failed/finished quests in a tab, don't show a textlist or table (whatever formspec element you used), show a label instead saying something like “There are no open quests.”.
    Done.
    Wuzzy wrote: - When there are no more open quests and no more quest which have been just finished or aborted or failed, the HUD should say something like: “No more open quests.”, maybe it gets automatically hidden after 10 seconds or so, so it does not get in the way (auto-hide should be configurable).
    I'll add it on my TODO list.
    Wuzzy wrote: - Quests which have been “just finished” become green in the HUD and are auto-hidden after a few seconds. I like this. But I think there is still a minor flaw in it, because the quest which has been just finished is still listed under a label which says “Open Quests:”, which is of course untrue at this moment. It's not very important, but a possible “fix” for this would be to create another list saying “Just finished quests:”, which only appears when there is at least one such quest. The downside of this is that the quest info tends to “jump around” in the HUD. The lazy and probably saner fix would be to simply rename the label “Open Quests:” to “Quests:”. This would not be a problem, because the state of a quest can already be inferred from its color (yellow=open, green=finished, red: failed or aborted).
    I did the lazyer fix since I don't like the quests jumping around in the HUD. It was already a pain to keep them in place in the normale mode. Secondly, I think this is better because the quest simply turns green instead of being in anoter place.
    Wuzzy wrote: Other comments:
    - I do not like how the long quest descriptions are implemented. Currently, it is just a text field, which can be edited, but it should be read-only. This is not really your fault, however, since the engine does not provide multi-line text labels at the moment. I have made an issue on GitHub about that already: https://github.com/minetest/minetest/issues/2249
    There is an ugly workaround, however: Simply by using a textlist instead, but then you have to align each line of text manually, or you move this responsibility to the modder, which is even worse. So its best to just stay with (the ugly) textfields for now and lets hope multiline labels get implemented some day. ;-)
    I know, this is ugly, but I can't do anything about it. Trying to implement multiline labels in lua would result in a much uglyer code.
    Also, since changing the quest description has no effect, I thought this wasn't too bad.
    Wuzzy wrote: Edit:

    I have tried out the API now and played around with sample_quest a bit, and it seems weird.
    So at the beginning you register 4 quests, all with auto-accept. To my understanding, an auto-accept quest is active immediately, no need to call start_quest, right?
    But if that's the case, why is it that at the beginning, only the quest “Walk 200 nodes” is active, but not the other ones? I have not seen any start_quest for the walk quest. So how could the mod possibly have known that you intended to only start the first “autoaccept” quest, but not the other 3? This doesn't look right.
    In my first version, you would be right. register_quest would automaticly start the quest. But that was not good because a lot of redundant data was saved and debugging quests was a PITA. So, every quest has to be started with start_quest.
    auto-accept is only finished automaticly not started. All quests are started inside sample_quest.next_quest(). This function is called from minetest.register_on_joinplayer() one time, so the first quest is started.
    I know, the code in sample_quest is a mess. I did it mainly to test the behavior of quests.

    TeTpaAka

    User avatar
    Wuzzy
    Member
    Posts: 3981
    Joined: Mon Sep 24, 2012 15:01
    GitHub: Wuzzy2
    IRC: Wuzzy
    In-game: Wuzzy

    Re: [Mod] Quest framework [0.2] [quests]

    by Wuzzy » Post

    Thanks for explaining the example quest for me; I initially haven't noticed that call to next_quest().

    Since this is an example, a couple of comments would clearly help. :)
    I did the lazyer fix
    I am perfectly OK with that.
    I hope this fixes it. Now the window says: No quest specified. Is this OK?
    Yes.

    Edit:
    I have a suggestion for a new API function:

    Code: Select all

    quests.show_formspec(playername)
    This should show the quest formspec to the specified player; same effect as using “/quests”. Useful for mods which want to have their own way to show the quest formspec.

    User avatar
    TeTpaAka
    Member
    Posts: 141
    Joined: Sat Dec 28, 2013 21:54

    Re: [Mod] Quest framework [0.2] [quests]

    by TeTpaAka » Post

    Wuzzy wrote: Since this is an example, a couple of comments would clearly help. :)
    I hope, this is better now.
    Wuzzy wrote:I have a suggestion for a new API function:

    Code: Select all

    quests.show_formspec(playername)
    This should show the quest formspec to the specified player; same effect as using “/quests”. Useful for mods which want to have their own way to show the quest formspec.
    Added

    Edit:
    I also split the code in multiple files to keep an overview and make editing and working with git more easy.

    User avatar
    domtron vox
    Member
    Posts: 111
    Joined: Thu Feb 20, 2014 21:07
    GitHub: DomtronVox
    IRC: Domtron
    In-game: Domtron

    Re: [Mod] Quest framework [0.3] [quests]

    by domtron vox » Post

    TeTpaAka wrote:
    Wuzzy wrote: Other comments:
    - I do not like how the long quest descriptions are implemented. Currently, it is just a text field, which can be edited, but it should be read-only. This is not really your fault, however, since the engine does not provide multi-line text labels at the moment. I have made an issue on GitHub about that already: https://github.com/minetest/minetest/issues/2249
    There is an ugly workaround, however: Simply by using a textlist instead, but then you have to align each line of text manually, or you move this responsibility to the modder, which is even worse. So its best to just stay with (the ugly) textfields for now and lets hope multiline labels get implemented some day. ;-)
    I know, this is ugly, but I can't do anything about it. Trying to implement multiline labels in lua would result in a much uglyer code.
    You should take a look at rubenwardy smartfs mod. I belive it adds a non-editable multi-line element. It also makes dealing with formspecs much easier. You can make it a dependancy or include it in your own code as a lua library. https://github.com/rubenwardy/smartfs

    User avatar
    Wuzzy
    Member
    Posts: 3981
    Joined: Mon Sep 24, 2012 15:01
    GitHub: Wuzzy2
    IRC: Wuzzy
    In-game: Wuzzy

    Re: [Mod] Quest framework [0.3] [quests]

    by Wuzzy » Post

    I am now quite happy with the mod. Good work! :-)

    Using smartfs might work as a temporary solution until the engine provides native multiline text fields, but I haven't looked at this mod that much, so I don't know how feasible it is.

    User avatar
    Minetestforfun
    Member
    Posts: 936
    Joined: Tue Aug 05, 2014 14:09
    GitHub: Darcidride
    IRC: Darcidride + MinetestForFun
    In-game: Darcidride + MinetestForFun
    Location: On earth
    Contact:

    Re: [Mod] Quest framework [0.3] [quests]

    by Minetestforfun » Post

    Wow awesome Work ! keep up the good work, we wait impatient your realease 1.0 :D

    Thank you for your work !

    User avatar
    rubenwardy
    Moderator
    Posts: 6189
    Joined: Tue Jun 12, 2012 18:11
    GitHub: rubenwardy
    IRC: rubenwardy
    In-game: rubenwardy
    Location: United Kingdom
    Contact:

    Re: [Mod] Quest framework [0.3] [quests]

    by rubenwardy » Post

    domtron vox wrote:You should take a look at rubenwardy smartfs mod. I belive it adds a non-editable multi-line element. It also makes dealing with formspecs much easier. You can make it a dependancy or include it in your own code as a lua library. https://github.com/rubenwardy/smartfs
    I don't remember this. I don't think I did.

    Here is a way to do it:

    Code: Select all

    local ar = sometext:split("\n")
    for i = 1, #ar do
    	local text = ar[i]
    	-- Hack to add word wrapping.
    	-- TODO: Add engine support for wrapping in formspecs
    	while #text > 80 do
    		if formspec ~= "" then
    			formspec = formspec .. ","
    		end
    		formspec = formspec .. core.formspec_escape(string.sub(text, 1, 79))
    		text = string.sub(text, 80, #text)
    	end
    	if formspec ~= "" then
    		formspec = formspec .. ","
    	end
    	formspec = formspec .. core.formspec_escape(text)
    end

    User avatar
    TeTpaAka
    Member
    Posts: 141
    Joined: Sat Dec 28, 2013 21:54

    Re: [Mod] Quest framework [0.3] [quests]

    by TeTpaAka » Post

    Wuzzy wrote:I am now quite happy with the mod. Good work! :-)

    Using smartfs might work as a temporary solution until the engine provides native multiline text fields, but I haven't looked at this mod that much, so I don't know how feasible it is.
    I am glad you like it.
    And I will take a look at smartfs.
    Minetestforfun wrote:Wow awesome Work ! keep up the good work, we wait impatient your realease 1.0 :D

    Thank you for your work !
    I hope you like it. I am always open for suggestions to make this mod better.
    rubenwardy wrote:
    domtron vox wrote:You should take a look at rubenwardy smartfs mod. I belive it adds a non-editable multi-line element. It also makes dealing with formspecs much easier. You can make it a dependancy or include it in your own code as a lua library. https://github.com/rubenwardy/smartfs
    I don't remember this. I don't think I did.

    Here is a way to do it:

    Code: Select all

    local ar = sometext:split("\n")
    for i = 1, #ar do
    	local text = ar[i]
    	-- Hack to add word wrapping.
    	-- TODO: Add engine support for wrapping in formspecs
    	while #text > 80 do
    		if formspec ~= "" then
    			formspec = formspec .. ","
    		end
    		formspec = formspec .. core.formspec_escape(string.sub(text, 1, 79))
    		text = string.sub(text, 80, #text)
    	end
    	if formspec ~= "" then
    		formspec = formspec .. ","
    	end
    	formspec = formspec .. core.formspec_escape(text)
    end
    I might integrate this (Hope the engine will support multiline labels). But isn't the core namespace reserved for the game? Shouldn't it be minetest.formspec_escape(...)?

    TeTpaAka

    User avatar
    TeTpaAka
    Member
    Posts: 141
    Joined: Sat Dec 28, 2013 21:54

    Re: [Mod] Quest framework [0.4] [quests]

    by TeTpaAka » Post

    Added intllib support and a german translation.
    Note: The translation only covers the interface. The registering mod has to provide its own translations for the quests.

    User avatar
    TeTpaAka
    Member
    Posts: 141
    Joined: Sat Dec 28, 2013 21:54

    Re: [Mod] Quest framework [0.5] [quests]

    by TeTpaAka » Post

    I added basic support for the advanced inventory mods unified_inventory and inventory_plus. But I am aware that it still needs work. Right now, there is only the button registered which starts the regular questlog. Espescially for unified_inventory I am planning to provide an integrated page.

    TeTpaAka

    Edit:

    Now the pages are (finally) added.

    User avatar
    indriApollo
    Member
    Posts: 146
    Joined: Fri Sep 26, 2014 11:34
    GitHub: indriApollo
    IRC: indriApollo
    In-game: SudoAptGetPlay
    Location: Belgium
    Contact:

    Re: [Mod] Quest framework [0.6] [quests]

    by indriApollo » Post

    This is a very nice mod ! thank you TeTpaAka

    Post Reply

    Who is online

    Users browsing this forum: No registered users and 2 guests