Page 1 of 2

[Mod] Quest framework [1.1] [quests]

PostPosted: Thu Feb 19, 2015 16:17
by TeTpaAka
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

+ Screenshots:




+ API


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):

    Re: [Mod] Quest framework [quests]

    PostPosted: Thu Feb 19, 2015 18:37
    by domtron vox
    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!

    Re: [Mod] Quest framework [quests]

    PostPosted: Thu Feb 19, 2015 19:07
    by rubenwardy
    You should round the progress numbers.

    Re: [Mod] Quest framework [quests]

    PostPosted: Fri Feb 20, 2015 15:25
    by TeTpaAka
    rubenwardy wrote:You should round the progress numbers.

    Done. The Display of the progress is now rounded to two digits.

    Re: [Mod] Quest framework [quests]

    PostPosted: Fri Feb 20, 2015 17:28
    by guideahon
    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

    Re: [Mod] Quest framework [quests]

    PostPosted: Sat Feb 21, 2015 03:30
    by Wuzzy
    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.

    Re: [Mod] Quest framework [quests]

    PostPosted: Sat Feb 21, 2015 03:36
    by domtron vox
    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.

    Re: [Mod] Quest framework [quests]

    PostPosted: Sat Feb 21, 2015 14:06
    by TeTpaAka
    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.)

    Re: [Mod] Quest framework [quests]

    PostPosted: Sun Feb 22, 2015 01:03
    by Wuzzy
    Cool, thanks! :-)

    Re: [Mod] Quest framework [quests]

    PostPosted: Mon Feb 23, 2015 14:57
    by guideahon
    Maybe integration with unified inventory would be a good idea.

    Re: [Mod] Quest framework [quests]

    PostPosted: Sat Feb 28, 2015 11:04
    by TeTpaAka
    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.

    Re: [Mod] Quest framework [quests]

    PostPosted: Sat Feb 28, 2015 11:51
    by Wuzzy
    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.

    Re: [Mod] Quest framework [quests]

    PostPosted: Sat Feb 28, 2015 20:33
    by TeTpaAka
    Wuzzy wrote:But I agree HUD could be improved.

    I hope, it is better now.

    Now the progress is show with a small bar.

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

    PostPosted: Sun Mar 01, 2015 02:07
    by Wuzzy
    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.

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

    PostPosted: Sun Mar 01, 2015 09:03
    by TeTpaAka
    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

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

    PostPosted: Sun Mar 01, 2015 18:31
    by Wuzzy
    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:

    Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
    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.

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

    PostPosted: Mon Mar 02, 2015 14:21
    by TeTpaAka
    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:

    Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
    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.

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

    PostPosted: Tue Mar 03, 2015 01:29
    by domtron vox
    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

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

    PostPosted: Tue Mar 03, 2015 02:16
    by Wuzzy
    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.

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

    PostPosted: Tue Mar 03, 2015 15:39
    by Minetestforfun
    Wow awesome Work ! keep up the good work, we wait impatient your realease 1.0 :D

    Thank you for your work !

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

    PostPosted: Tue Mar 03, 2015 18:14
    by rubenwardy
    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:

    Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
    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

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

    PostPosted: Tue Mar 03, 2015 20:15
    by TeTpaAka
    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:

    Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
    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

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

    PostPosted: Tue Mar 03, 2015 21:13
    by TeTpaAka
    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.

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

    PostPosted: Wed Mar 04, 2015 18:39
    by TeTpaAka
    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.

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

    PostPosted: Mon Mar 09, 2015 23:31
    by indriApollo
    This is a very nice mod ! thank you TeTpaAka

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

    PostPosted: Fri Mar 27, 2015 12:06
    by TeTpaAka
    indriApollo wrote:This is a very nice mod ! thank you TeTpaAka

    Thanks.

    I had to take a break due to my exams, but now I could continue working on this.
    The newest update includes the option to automaticly hide the HUD.

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

    PostPosted: Mon May 11, 2015 22:30
    by Aryandil
    I have a question. I'm rather new to computer skills when it comes to coding and all that and only just figured out where to put mods and maps. If you could explain how to use API, that would be great. Thank you!

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

    PostPosted: Tue May 12, 2015 06:17
    by TeTpaAka
    Aryandil wrote:I have a question. I'm rather new to computer skills when it comes to coding and all that and only just figured out where to put mods and maps. If you could explain how to use API, that would be great. Thank you!

    First, you register a quest on load time of the mod, like you would do with a node/item/entity:
    Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
    Code: Select all
    quests.register_quest("yourmod:quest", {
        title = "Awesome quest",
        description = "blablabla",
        max = 10,
        autoaccept = true,
        callback = function(playername, questname)
            minetest.chat_send_all(playername .. " has beaten " .. questname .."!")
        end
    }

    Then you need to start the quest for a player, for example when he punches a node, talks to an npc, on_newplayer:
    Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
    Code: Select all
    quests.start_quest("singleplayer", "yourmod:quest")

    Each time an action occurs that alters the quest (digging stuff, killing players/mobs...) you should call:
    Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
    Code: Select all
    quests.update_quest("singleplayer", -- or any other player
                        "yourmod:quest", 1) -- 1 or the amount of update

    That's it. Please report any bugs in this topic. Thank you.

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

    PostPosted: Mon Jul 06, 2015 15:21
    by amadin
    It is great mod, but i know to create many quests without gui interface is too long time and difficult for most peoples.

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

    PostPosted: Mon Jul 06, 2015 20:07
    by TeTpaAka
    amadin wrote:It is great mod, but i know to create many quests without gui interface is too long time and difficult for most peoples.

    This mod is designed as a foundation for other mods to work on. It is not directly for the end user as it is useless on it's own, only for mod creators.
    Anyway, I will try to improve the mod if you tell me, what you expect from a gui.