Welcome to the Builder Academy

Question Trigger of the Day - Room Global Random Example

More
15 Jun 2013 20:42 #3123 by Rumble
Code:
Name: 'Room Global Random Example', VNum: [ 50], RNum: [ 50] Trigger Intended Assignment: Rooms Trigger Type: Global Random , Numeric Arg: 1, Arg list: None Commands: * By Rumble of The Builder Academy tbamud.com 9091 * Global makes this trigger fire whether a player is in the room or not. switch %random.4% case 1 %echo% A shrill cry from a distant bird pierces the air. break case 2 %echo% The town bell rings in the distance. break case 3 %echo% Several doves coo overhead in the alcoves. break default %echo% Voices can be heard conversing in the distance. break done
Since random triggers fire every 13 seconds you can set how often the trigger
fires by modifying numeric arg to the following values:

1% = 22 minutes
2% = 11 minutes
5% = 4 minutes
10% = 2 minutes
20% = 1 minute
50% = 26 seconds
100% = 13 seconds

The actual equation is 100/numeric arg X 13 = time in seconds. 100/20 X 13 = 65 seconds

If this was helpful please vote or leave a review for TBA.

Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com

Please Log in or Create an account to join the conversation.

More
17 Jun 2013 16:25 #3142 by Fizban
Probably worth noting that a random trigger with numeric arg 1 will not actually fire every 1300 seconds.

It will instead have a 1% chance of firing every 13 seconds. It is unlikely, but can actually trigger twice in a row 13 seconds after the last time it triggered.

If you're looking for something precise as opposed to something that should fire 'roughly' 1 time per 'x' amount of time then there are two ways to go about it.

One of those is to have a 'wait' line at the end of the script and have it be numeric arg of 100.

The other way is to have numeric arg be 100 and increment the value of a variable every time it triggers, and then save the new value as a global, and only run the rest of the script when the variable equals a predetermined value.

An example of the second method would look like so:
Code:
Name: 'Room Global Random Example', VNum: [ 50], RNum: [ 50] Trigger Intended Assignment: Rooms Trigger Type: Global Random , Numeric Arg: 100, Arg list: None Commands: * By Rumble of The Builder Academy tbamud.com 9091 * Global makes this trigger fire whether a player is in the room or not. if !%i% set i 1 global i halt else if %i% < 100 eval i %i% + 1 global i halt else unset i end end switch %random.4% case 1 %echo% A shrill cry from a distant bird pierces the air. break case 2 %echo% The town bell rings in the distance. break case 3 %echo% Several doves coo overhead in the alcoves. break default %echo% Voices can be heard conversing in the distance. break done

Please Log in or Create an account to join the conversation.

Time to create page: 0.187 seconds