Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

terminal actions available to PB

Discussion in 'Programming (In-game)' started by hellokeith, Jun 9, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. hellokeith Apprentice Engineer

    Messages:
    335
    Where are these defined in the source?

    For example, I have located the ShootOnce action that actually fires a weapon once, but I see no enabling/disabling/connection to terminalactions or modapi.ingame that lets an ingame script do it.
     
  2. mexmer Senior Engineer

    Messages:
    1,977
    can't say i understand what you asking for, but this is my evaluation code, to retrieve block actions and properties, that are not described in documentation (because they are accessible trough terminal extension interface)
    don't forget to replace IMyAirvent with any existing block, you want to retrieve actions and properies for.
    Code:
    void Main()
    {
    	IMyTextPanel screen = (IMyTextPanel) GridTerminalSystem.GetBlockWithName("LCD Test");
    	if (screen != null)
    	{
    		StringBuilder values = new StringBuilder();
    		List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>();
    		StringBuilder test = new StringBuilder();
    		GridTerminalSystem.GetBlocksOfType<IMyAirVent>(blocks);
    		if (blocks.Count > 0)
    		{
    			List<ITerminalAction> resultList = new List<ITerminalAction>();
    			IMyTerminalBlock unit = blocks[0];
    			unit.GetActions(resultList);
    			values.Append("IMyAirVent\nActions:\n" + unit.CustomName + "\n");
    			for (int i=0;i<resultList.Count;i++)
    			{
    				StringBuilder temp = new StringBuilder();
    				values.Append(resultList[i].Id + ":" + resultList[i].Name + "(");
    				if (resultList[i].Id.Length == 0)
    					resultList[i].WriteValue(unit, temp);
    				else
    					unit.GetActionWithName(resultList[i].Id.ToString()).WriteValue(unit, temp);
    
    				values.Append(temp.ToString());
    				values.Append(")\n");
    			}
    			List<ITerminalProperty> propList = new List<ITerminalProperty>();
    			unit.GetProperties(propList);
    			values.Append("\nProperties:\n");
    			for (int i=0;i<propList.Count;i++)
    				values.Append(propList[i].Id + ":" + propList[i].TypeName + "\n");
    
    			values.Append("\nDetailedInfo:\n" + unit.DetailedInfo);
    			values.Append("\n----------\n");
    		}
    		else
    			values.Append("No Blocks Found");
    
    		screen.SetValue("FontSize", 0.8f);
    		screen.ShowTextureOnScreen();
    		screen.WritePublicText(values.ToString());
    		screen.ShowPublicTextOnScreen();
    	}
    }
    
     
  3. hellokeith Apprentice Engineer

    Messages:
    335
    No, where in the source code. Take a look at the Laser Antenna. Only a subset of the buttons in the terminal are made available to the script as terminal actions. Where is this capability/limitation defined?
     
  4. mexmer Senior Engineer

    Messages:
    1,977
    in last update all on/off button and checkboxes on blocks were made available as actions or as boolean property (or both)
    this is output from code i posted above for laser antenna block
    Code:
    IMyLaserAntenna
    Actions:
    Laser Antenna Platform
    OnOff:Toggle block On/Off(On)
    OnOff_On:Toggle block On(On)
    OnOff_Off:Toggle block Off(On)
    Idle:Idle()
    PasteGpsCoords:Paste coords()
    ConnectGPS:Connect to coords()
    isPerm:Permanent connection On/Off(On)
    
    Properties:
    OnOff:Boolean
    ShowInTerminal:Boolean
    ShowOnHUD:Boolean
    isPerm:Boolean
    
    DetailedInfo:
    Type: Laser Antenna
    Current Input: 576.00 kW
    Connected to Laser Antenna Outpost
    ----------
    
    if you want to discuss source code and not programable block scripts, there is different section for that.
     
  5. Mauzen Trainee Engineer

    Messages:
    75
  6. mexmer Senior Engineer

    Messages:
    1,977
    Actions are not added trough sbc file. As for terminal extension for actions, every control that has action (in GetActions) must have .EnableAction() or .EnableActions() entry in sourcecode.
    What you see in sbc files are parameters, if it's savefile it might be also state of control (for buttons and checkboxes) or content of control (for listboxes, textboxes, combos).
     
  7. Textor Junior Engineer

    Messages:
    775
    I can't find the action definitions in the source code anywhere. Searching for common ones like, say, "OnOff_On" returns no results. I think they are defined elsewhere, though I can't figure out where at the moment. I was able to find the code that makes the actions do what they do, though.
     
  8. mexmer Senior Engineer

    Messages:
    1,977
    OnOff_On
    Depresurize_On
    ShowInHud_On
    etc.
    are created by code following way
    Id+"_On"
    Id+"_Off"

    that's why i said, you need to evaluate code (shown above) in PB.
    Depending on control, it might have EnableAction(), EnableActions(), EnableToggle(), EnableOnOffActions() and so on.
    Terminal property is quite complex thing and uses templates and parametrization.

    anyway, like i said, for discussing sourcecode, there is different section.
     
Thread Status:
This last post in this thread was made more than 31 days old.