Code:
Name: 'Eval and Set Example', VNum: [ 49], RNum: [ 49]
Trigger Intended Assignment: Rooms
Trigger Type: Speech , Numeric Arg: 100, Arg list: test
Commands:
* By Rumble of The Builder Academy builderacademy.net 9091
* This is a speech trig @RHELP TRIGEDIT ROOM SPEECH@n, say 'test' to activate.
* There is much confusion about the difference between set and eval. So this is
* the simplest way I can think of to explain it (assume %actor.level% = 34):
*
* Set stores the variable and will not process it until called.
* In the example below %set_variable% will contain '34 + 1'
set set_variable %actor.level% + 1
%echo% Set Variable: %set_variable%
*
* Eval immediately evaluates the variable.
* In the example below %eval_variable% will contain '35'
eval eval_variable %actor.level% + 1
%echo% Eval Variable: %eval_variable%
*
%echo% Level: %actor.level%
This trig outputs:
You say, 'test'
Set Variable: 34 + 1
Eval Variable: 35
Level: 34
Or as Mordecai said:
When you want to preserve the layout of a string, you can use set.
When you want to evaluate a string into a result, you can use eval.
If this was helpful please
vote
or leave a
review
for TBA.