Serpens Posted March 10, 2017 Share Posted March 10, 2017 Hi I'm currently working on a "Quests mod", to introduce small tasks like bring xy to pigking and get a small reward. Since I'm not very ingenious, I thought it would be best to allow other modders to add custom quests and also rewards to the mod by an API. The reward system is mostly a "shop". You get dubloons for completing tasks and then you can go to the shopkeeper to buy some stuff. The shop is made as a new Techtree. So first task is: How can other mods add their items to the shop techtree? Second task: How can other mods make use of functions I implement in the API mod? Third: Make first and second compatible to each other. My thoughts were: making a new script and class "QuestAPI". Then use Spoiler local QuestAPI = GLOBAL.require("questapi") QuestAPI = QuestAPI() local function AddShopItems() QuestAPI:AddShopItem("cutgrass",2) QuestAPI:AddShopItem("log",3) end in the Quest mod, while the content of the QuestAPI script is: Spoiler local QuestAPI = Class(function(self) self.questfunctions = require("scenarios/questfunctions") end) function QuestAPI:AddShopItem(prefab,cost) local recipe = nil recipe = AddRecipe(prefab.."_shop_stuff", {Ingredient("dubloon", cost, "images/slotm_inventory.xml")}, shoptab, TECH.SHOPPING_ONE, nil, nil, true, nil, nil, nil, prefab..".tex");recipe.product = prefab; end return QuestAPI But this does not work, since "AddRecipe" is unknown outside of modmain =/ Another thought was to make a TUNING list with stuff that should be added by API mod, but in that case the Quest mods must load before the API mod, to fill the list. But with using that loading order, the Questmods can't use any other functions of the API mod. Link to comment Share on other sites More sharing options...
Ricoom Posted March 12, 2017 Share Posted March 12, 2017 create a class and add it to GLOBAL , Although there is small issue with mod load order. You can make a event that fires when mod is finished loading and have "other" mods use that to detect when class is loaded and then they can access it and use its features. Link to comment Share on other sites More sharing options...
Serpens Posted March 15, 2017 Author Share Posted March 15, 2017 (edited) thank you for the suggestion I found an easier way now: - The API mod loads last. - Every other quest mod can define/fill a GLOBAL.TUNING.QUESTMOD table with their quests, their functions and other stuff. The API mod then just reads this table and acts accordingly Important is the fact, that this table can also include functions, so the modders can just define a "rewardfunction", which is called after the quest is finished (same for intifn and checkfn) and that way they are totally free to create custom quests Edited March 15, 2017 by Serpens Link to comment Share on other sites More sharing options...
. . . Posted March 15, 2017 Share Posted March 15, 2017 I really can't wait for this mod to be done ! One of the reasons cuz I want to add a shop & quest stuff for one of char's modes for a while but had no idea how... Link to comment Share on other sites More sharing options...
Serpens Posted March 15, 2017 Author Share Posted March 15, 2017 3 hours ago, SuperDavid said: I really can't wait for this mod to be done ! One of the reasons cuz I want to add a shop & quest stuff for one of char's modes for a while but had no idea how... I'm making good progress. I'm sure first version will be released at latest end of next week Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now