Script objects: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(update after split)
(add tdm_gui_message)
Line 1: Line 1:
== Introduction ==
== Introduction ==


A '''script object''' is an object that is written in the idTech4 scripting language, and an be attached to arbitrary entities. Each entity can have '''only one''' script object.
A '''script object''' is an object that is written in the idTech4 scripting language, and an be attached to arbitrary entities. Each entity can have '''only one''' script object, but one script object can be attached to multiple entities.


For your convience, TDM already contains a few useful script objects:
For your convience, TDM already contains a few useful script objects:
Line 22: Line 22:


This script object also makes the entity react to fire stims, an/or triggers like when you link a button/lever/trigger to this entity.
This script object also makes the entity react to fire stims, an/or triggers like when you link a button/lever/trigger to this entity.
=== tdm_gui_message ===
This script object is attached to an atdm:target_message entity, and the entity shows a message to the player, based on cvars and spawnargs. You can use this script object for the "popup" messages that appear on the upper left corner (f.i. to give the player hints) or for screeen overlays like in a movie, where it says f.i. "Random Town, past midnight". Where the message appears and how it looks is entirely customizable by using a different gui.
==== CVARs ====
* '''tdm_show_trainer_messages''' - if true, the messages are shown, if false, suppressed
==== Spawnargs ====
* '''show'''- The time in seconds the message is shown, will be longer by approx. one second to fade the message out. If set to 0, shows the message for 6 seconds plus 1s fade out.
* '''lines''' - Number of lines the text has
* '''text''' - The text to be shown on the message.
* '''gui''' - Name of the GUI file, defaults to ''guis/message.gui''
* '''wait''', '''delay''' - These two are inherited from '''atdm:target_callobjectfunction''' and set the "wait" between triggers and the initial "delay" before the messsage show.
* '''fade_out_time''' - Defaults to 1, in seconds. This time is waited for the GUI to fade out, then the message is forcefully removed. If you use a different gui with "gui", then set this spawnarg to match the fadeout time of your gui.
* '''auto_trigger''' - Boolean, if true, the msg is triggered "delay" seconds after map load automatically.
* '''force''' - Boolean, if true, the msg is always shown, regardless of the menu setting (e.g. the CVAR).
==== Notes ====
# Currently messages just overlay each other on the screen. So if a later messages is displayed while an old message is still there, they fade over from the old one to the new one.
# If the player then steps back into the first trigger, the old message is not displayed again, because it is still waiting around.


== See also ==
== See also ==

Revision as of 14:06, 15 January 2011

Introduction

A script object is an object that is written in the idTech4 scripting language, and an be attached to arbitrary entities. Each entity can have only one script object, but one script object can be attached to multiple entities.

For your convience, TDM already contains a few useful script objects:

tdm_suicide

 "script_object" "tdm_suicide"
 "remove_delay"  "100"              // remove this entity 100 seconds after spawning it

tdm_light_holder

 "script_object" "tdm_light_holder"
 "extinguished"  "1"                // the light starts off, but can be lit by the player

This is typical attached to either lights (an electrical lamp f.i.) or light holders (a candle holder with attached candle + flame, or a torch with attached flame). This script object has handy methods to toggle all lights that this holder has, regardless how many (multiple flames?) or where (flame on holder or flame on candle on holder?).

This script object also makes the entity react to fire stims, an/or triggers like when you link a button/lever/trigger to this entity.

tdm_gui_message

This script object is attached to an atdm:target_message entity, and the entity shows a message to the player, based on cvars and spawnargs. You can use this script object for the "popup" messages that appear on the upper left corner (f.i. to give the player hints) or for screeen overlays like in a movie, where it says f.i. "Random Town, past midnight". Where the message appears and how it looks is entirely customizable by using a different gui.

CVARs

  • tdm_show_trainer_messages - if true, the messages are shown, if false, suppressed

Spawnargs

  • show- The time in seconds the message is shown, will be longer by approx. one second to fade the message out. If set to 0, shows the message for 6 seconds plus 1s fade out.
  • lines - Number of lines the text has
  • text - The text to be shown on the message.
  • gui - Name of the GUI file, defaults to guis/message.gui
  • wait, delay - These two are inherited from atdm:target_callobjectfunction and set the "wait" between triggers and the initial "delay" before the messsage show.
  • fade_out_time - Defaults to 1, in seconds. This time is waited for the GUI to fade out, then the message is forcefully removed. If you use a different gui with "gui", then set this spawnarg to match the fadeout time of your gui.
  • auto_trigger - Boolean, if true, the msg is triggered "delay" seconds after map load automatically.
  • force - Boolean, if true, the msg is always shown, regardless of the menu setting (e.g. the CVAR).

Notes

  1. Currently messages just overlay each other on the screen. So if a later messages is displayed while an old message is still there, they fade over from the old one to the new one.
  2. If the player then steps back into the first trigger, the old message is not displayed again, because it is still waiting around.

See also