wiki.sine.space | sinespace

Difference between revisions of "Scripting/SChat"

From wiki.sine.space
Jump to: navigation, search
Line 2: Line 2:
  
 
{{ScriptFunction|void|JoinChat|(string name);|Join a chat channel.|5=
 
{{ScriptFunction|void|JoinChat|(string name);|Join a chat channel.|5=
Space.Network.Chat.JoinChat("Test room")
+
Space.Network.Chat.JoinChat("Test room")|6=<pre>--this script will make the player join a chat when entering a trigger collider and leave it when leaving
 +
--[Requires this object to have a "Trigger" collider]
 +
 
 +
thisObject = Space.Host.ExecutingObject
 +
thisPlayer = Space.Scene.PlayerAvatar
 +
 
 +
OTS = function(gameObject)
 +
  if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
 +
 
 +
    Space.Network.Chat.JoinChat("PrivateChatZone")
 +
   
 +
  end
 +
 
 +
end
 +
 
 +
OTE = function(gameObject)
 +
  if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
 +
 
 +
    Space.Network.Chat.LeaveChat("PrivateChatZone")
 +
   
 +
  end
 +
 
 +
end
 +
 
 +
 
 +
thisObject.OnTriggerStart(OTS)
 +
thisObject.OnTriggerExit(OTE)</pre>
 +
}}
 +
 
 +
{{ScriptFunction|void|LeaveChat|(string name);|Leave a chat channel.|5=
 +
Space.Network.Chat.LeaveChat("Test room")|6=<pre>--this script will make the player join a chat when entering a trigger collider and leave it when leaving
 +
--[Requires this object to have a "Trigger" collider]
 +
 
 +
thisObject = Space.Host.ExecutingObject
 +
thisPlayer = Space.Scene.PlayerAvatar
 +
 
 +
OTS = function(gameObject)
 +
  if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
 +
 
 +
    Space.Network.Chat.JoinChat("PrivateChatZone")
 +
   
 +
  end
 +
 
 +
end
 +
 
 +
OTE = function(gameObject)
 +
  if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then
 +
 
 +
    Space.Network.Chat.LeaveChat("PrivateChatZone")
 +
   
 +
  end
 +
 
 +
end
 +
 
 +
 
 +
thisObject.OnTriggerStart(OTS)
 +
thisObject.OnTriggerExit(OTE)</pre>
 
}}
 
}}
  
Line 19: Line 75:
 
}}
 
}}
  
{{ScriptFunction|void|LeaveChat|(string name);|Leave a chat channel.|5=
+
 
Space.Network.Chat.LeaveChat("Test room")
+
}}
+
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 12:30, 22 November 2021

Members

JoinChat

void JoinChat (string name);

Join a chat channel.

Space.Network.Chat.JoinChat("Test room")


--this script will make the player join a chat when entering a trigger collider and leave it when leaving
--[Requires this object to have a "Trigger" collider]

thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar

OTS = function(gameObject)
  if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then 

    Space.Network.Chat.JoinChat("PrivateChatZone")
    
  end

end

OTE = function(gameObject)
  if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

    Space.Network.Chat.LeaveChat("PrivateChatZone")
    
  end 
  
end


thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)

LeaveChat

void LeaveChat (string name);

Leave a chat channel.

Space.Network.Chat.LeaveChat("Test room")


--this script will make the player join a chat when entering a trigger collider and leave it when leaving
--[Requires this object to have a "Trigger" collider]

thisObject = Space.Host.ExecutingObject
thisPlayer = Space.Scene.PlayerAvatar

OTS = function(gameObject)
  if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then 

    Space.Network.Chat.JoinChat("PrivateChatZone")
    
  end

end

OTE = function(gameObject)
  if gameObject.Avatar ~= nil and thisPlayer == gameObject.Avatar then

    Space.Network.Chat.LeaveChat("PrivateChatZone")
    
  end 
  
end


thisObject.OnTriggerStart(OTS)
thisObject.OnTriggerExit(OTE)

OnChat

void OnChat (Action< SChatMessage > callback);
Bind a function to the OnChat event. This function will be called every time a new chat message is received on the local channel.
function oc(SChatMessage)
  Space.Log(SChatMessage.Message)
end

Space.Network.Chat.OnChat(oc) 



GetXMPPName

string GetXMPPName (string name);

Get XMPP name.

Space.Network.Chat.GetXMPPName("Test room")