Prompts script modified from the Crayta Prompts package.
Advanced prompts allows multiple prompts for the same button, specification of the order the prompts should be displayed in, and player specific prompts.
To install search for “Advanced Prompts” in the community tab.
Basic Crayta prompts:
Add a function called GetButtonPrompts
to scripts in the User or Player entities that take in a prompts
table as an argument. Can also add the function GetInteractPrompt
to an entity you can interact with in order to have a prompt show up.
Add property keys to the prompts object that are the same as the button names to add a prompt (i.e.,
function UserScript:GetButtonPrompts(prompts)
prompts.interact = "do a thing"
end
The formatting for the prompts will be default be the same as the pressText
property, defaulted to Press {button} to {action}
where {button}
will be replaced with the button icon and {action}
will be replaced with the string/text you set in the prompts
table. In the example above, it would become: Press {interact-icon} to do a thing
.
If you want something other than the default pressText
, then set the table value to a string that includes the full {button-icon}
string in the value.
i.e.,
function InteractableItemScript:GetInteractPrompt(prompts)
prompts.interact = "Hold {interact-icon} to do a special thing"
end
Usage is same as the Crayta prompts package except for the following:
GetInteractPrompt
is now also passed the player that is looking at the entity so that you can check for player specific logic (i.e., if they have enough credits to buy the item, they found something that they need to unlock the item, etc.)
Each value in prompts
can now be a table so you can have multiple prompts for the same action key
i.e.,
function UserScript:GetButtonPrompts(prompts)
prompts.interact = { "do a thing", "Hold {interact-icon} to do another thing" }
end
prompts
now can now have a value assigned to prompts.order
which should be a table that will determine the order in which the prompts will show up (note: if order
is used only the buttons that are in the order
table will show up)
example:
function UserScript:GetButtonPrompts(prompts)
prompts.interact = { "do a thing", "Hold {interact-icon} to do another thing" }
prompts.extra1 = "do a third thing"
prompts.extra2 = "not show up"
prompts.order = { "extra1", "interact" }
end
This will results in the following prompts:
Press {extra1-icon} to do a third thing
Press {interact-icon} to do a thing
Hold {interact-icon} to do another thing
– extra2
prompts will not show up as it was not in prompts.order