View topic - Sending Console Message



All times are UTC + 1 hour


Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: Sending Console Message
PostPosted: 01 Jun 2011, 09:46 

Joined: 10 Feb 2011, 03:00
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!


Top
 Offline Profile  
 
PostPosted: 01 Jun 2011, 12:38 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
Quote:
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:


Top
 Offline Profile  
 
PostPosted: 01 Jun 2011, 13:44 

Joined: 10 Feb 2011, 03:00
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?


Top
 Offline Profile  
 
PostPosted: 01 Jun 2011, 14:21 

Joined: 17 Aug 2010, 19:24
Location: Start 1
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.


Top
 Offline Profile  
 
PostPosted: 01 Jun 2011, 21:29 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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.


Top
 Offline Profile  
 
PostPosted: 02 Jun 2011, 10:55 

Joined: 10 Feb 2011, 03:00
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).


Top
 Offline Profile  
 
PostPosted: 02 Jun 2011, 12:01 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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_UnsyncedCtrl#SendLuaMessage
+
http://answers.springlobby.info/questions/429/howto-write-to-a-file-from-lua
:?:


Top
 Offline Profile  
 
PostPosted: 04 Jun 2011, 01:57 
Lobby Developer
User avatar

Joined: 25 Sep 2006, 12:56
/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 :/


Top
 Offline Profile  
 
PostPosted: 06 Jun 2011, 04:29 

Joined: 10 Feb 2011, 03:00
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.


Top
 Offline Profile  
 
PostPosted: 06 Jun 2011, 09:24 
Moderator

Joined: 12 Oct 2007, 08:24
Quote:
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.


Top
 Offline Profile  
 
PostPosted: 06 Jun 2011, 16:51 

Joined: 10 Feb 2011, 03:00
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


Top
 Offline Profile  
 
PostPosted: 06 Jun 2011, 19:58 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
widgets/gadgets can talk to each other through other ways then the chat console.
knorke wrote:
"Very important! (allows synced inter-lua-enviroment communications)"


Top
 Offline Profile  
 
PostPosted: 07 Jun 2011, 09:56 

Joined: 10 Feb 2011, 03:00
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!


Top
 Offline Profile  
 
PostPosted: 07 Jun 2011, 16:27 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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:
luamsgpre = "tpMSGBOX"
luascoremsgpre ="tpSCORE"

the gadget then does stuff like
Code:
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:
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.


Top
 Offline Profile  
 
PostPosted: 08 Jun 2011, 10:40 

Joined: 10 Feb 2011, 03:00
Using this we could send information to another player without displaying in the console?


Top
 Offline Profile  
 
PostPosted: 08 Jun 2011, 15:29 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
yes.


Top
 Offline Profile  
 
PostPosted: 10 Jun 2011, 09:29 

Joined: 10 Feb 2011, 03:00
Thanks =)


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.