Page 1 of 1

Sending Console Message

Posted: 01 Jun 2011, 10:46
by Von66341
Hello!

Would like to ask if it is possible to send what I type in to the console to my oponent screen?
But only display when I want it to? Or totally do not display?

Thanks!

Re: Sending Console Message

Posted: 01 Jun 2011, 13:38
by knorke
Would like to ask if it is possible to send what I type in to the console to my oponent screen?
press enter to send the message?
dont really understand the question here :shock:

Re: Sending Console Message

Posted: 01 Jun 2011, 14:44
by Von66341
Spring.Echo("message") > this display message on everyone in the game console?
Or it only display on the player console?

For example, I have this message > "test"
But would want test to only show up on the opponent screen when I want to, will it be possible?

Re: Sending Console Message

Posted: 01 Jun 2011, 15:21
by camo
http://springrts.com/wiki/LuaCallinReturn
AddConsoleLine() --> "msg, priority"
i.e. write a widget:AddConsoleLine(msg, priority)

Chat-Messages are a string in the form:
<NAME> MESSAGE

So you have the playername, check if it's from an enemy and start action. The highest detailed answer for the question possible.

Re: Sending Console Message

Posted: 01 Jun 2011, 22:29
by knorke
echo in a gadget: shows only the message, no player name. visible to all.

echo in a widget: just visble to the player running the widget. at least i think because otherwise i wonder why nobody complaint on the occaisions where i accidently spammed the chat with widgets going mad :roll:

To send chat a chatmessage from widget use Spring.SendCommands("say blabla")
Spring.SendCommands("say a: blabla") for teamchat.

Re: Sending Console Message

Posted: 02 Jun 2011, 11:55
by Von66341
Hmm..i tried Spring.SendCommands("say blabla") and Spring.SendCommands("say a: blabla") but the message is still display in the console/chat.

For example, the players type the following:
Player A: Alpha
Player B: Bravo

Can we send the message player B has 'Bravo' to player A side without displaying it in the chat?

I need player A to have player B message in the console(such that it will be log in the infolog.txt but not show in the chat).

Re: Sending Console Message

Posted: 02 Jun 2011, 13:01
by knorke
the text entered in chat is always visible to all players unless you hide the console completly with /console 0
Maybe you want
http://springrts.com/wiki/Lua_UnsyncedC ... LuaMessage
+
http://answers.springlobby.info/questio ... e-from-lua
:?:

Re: Sending Console Message

Posted: 04 Jun 2011, 02:57
by BrainDamage
/w playername message
is supposed to whisper a message to a player, except in current version it seems broken, as in no message is recieved :/

Re: Sending Console Message

Posted: 06 Jun 2011, 05:29
by Von66341
Thanks for all the help!

The above is able to send message and the opponent will be able to see.

However, I want to sent a message while the opponent do not see it. In the end, I use "/n" (insert new line) to clear the console before the opponent could see.

Re: Sending Console Message

Posted: 06 Jun 2011, 10:24
by Google_Frog
However, I want to sent a message while the opponent do not see it. In the end, I use "/n" (insert new line) to clear the console before the opponent could see.
This doesn't work. The opponent may be using a lua console which does not display the extra newlines or allows the user to scroll up and look at the message. If you entirely disable lua the opponent could still read the message by opening and reloading their infolog as Spring writes to it.

Re: Sending Console Message

Posted: 06 Jun 2011, 17:51
by Von66341
yup. in my case I want to send the message player A has to player B computer (infolog and also a txt file that I ask a widget to write that message). but doesn't want the player to be able to see in the console =D

Re: Sending Console Message

Posted: 06 Jun 2011, 20:58
by knorke
widgets/gadgets can talk to each other through other ways then the chat console.
"Very important! (allows synced inter-lua-enviroment communications)"

Re: Sending Console Message

Posted: 07 Jun 2011, 10:56
by Von66341
Thanks knorke!
Understand the concept of the communication between widget and gadget.

Say we have lots of messages going in between the widget and gadget.
How do we check the contains of the message to what we want before we do the action? string.gmatch(message, keyword)?

Thanks!

Re: Sending Console Message

Posted: 07 Jun 2011, 17:27
by knorke
in spring tanks i do it like this:
(in ST there are two kind of messages the gadget can send to the widget:
1) "game event messages" like "the game has started!" etc
2) "score table messages" which is the current score of all players packed into a string)

I prefix messages with stuff so the widget can tell them apart:

Code: Select all

luamsgpre = "tpMSGBOX"
luascoremsgpre ="tpSCORE"
the gadget then does stuff like

Code: Select all

Spring.SendLuaUIMsg (luamsgpre .. "The game has ended!")
Spring.SendLuaUIMsg (luamsgpre .. "<TEAM" .. flagteam .. "> returned his flag")
...
Spring.SendLuaUIMsg (luascoremsgpre .. score_string())
and on widget side:

Code: Select all

function widget:RecvLuaMsg(msg, playerID)
	luamsgpre = "tpMSGBOX"
	luascoremsgpre ="tpSCORE"
	if (msg:find(luamsgpre,1,true)) then
  --display the message in the UI
	end
	
	if (msg:find(luascoremsgpre,1,true)) then
 --take the string apart and update the score display
	end
end
For widget->gadget talk I would do it the same way, I think.
Just with SendLuaRulesMsg instead of SendLuaUIMsg.

Re: Sending Console Message

Posted: 08 Jun 2011, 11:40
by Von66341
Using this we could send information to another player without displaying in the console?

Re: Sending Console Message

Posted: 08 Jun 2011, 16:29
by knorke
yes.

Re: Sending Console Message

Posted: 10 Jun 2011, 10:29
by Von66341
Thanks =)