Ok I'm getting there now. Went back to the beginning and started from scratch. What happens now is
-I record in a variable the last command that I sent out.
-I then check each incoming line for the prompt
-When prompt is matched, I check the line to see if it matches my last command sent out.
if it does, then it's a local command and I simply add a carriage return in front to revert the prompt.
if it does not, then it's a command from the remote player and so I will need to add the |1| to the front of the line if not present
<variables>
<variable name="snoopcheck">N</variable>
<variable name="commcheck">empty</variable>
</variables>
<!-- Script -->
<script>
<![CDATA[
function OnPluginCommandEntered (sText)
local snoopy = GetVariable ("snoopcheck")
-- only apply if actively snooping
if string.match (snoopy, "Y") then
newcommand = "\r\n" .. sText
-- Note ("add CR")
return newcommand
else
return sText
end -- if
end -- function
function OnPluginSent (sText)
SetVariable ("commcheck", sText)
end -- function
function OnPluginLineReceived (sText)
local origin = GetVariable ("commcheck")
test1 = sText
if (string.match (test1, "^%*") or string.match (test1, "^%|1%|%*")) then -- line is a command
-- Note ("Command issued")
if string.match (sText, origin) then
-- Note ("Command was sent locally")
world.SetVariable ("commcheck", "empty")
-- No need to do anything else as OnPluginCommandEntered will issue /r to revert prompt
else
-- Note ("Command was sent remotely")
world.SetVariable ("commcheck", "empty")
-- <code to add |1| to beginning of line if currently on standard prompt>
end -- if
else
-- Note ("Not a command")
end -- if
return true -- display it
end -- function
]]>
</script>
|