Hi,
When you next have 15 minutes to spare, I do recommend watching James's tutorials on using regular expressions in VC because it will open up so many different possibilities with the program in the long run--not just with Kodi.
A key problem you're having above is that you're not actually accessing any regular expression matches in your command. Regular expression matches are not returned as {LastResult}.
As the Action Description says:
Performs regular expression matching against the {LastResult} from a previous action, and stores multiple matches in {Match.1} {Match.2} etc.
We perform regular expression matching
on a result (hence the action names Results.Regex/Results.RegexSingle), but then each time the pattern is matched we access it as a {Match.#} – or {Match.#.1}, {Match.#.2} etc. if we want to capture more than one pattern in a single expression, as I suggested that you could do here.
No custom variables should need to be created if you capture both role and actor name in the same regex line.
Below was my suggested solution. There are 2 commands. The event-driven command can replace the default version that comes in your Kodi config.
OnPlay command, with a few lines added to generate the new payload xml
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.2-->
<command id="495" name="XBMC.Player.OnPlay.movie" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="For me, the Kodi "cast" json result returns name: ... then role: ... further down. This may not be true in your Kodi installation. If role is returned before name for you, change the Results.RegExSingle line accordingly.">
<action>
<cmdType>XJson.Raw</cmdType>
<params>
<param>Player.GetProperties</param>
<param>"playerid":1, "properties": ["percentage"]</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>XJson.ParseTokens</cmdType>
<params>
<param>{percentage}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<if ifBlockDisabled="False" ifNot="False">
<ifType>(A)<(B)</ifType>
<ifParams>{LastResult}&&0.1</ifParams>
<then>
<action>
<cmdType>XJson.Raw</cmdType>
<params>
<param>Player.GetItem</param>
<param>"playerid":1, "properties": ["title","cast"]</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegEx</cmdType>
<params>
<param>"name".*?"(.*)"</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.MatchConcat</cmdType>
<params>
<param>, </param>
<param>3</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>XJson.ParseTokens</cmdType>
<params>
<param>Now playing {item.title} starring {lastresult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>XJson.SoftMute</cmdType>
<params>
<param>60</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>TTS.SpeakSync</cmdType>
<params>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>XJson.SoftUnMute</cmdType>
<params />
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>VcAdvanced.Log</cmdType>
<params>
<param>Resuming movie - skip announcement.</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
<action>
<cmdType>PayloadXML.Clear</cmdType>
<params>
<param>XbmcPayloads\movie_roles.xml</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>XJson.Raw</cmdType>
<params>
<param>Player.GetItem</param>
<param>"playerid":1, "properties": ["cast"]</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegExSingle</cmdType>
<params>
<param>"name":\s"(.*?)".*?"role":\s"(.*?)"</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.MatchToXML</cmdType>
<params>
<param>XbmcPayloads\movie_roles.xml</param>
<param />
<param>True</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<event>XBMC.Player.OnPlay.movie</event>
</command>
Command to ask who plays what:
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.2-->
<command id="454" name="Who plays the character {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>{1} plays the character {PF.1}.</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Who plays the character</phrase>
<payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">XbmcPayloads\movie_roles.xml</payloadFromXML>
</command>