zetake Posted July 21, 2019 Share Posted July 21, 2019 (edited) Hello, I'll show you how to make custom action that will dependent on the tech level. Description: Spoiler This will allow you to make custom actions that will require some station to be done. It will work like crafting tabs. For exaple, you wanted to do fuel that could be added only if you are standing close to Sea Lab. Now you can make it... or anything you want... Available TECH levels: Spoiler SCIENCE 0 = None 1 = Tier 1 = Science Machine 2 = Tier 2 = Alchemy Engine or Sea Lab MAGIC0 = None1 = Science Machine or Alchemy Engine 2 = Tier 1 = Prestihatitator, Piratihatitator or Hogus Porkusator 3 = Tier 2 = Shadow Manipulator ANCIENT 0 = None 2 = Broken Ancient Pseudoscience Station 4 = Ancient Pseudoscience Station OBSIDIAN 0 = None 2 = Obsidian Workbench WATER0 = None 2 = Sea Lab HOME0 = None 2 = Slanty Shanty CITY0 = None 2 = Key to the City LOST0 = None Available operators: Spoiler EQUAL == NOT EQUAL ~= GREATER > LESS < GREATER or EQUAL >= LESS or EQUAL <= Custom Action: Spoiler Custom Action Example (Goes to modmain.lua) local Action = GLOBAL.Action local ActionHandler = GLOBAL.ActionHandler local actionname = Action({mount_enabled=true}) actionname.str = "Action name" -- Name of your action. actionname.id = "ACTIONNAME" -- ID of your action. actionname.fn = function(act) local builder = act.doer.components.builder local MAGIC = builder.accessible_tech_trees.MAGIC -- TECH level for your action, in this cace MAGIC. if builder and MAGIC > 1 then -- Executable if close to Prestihatitator/Piratihatitator/Hogus Porkusator, Shadow Manipulator or your character MAGIC = 2 or 3 -- Your action. end end AddAction(actionname) AddStategraphActionHandler("wilson", ActionHandler(actionname, "dolongaction")) Custom Components Function Example (Goes to custom component) function Componentname:CollectUseActions(doer, target, actions) local builder = doer.components.builder local MAGIC = builder.accessible_tech_trees.MAGIC -- TECH level for your action, in this cace MAGIC. if builder and (MAGIC == 1 or MAGIC == 2) then -- Available if close to Science Machine/Alchemy Engine, Prestihatitator/Piratihatitator/Hogus Porkusator or your character MAGIC = 1 or 2 -- Your function. end end Function is responsible for showing and calling action. Action is responsible for executing action. Function can be different than Action, but if Action won't be true, it will fail after animation which in this case was "dolongaction". Edited July 21, 2019 by zetake 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