{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorInteractPrompt**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== ECBehaviorInteractPrompt ======
{{youtube>QXytMlYqe5U?medium}}
Example usage of interact prompt behavior.
Behavior adding support to elements to show interact prompt to player.
This is a passive behavior storing the information used by player prompt behaviors to show to the player what he can do with the element for example when looking at it.
The promp information composes of an image/video, style, verb, description and command. Not all information is shown by player prompt behaviors. Typically the image/video and verb is shown sometimes only the image/video. If multiple interactions are possible the command is usually also shown. The description can be used if the player needs some more information that can not be easily given using an image/video or a simple interact verb. The style is an optional information can be be used by the player prompt behavior to tint the image/video, verb text or even the description. This can be used to tell the player additional hints like if the interaction has potential caveats or is currently not possible to be done. The meaning of the style value depends on the prompt display widget used. A typical use of style is to be used as suffix for the widget designer selector.
The player prompt behavior determines where the image/video, verb, command and description text is shown.
This behavior has an enabled parameter. This can be used to temporarily disable the interact prompt for example to enable it when certain conditions are met or if multiple interact prompts are used for the same element. This allows to set them all up and enabling only the active one.
The command parameter is the name of the command as present in the CommandManager used by the player interact prompt display. If found the bindings used to trigger this command are shown or the command name whever the prompt display decides to use.
Prompts are typically used with collision testing for example [[behavior_lookat|ECBehaviorLookAt]] and likewise. In this situation it can be useful to assign prompts to individual areas
of a collider for example using hit bone name as produced by collision tests. For this use case the bones parameter can be used. If this parameter is an not an empty list this prompt shall only be considered if the hit bone is included in the list.
====== Instance Counts ======
This behavior can be used multiple times on an element to add different interaction prompts. Use the behavior identifier to tell them apart.
====== Element Class Properties ======
Element class properties have the prefix **interactPrompt.** or **interactPrompt(id).** if id is not empty.
===== image =====
Path to image to use as icon displayed for the prompt.
* Full name: "interactPrompt.image" or "interactPrompt(id).image"
* Type image path
* Default Value //null//
* Example (*.deeclass) useItem.png
===== video =====
Path to video to use as icon displayed for the prompt. If both image and video are used the prompt widget decides which one (or both) to use. The default widget supports both with the video layered on top of the image. This can be used to show a static image with a smaller video inside.
* Full name: "interactPrompt.video" or "interactPrompt(id).video"
* Type video path
* Default Value //null//
* Example (*.deeclass) useItem.ogv
===== style =====
Optional style identifier. The prompt widget decides how to use this identifier. The default widget appends this identifier to the designer selector. Hence in your GUI theme you can use then designers named (for example) //"Label.InteractPromptEntry.{style}"// to modify the text color for different prompt styles. If the style is empty string the unmodified designer selector is used (in this example //"Label.InteractPromptEntry"//).
* Full name: "interactPrompt.style" or "interactPrompt(id).style"
* Type string
* Default Value //empty string//
* Example (*.deeclass) blueColored
===== verb =====
Short text indicating to the player what kind of interaction will take place. This is typically a single word or two like //"Use"//, //"Pick Up"// or //"Interact"//.
* Full name: "interactPrompt.verb" or "interactPrompt(id).verb"
* Type unicode string
* Default Value //empty string//
* Example (*.deeclass) Interact
===== description =====
Optional description text indicating in detail to the player what kind of interaction will take place. This is a typically an entire sentence which can be displayed near the prompt or at the top/bottom edge of the screen. For certain game scenarios this can be useful. Most of the time you do not to use this property. The default prompt widget does display the description underneath the verb.
* Full name: "interactPrompt.description" or "interactPrompt(id).description"
* Type unicode string
* Default Value //empty string//
* Example (*.deeclass) Open the door
===== command =====
Name of the input command required to be used by the player to activate the interaction. If matching an input command name defined by the game the default prompt widget will look up the bindings assigned by the player and shows them below the verb. If the name is //empty string// no bindings will be shown by the default prompt widget.
* Full name: "interactPrompt.command" or "interactPrompt(id).command"
* Type string
* Default Value //empty string//
* Example (*.deeclass) primaryAction
===== bones =====
List of bones to restrict the interact prompt to. This is typically used with [[behavior_lookat|ECBehaviorLookAt]] and similar behaviors using collision tests to figure out what the player wants to interact with. These collision tests also return the name of the hit bone or //null// if this information can not be found. Using the bones property an element can have multiple interact prompts each only showing up if the player looks or clicks at the right spot.
* Full name: "interactPrompt.bones" or "interactPrompt(id).bones"
* Type string list
* Default Value //empty list//
* Example (*.deeclass)
bigBadButton
===== enabled =====
Determines if the interact prompt is enabled. The enabled state can be changed during runtime. This allows to create interact prompts which the player has to first activate somehow.
* Full name: "interactPrompt.enabled" or "interactPrompt(id).enabled"
* Type boolean
* Default Value //true//
* Example (*.deeclass) true
====== Required Behaviors ======
This behavior does not required other behaviors to be present.
====== Optional Behaviors ======
This behavior does not support optional behaviors.
====== Persistency ======
This behavior does not use persistency.
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorInteractPrompt.html,ECBehaviorInteractPrompt~@#.
Since DragonScript Module Version **1.1**
====== Use Cases ======
* Show how player can interact with objects in the game world he is looking at. Requires the object to use ECBehaviorInteractPrompt while the actor (player) requires to use [[behavior_lookat|ECBehaviorLookAt]] and [[behavior_playerlookatinteractprompt|ECBehaviorPlayerLookAtInteractPrompt]].
====== Element Class Example ======
class ObjectElementClass extends BehaviorElementClass
public var ECBehaviorInteractPrompt interactPrompt
public func new() super("ExampleObject")
// create interact prompt behavior. shows an icon with the verb "Interact" underneath.
// the player has to use the input he assigned to the "primaryAction" command.
// also the prompt is only shown if the player looks at the bone named "bigBadButton".
interactPrompt = ECBehaviorInteractPrompt.new(this)
interactPrompt.getImage().setPath("interact.png")
interactPrompt.getVerb().setValue(UnicodeString.newFromUTF8("Interact"))
interactPrompt.getCommand().setValue("primaryAction")
interactPrompt.getBones().add("bigBadButton")
end
end
class PlayerElementClass extends BaseActorClass
public var ECBehaviorLookAt lookAt
public var ECBehaviorPlayerLookAtInteractPrompt playerLookAtInteractPrompt
public func new() super("PlayerActor")
// allow actor to figure out what the player is looking at
lookAt = ECBehaviorLookAt.new(this)
// show an interact prompt widget on screen. the behavior requires a couple of
// parameters to work properly.
//
// you have to create a controller factory instance which allows the behavior
// to create the prompt widget.
//
// then you also have to specify where the newly created prompt widget will be
// added to. in this example the panel is added to the current WindowGameWorld.
// this window uses a StackLayout which works best with PanelInteractPrompt.
// the last parameter is the object layout settings to use while adding the
// widget to the container. this is only required to be non-null if you use
// layouts requiring extra information, for example BorderLayout.
playerLookAtInteractPrompt = ECBehaviorPlayerLookAtInteractPrompt.new(this, \
getPlayerControlled(), lookAt, PanelInteractPromptController.ControllerFactory.new(), \
BaseGameApp.getApp().getWindowGameWorld(), null)
end
end