Accepting mission

Hello Еveryone!

I am very impressed with the capabilities of this framework. Many thanks to the author. Excellent work!

But I had a little difficulty with acceptance the quest. When i try to accept quest i use next command:

HostSanderling.MouseClickLeft(HostSanderling?.MemoryMeasurement?.Value?.WindowAgentDialogue?[0]?.ButtonText?[0]);

and have Error:

Error3184CS1061’IWindowAgentDialogue’ does not contain a definition for ‘ButtonText’ and no extension method ‘ButtonText’ accepting a first argument of type ‘IWindowAgentDialogue’ could be found (are you missing a using directive or an assembly reference?)

But at the same time API Explorer displays the path without problems: proof.

I test this code on the  SINGULARITY, docked in the station:

1 Like
//    This is a warp to 0km auto-pilot, making your travels faster and thus safer by directly warping to gates/stations.  while(true) {     var Measurement = HostSanderling?.MemoryMeasurement?.Value;           var Station = Measurement?.WindowStation;          if(null!=Station)     {         var Agent = Station?.FirstOrDefault()?.AgentEntry?.FirstOrDefault();         if (null != Agent)          {             Host.Log("Agent name:  "+Agent?.LabelText?.FirstOrDefault()?.Text);                          if (Agent?.StartConversationButton != null)             {                 HostSanderling.MouseClickLeft(Agent?.StartConversationButton);                 Host.Log("StartConversationButton clicked.");                                                  //    retrieve a new measurement.                 Measurement = HostSanderling?.MemoryMeasurement?.Value;                                  var WindowAgentDialogue = Measurement?.WindowAgentDialogue?[0];                 if (WindowAgentDialogue != null)                  {                                 //    Error    29    84    CS1061    'IWindowAgentDialogue' does not contain a definition for 'ButtonText'                      //    and no extension method 'ButtonText' accepting a first argument of type 'IWindowAgentDialogue'                      //    could be found (are you missing a using directive or an assembly reference?)                         var text =  HostSanderling?.MemoryMeasurement?.Value?.WindowAgentDialogue?[0]?.ButtonText?[0]?.Text;                                         HostSanderling.MouseClickLeft(HostSanderling?.MemoryMeasurement?.Value?.WindowAgentDialogue?[0]?.ButtonText?[0]);                     Host.Log("WindowAgentDialogue not null.
" );                 }             }             else             {                 Host.Log("StartConversationButton not found.");             }                     }     }     else     {     } loop:     //    wait for four seconds before repeating.     Host.Delay(4000);     }

What am i doing wrong?

Looks like you found a bug.

The member ‘ButtonText’ is missing on the type known to the script compiler. That is the reason the compiler complains. I will fix this in the next release.

The API Explorer knows something the script compiler does not: That the actual window object is of type ‘Sanderling.Interface.MemoryStruct.WindowAgentDialogue’. (The type of an object is shown on the right of the item in the tree view) And here also lies the key to work around this bug: To stop the compiler from complaining tell it about the type you are expecting there with a cast expression. (In this case you don’t have to add the namespace ‘Sanderling.Interface.MemoryStruct’ in front because the scripting framework took care of this)

After applying the cast, the code looks like this (it compiles without errors):

var text =  (HostSanderling?.MemoryMeasurement?.Value?.WindowAgentDialogue?[0] as WindowAgentDialogue)?.ButtonText?[0]?.Text;                    HostSanderling.MouseClickLeft((HostSanderling?.MemoryMeasurement?.Value?.WindowAgentDialogue?[0] as WindowAgentDialogue)?.ButtonText?[0]);

I have not investigated your code thoroughly but for identifying the accept button I’d suggest testing for its label like so:

var    DialogueWindow = (HostSanderling?.MemoryMeasurement?.Value?.WindowAgentDialogue?[0] as WindowAgentDialogue);var AcceptButton = DialogueWindow?.ButtonText?.FirstOrDefault(b => b.Text == "Accept");

This way your code won’t depend on the order of the buttons anymore.

Let me know in case you see any further impediments.

1 Like

Thank you for replying. It’s completely fix my problem.
If i will have another questions, should i create new topic or ask them here?

Thank you for replying. It’s completely fix my problem.
If i will have another questions, should i create new topic or ask them here?

It depends on the question.

Would people expect it in a thread having only read the title and content of the first post? If you think that applies to a thread then you can append it there.

If you are not sure about that, just open a new one.

Todays release brought a fix for this bug as well as new features.