Hey guys. For my mod LoL Items Mod I need a custom merchant with a spawner. But I have no idea how to mod them . So could somebody help me ? Or just give me a link to a tutorial?
I can help you, but I need more info on what you need. Do you just want to make a generic merchant that sells specific goods, or do you want to have a merchant that sells stuff based on some sort of arguments/parameters?
( I dont have the assets in front of me at this moment so forgive me for being vague) Well then you can copy one of the merchant npcs in the NPC folder. There is also a merchant.npctype. This holds all the items that the different types sell. Duplicate this structure within your custom .npctype. You will also have to include the merchantState as a script. Once I have the assets in front of me I can give you a clearer anwser.
I dont "need" the assets, I just wanted to see them so I could tell you specifically where they are located and which ones I am talking about. If you are able to find them based on what I told you, you should still be good to go. However, I do not remember specific names or keys that are required. All I remember is that the item types are stored in a category in the merchant.npctype file each category corresponds to the different merchants you will find, such as the chefs, frog merchant, wizard, etc. All you need to do is create a new category in your custom .npctype's JSON by mimic the merchant.npctype and set it to use that category for the merchantState script. Once I am home tonight, I can give you some pictures and stuff, but for now this is the best I can give.
How can i make a merchant that sells stuff based on some sort of arguments/parameters?Or how to make it sell specific goods in mutiplayer.(I already knew how to get stuff based on some sort of arguments/parameters,but don't know the way make it show up in npcs sell list in mutiplay).Could u help me plz?
I need you to be a little bit more clear on that. Like the player holding an item, or some sort of object's parameters? (Code below) It is pretty easy, just take a look at the populateRecipies function. Sadly I don't really have the time to make a generic merchant for you, but you should be able to sift through this and figure it out. If not, I can help you when I am not drowning in homework/tests. Code: function interact(args) return { "OpenNpcCraftingInterface", tradingMenu() } end -- Makes the recipies for our Dynamic Merchants function populateRecipies(seed, level, merchType) local recipes = {} local commonSwords = {"commonaxe", "commondagger", "commonhammer", "commonshortsword", "commonbroadsword"} -- Gotta love inconsistencies!!! local uncommonSwords = {"uncommonaxe", "uncommondagger", "uncommonhammer", "uncommonshortsword", "uncommonspear", "uncommonbroadsword"} local commonGuns = {"commonassaultrifle", "commonplasmaassaultrifle", "commongrenadelauncher", "commonmachinepistol", "commonplasmamachinepistol", "commonpistol"} local uncommonGuns = {"uncommonassaultrifle", "uncommonsniperrifle", "uncommongrenadelauncher", "uncommonmachinepistol", "uncommonrocketlauncher", "uncommonpistol"} local uncommonTable = {} local commonTable = {} if merchType == "Blacksmith" then commonTable = commonSwords uncommonTable = uncommonSwords elseif merchType == "Gunsmith" then world.logInfo("COLONIES: MERCHANT used Guns") commonTable = commonGuns uncommonTable = uncommonGuns else world.logInfo("COLONIES: MERCHANT used Default") commonTable = commonGuns uncommonTable = uncommonGuns end for i = 1, level + 5 do local recipe = commonTable[math.random(#commonTable)] table.insert(recipes, makeWeapon(merchType, recipe, level, seed)) end if level > 7 then -- If the level is greater than 7, display some uncommon items. for i = 1, level + 5 do local recipe = uncommonTable[math.random(#uncommonTable)] table.insert(recipes, makeWeapon(merchType, recipe, level, seed)) end end return recipes end function makeWeapon(merchType, recipe, eLevel, eSeed) local weaponType = "generatedsword" if merchType == "Gunsmith" then weaponType = "generatedgun" end -- TODO: Figure out how to scale money for guns? return {input = { { name = "money", count = 3000 } }, output = { name = weaponType , data = {definition = recipe, level = eLevel, seed = math.random() * eSeed}}} end function tradingMenu() local colonyInfo = world.callScriptedEntity(storage.colony.id, "getColonyInfo") local merchType = storage.colony.merchant.merchType local maxLevel = 0 -- Maximum tier of all buildings of same type local smiths = colonyInfo.buildings[merchType] local recipe = {} if smiths then -- Only if the building is completed, do we want to increment the maxLevel for k, v in pairs( smiths ) do local info = world.callScriptedEntity(k, "getBuildingInfo") if info.finished and info.tier > maxLevel then maxLevel = info.tier end end if maxLevel > 0 then local eLevel = maxLevel + getSkillLevel(merchType) local eSeed = tonumber(entity.seed()) math.randomseed(eSeed) recipe = populateRecipies(eSeed, eLevel, merchType) end end local tradingConfig = { config = "/interface/windowconfig/shop.config", recipes = recipe -- {input = { { name = "greenstim", count = 1 } }, output = { name = "redstim" } } } } math.randomseed(os.time()) return tradingConfig end EDIT: I should also note that this will not work on the Nightly build. They changed the item.data table to item.parameters ... Simple simple fix though: Replace the word "data" with "parameters" on this line: Code: return {input = { { name = "money", count = 3000 } }, output = { name = weaponType , data = {definition = recipe, level = eLevel, seed = math.random() * eSeed}}}
Thanks,dude!!!! It helps me a lot,I will spend some time on these. By the way,hope u can get good grades on your tests. THKS!
No problem. Thats code from my own mod, so it may not be what you want, but definitely goes over the basics of how to create a recipe from a seed for generated guns and swords. Non-generated items are MUCH easier. And thanks. Gonna need it for this calculus 2 test today.