Index
Page Contents

Chat Lua Functions

These functions are available to Lua scripts running on the server in the context of chat.


Chat Message Functions

Note:All messages sent with these functions will appear to be from "System" on the player's end.

PostServerChatMessage

PostServerChatMessage(channel_id, message)

Parameters

  • channel_id - Chat Channel for the message
  • message - The message to post. Can include emoji.

Example

PostServerChatMessage("server-home", "The server will be shutting down in 4 minutes.")

PostServerChatMessageExt

PostServerChatMessageExt(channel_id, message, image_id, document_id)

Description

Posts a message to a chat channel. Extended function can include an image and/or attached document.

Parameters

  • channel_id - Chat Channel for the message
  • message - The message to post. Can include emoji.
  • image_id - Path to image relative to the save's "chat-images" folder, or nil for none.
  • document_id - Path to image relative to the save's "chat-documents" folder, or nil for none.

Example

PostServerChatMessageExt("server-home", "Please read our server rules!", "server-rules.png", "server-rules.txt")

SendServerChatMessageToUser

SendServerChatMessageToUser(to_user_id, channel_id, message)

Parameters

  • touserid - User login id to send the message to
  • channel_id - Chat Channel for the message
  • message - The message to post. Can include emoji.

Example

SendServerChatMessageToUser("joe", "server-chat", "Stop attacking the Jidou!")

SendServerChatMessageToUserExt

SendServerChatMessageToUserExt(to_user_id, channel_id, message)

Parameters

  • touserid - User login id to send the message to
  • channel_id - Chat Channel for the message
  • message - The message to post. Can include emoji.
  • image_id - Path to image relative to the save's "chat-images" folder, or nil for none.
  • document_id - Path to image relative to the save's "chat-documents" folder, or nil for none.

Example

SendServerChatMessageToUserExt("joe", "server-chat", "Stop attacking peaceful Jidou!", "sad-jidou.png", "server-rules.txt")

IssueInviteCode

IssueInviteCode(admin_password, login_name)

Parameters

  • admin_password - Must match admin password set in the save game's configuration. (For safety)
  • id - An identifier for the new invite code, just for tracking purposes.

Example

IssueInviteCode("my_admin_password", "joe")

Information

This function can be used (in combination with a chat LUA script) to create invite codes to join the server. After calling this function the name and generated invite code will be appended to the "invite-codes.txt" file in the save game's folder.

Effect Functions

To-Do:These functions should be moved to the Common Server Functions.

PlayEffectInst

PlayEffectInst(instance_id, effect_resource_id)

Parameters

  • instance_id - GameObject Instance ID that the effect will be played on
  • effectresourceid - Path to effect file

Information

This function will play an effect file on a GameObject Instance (like a character, creature, etc.). The effect is only played on the client and visible to all players.

PlayEffectPos

PlayEffectPos(position, effect_resource_id)

Parameters

  • position - A position string where the effect will be played. (The string should look something like: PL:forra:0:-4:54:15.646,1.498,5.153:0.000,0.375,-0.000,0.927)
  • effectresourceid - Path to effect file

Information

This function will play an effect file on a GameObject Instance (like a character, creature, etc.). The effect is only played on the client and visible to all players.

Administration Functions

Warning:These functions are intended for development and debugging. Read all warnings and be very careful with these.

ReloadSkills

Warning: Only use this on development servers or in an emergency. Calling this function on a server with active players will likely have ill effects. Depending on what data is changed players quests may become stuck or broken, NPC conversations may need to be escaped and restarted, etc.
ReloadSkills()

Parameters

  • none

Example

ReloadSkills()

Information

Calling this function safely reloads the data for all skills, projectiles, NPC conversations, and quests on the server across all simulation threads. Useful when building and debugging quests. This function will likely be renamed in the future to something more generic.