Welcome to the Builder Academy

Question eval, HELP EVAL, HELP ARRAY and Trigger 1325

More
22 Jun 2013 14:07 - 22 Jun 2013 17:46 #3207 by krell
After an enlightening discussion about the misuse and proper use of eval in triggers with Fizban the other day, I decided to take a look at one of the triggers listed as an example in HELP ARRAY; trigger 1325. I attached it to a mob on my locally running copy of tba and the mob reacted, but spat out variable names instead of their string values. I've modified the script so that it not only works, but (hopefully) is technically correct.

BTW, HELP EVAL is way too sparse and does not meet the quality of the online help files I've come to expect from tbaMUD. In case anybody wishes to tackle that issue. :-)

Code:
* By Jamie Nelson set w1max %random.20% set w2max %random.20% set w3max %random.20% set w4max %random.20% set w5max %random.11% set w6max %random.20% set w1[0] phenomenal set w1[1] rapid set w1[2] chilling set w1[3] insipid set w1[4] nauseating set w1[5] astronomical set w1[6] austere set w1[7] inevitable set w1[8] inescapable set w1[9] reckless set w1[10] haphazard set w1[11] accelerating set w1[12] profound set w1[13] awesome set w1[14] terrifying set w1[15] ubiquitous set w1[16] ignominious set w1[17] unprecedented set w1[18] unparalleled set w1[19] insidious set w1[20] broad set w2[0] growth set w2[1] decline set w2[2] prospects set w2[3] acceleration set w2[4] threat set w2[5] expansion set w2[6] oneness set w2[7] outgrowtset w2[8] madness set w2[9] evacuation set w2[10] diminishment set w2[11] consumption set w2[12] decay set w2[13] putrefaction set w2[14] vapidity set w2[15] downsizing set w2[16] degeneration set w2[17] litigation set w2[18] declivity set w2[19] hastening set w2[20] paradigm shifting set w3[0] the Internet set w3[1] urban tax dollars set w3[2] new technologies set w3[3] gender identification disorders set w3[4] censorship set w3[5] interpersonal communications set w3[6] modern life set w3[7] rampant paradigm shifts set w3[8] consumer spending set w3[9] rain forests set w3[10] human literacy set w3[11] natural resources set w3[12] traditional values set w3[13] media junk food set w3[14] family values set w3[15] corporate mentality set w3[16] the American justice system set w3[17] technological change set w3[18] the ozone layer set w3[19] human resources set w3[20] current epistemologies set w4[0] forever dissipate set w4[1] escalate set w4[2] aggrandize set w4[3] overhaul set w4[4] deteriorate set w4[5] revolutionize set w4[6] uglify set w4[7] put an end to set w4[8] enslave set w4[9] bankrupt set w4[10] truncate set w4[11] nullify set w4[12] sabotage set w4[13] destabilize set w4[14] incapacitate set w4[15] hasten set w4[16] dehumanize set w4[17] evaporate set w4[18] indenture set w4[19] intensify set w4[20] undermine set w5[0] today's set w5[1] tomorrow's set w5[2] the entrenchment of our set w5[3] worldwide set w5[4] our children's set w5[5] modern set w5[6] all of our set w5[7] our future set w5[8] our set w5[9] the demise of our set w5[10] our grandchildren's set w5[11] all hope for set w6[0] business models set w6[1] re-ruralization set w6[2] human condition set w6[3] family values set w6[4] self-esteem set w6[5] medical insights set w6[6] human psyche set w6[7] human depth set w6[8] egalitarianism set w6[9] World Wide Web set w6[10] future values set w6[11] hopes and dreams set w6[12] business models set w6[13] political climate set w6[14] education set w6[15] cultural heritage set w6[16] lifestyles set w6[17] fiduciary responsibility set w6[18] genetic diversity set w6[19] intestinal fortitude set w6[20] computer literacy eval w1 %%w1[%w1max%]%% set msg The %w1% eval w2 %%w2[%w2max%]%% set msg %msg% %w2% of eval w3 %%w3[%w3max%]%% set msg %msg% %w3% eval w4 %%w4[%w4max%]%% set msg %msg% will %w4% eval w5 %%w5[%w5max%]%% set msg %msg% %w5% eval w6 %%w6[%w6max%]%% set msg %msg% %w6% say %msg%



P.S. Don't you hate it when you have the wrong window open and you copy+paste that text into your post? Yeah, me too.
Last edit: 22 Jun 2013 17:46 by krell. Reason: minor cleanup

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

More
22 Jun 2013 15:18 - 22 Jun 2013 15:19 #3208 by Rumble
Trig 1325 works fine for me.

Looks like the example helpfile took precedent over the true eval help file. HELP EVAL should return:

EVALUATE TRIG-EVALS EVALS

Usage: eval <variable> <expression>

* this example immediately evaluates the expression below and stores the result
* in %result%
eval result %self.hitp% * 100 / %self.maxhitp%
say My hitpoint percentage is %result%
* this result will not change after the evaluation even if %self.hitp% changes.

The eval command is used to set (or create) the specified variable equal to
the result of the immediate evaluation of the provided expression. There also
exists a "set" command, with the same syntax. Set differs in that the expression
is not evaluated until the variable is accessed.

Example: TSTAT 49

See also: TRIG-SET, EVAL-EXAMPLES


Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com
Last edit: 22 Jun 2013 15:19 by Rumble.

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

More
22 Jun 2013 16:14 - 22 Jun 2013 17:47 #3209 by krell

Rumble wrote: Trig 1325 works fine for me.


It's possible I did something to the script that I don't remember. I was looking at it rather late last night.

Looks like the example helpfile took precedent over the true eval help file. HELP EVAL should return:


My confidence in tba's quality is restored. :-)

Anyhow, I think it's been established that T1325 works as is and that there is a good helpfile on eval.
Last edit: 22 Jun 2013 17:47 by krell. Reason: deleted a bunch of extra nonsense on my part

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

More
22 Jun 2013 22:16 - 22 Jun 2013 22:18 #3213 by Fizban
Help Eval-Examples could definitely use work though.

Its single example is so obvious that it's essentially useless.

IMO better examples would be things like this:

Good: set num %random.3%
Bad: eval num %random.3%
Good: set numcheck %findmob.5000(%mobvnum%)%
Bad: eval numcheck %findmob.5000(%mobvnum%)%
Good: eval numcheck %%findmob.%self.vnum%(%mobvnum%)%%
Bad: set numcheck %%findmob.%self.vnum%(%mobvnum%)%%
Good: eval product 3 * 4
Bad: set product 3 * 4

I see people do this a lot:

eval num %random.5%

I however never see this, which is what the helpfile currently shows:

eval fruit apple

The latter is so obviously wrong that most people know it without looking at the helpfile, but a lot of people think eval is needed for the former.
Last edit: 22 Jun 2013 22:18 by Fizban.

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

More
23 Jun 2013 02:30 #3216 by Rumble
Thanks, helpfile updated.

Rumble
The Builder Academy
tbamud.com 9091
rumble@tbamud.com
The following user(s) said Thank You: krell

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

Time to create page: 0.273 seconds