Sending Console Message

Sending Console Message

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Sending Console Message

Post 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!
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Sending Console Message

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

Re: Sending Console Message

Post 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?
camo
Posts: 29
Joined: 17 Aug 2010, 20:24

Re: Sending Console Message

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Sending Console Message

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

Re: Sending Console Message

Post 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).
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Sending Console Message

Post 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
:?:
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: Sending Console Message

Post 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 :/
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Sending Console Message

Post 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.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Sending Console Message

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

Re: Sending Console Message

Post 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
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Sending Console Message

Post by knorke »

widgets/gadgets can talk to each other through other ways then the chat console.
"Very important! (allows synced inter-lua-enviroment communications)"
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Sending Console Message

Post 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!
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Sending Console Message

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

Re: Sending Console Message

Post by Von66341 »

Using this we could send information to another player without displaying in the console?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Sending Console Message

Post by knorke »

yes.
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Sending Console Message

Post by Von66341 »

Thanks =)
Post Reply

Return to “Game Development”