MisterInSayne Posted September 28, 2015 Share Posted September 28, 2015 Hey everyone! So, I'm going to give some coding sniplets of things I think might be usefull for everyone here. With the main focus on keeping compatibility issues between mods as minimal as possible, and retaining the same functionality. Sounds good right? So here is the first one, for adding things to the build menu! --Creation of the sub menu in the original script:--Creation of the sub menu in the original script:--local buildOption = context:addOption(getText("ContextMenu_Build"), worldobjects, nil);--local subMenu = ISContextMenu:getNew(context);--What you use to add to the existing build submenu in your own script:local subMenu = nil;local buildOption = nil;for i,v in ipairs(context.options) do if v.name == getText("ContextMenu_Build") then buildOption = v; subMenu = context:getSubMenu(buildOption.subOption); endendif subMenu then --Now you can add your stuff to the build menu. --subMenu:addOption("Build <your object name>", variable1, ISYourClass.onYourFunction, variable2, etc);end What it does is check the already created context menu (the dropdown thing you get when you right click) looks for the submenu called "ContextMenu_Build", and once found it uses that.This way multiple mods can add to it, and there will be no need to overwrite the original lua file. Hope it helps <3 DirtySanchez and The Good Noob 2 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