![](templates/Classic/images/spacer.gif) |
hpoonis2010 Adept
![](images/avatars/1873888255ff6db71d8987.jpg)
Joined: 18 Jun 2019 Posts: 279
|
Posted: Wed Mar 16, 2022 10:03 am
THREAD |
I am a bit vague on this topic, so if anyone can clear things up a little...
Eg., The following checks the potion vars. I have some potion actions on buttons. I have noticed that sometimes when I click the button, the action is performed but the variable doesn't decrement. Thus, I made the following:
Code: |
#IF (%lower(%gmcp.char.status.pos)="fighting") {
qhp
#WAIT 400
qmn
#WAIT 400
qmv
}
|
Simply put, if I do this:-
Code: |
#THREAD checkpots
#IF (%lower(%gmcp.char.status.pos)="fighting") {
qhp
#WAIT 400
qmn
#WAIT 400
qmv
} |
Will this initiate a new thread (checkpots) which runs ALL of the actions within that thread? qhp, qmn, qmv are all aliases. Will these called scripts also be constrained to the checkpots thread?
Furthermore, if I use(eg.):
I could run these in their own thread and thus perform #WAITSIG tests? |
|
|
![](templates/Classic/images/spacer.gif) |
shalimar GURU
![](images/avatars/114658559147aeed8fee539.gif)
Joined: 04 Aug 2002 Posts: 4685 Location: Pensacola, FL, USA
|
Posted: Wed Mar 16, 2022 5:50 pm |
I believe you have to contain it all within {} if you want it to count as the named thread.
Supposedly just doing #WAIT 0 will shove the body of the setting in question into its own anonymous #THREAD.
I never got into all the capabilities of using #THREADs though, so you will have to experiment. |
|
_________________ Discord: Shalimarwildcat |
|
|
![](templates/Classic/images/spacer.gif) |
shalimar GURU
![](images/avatars/114658559147aeed8fee539.gif)
Joined: 04 Aug 2002 Posts: 4685 Location: Pensacola, FL, USA
|
Posted: Thu Mar 17, 2022 4:29 am |
Oh, I bet this is just the display bug of referencing a dbvar. The value will be accurate even if it still displays the old value.
For some reason variables used in the caption only update if they are stand-alone.
Disabling and enabling the button -should- update the display value, if that is indeed the issue. |
|
_________________ Discord: Shalimarwildcat |
|
|
![](templates/Classic/images/spacer.gif) |
hpoonis2010 Adept
![](images/avatars/1873888255ff6db71d8987.jpg)
Joined: 18 Jun 2019 Posts: 279
|
Posted: Thu Mar 17, 2022 9:07 pm |
I'll have to try the the thread thing again in {}. I did do this previously for a script but, whether it was the brackets or some other factor, the script didn't run at all.
For the most part (aside from the slight glitch) the variables do count down, especially out of combat as there is less spam from the mud.
The variables for these buttons are one-value vars: numHP, numMN, numMV. When I buy potions, a trigger script lifts any of the same potions out of a bag and, when they all go back in, the value is sent to num$pot ($pot=hp/mn/mv).
Currentpotions is populated when I shop for potions. Depending on char level, better potions are dropped into currentPotions: for hp, mn, mv, sanc, fly, etc. matched with a store to buy them in. Eg., for hit points: hp="level=60|keyword=duff|shop=23160". |
|
|
![](templates/Classic/images/spacer.gif) |
hpoonis2010 Adept
![](images/avatars/1873888255ff6db71d8987.jpg)
Joined: 18 Jun 2019 Posts: 279
|
Posted: Sat Mar 19, 2022 6:09 am |
Hmmm...I am not sure that THREAD{}does anything, or, if it does, there must be constraints which are undocumented. Thus, we have no real idea how to work these commands. It's a shame as I am sure it would increase the efficiency of the client/mud relationship.
|
|
|
![](templates/Classic/images/spacer.gif) |
shalimar GURU
![](images/avatars/114658559147aeed8fee539.gif)
Joined: 04 Aug 2002 Posts: 4685 Location: Pensacola, FL, USA
|
Posted: Sat Mar 19, 2022 3:59 pm |
Honestly, I'm not sure that there is anything complex enough to require threading on a daily basis.
It is mostly used to shunt code that would otherwise cause CMUD to freeze up as it processes, like a complex %mapquerry.
That way your other settings can still process incoming text from the server.
That was also one of the issues with #WAIT in zMUD, no other settings would process for the length of the wait, which I assume is why any use of the #WAIT command now pushes things into an anonymous thread.
CMUD has many ways to accomplish most tasks.
I am partial to using #EVENTs over #ALIASes anymore, if only because a disabled #EVENT won't send a nonsense command to the game in the aliasname. |
|
_________________ Discord: Shalimarwildcat |
|
|
![](templates/Classic/images/spacer.gif) |
hpoonis2010 Adept
![](images/avatars/1873888255ff6db71d8987.jpg)
Joined: 18 Jun 2019 Posts: 279
|
Posted: Mon Apr 11, 2022 10:05 am |
How do you define your threads? I have been testing #TH and have found that, in many cases, the scripts do not execute, but some do. I have tried using the following variations:
If I have a trigger/alias:
Eg., #ALIAS fred {code}
I have used:
#ALIAS fred {#TH "thread" {code}}
#ALIAS fred {#TH thread {code}}
#ALIAS fred{#TH code} |
|
|
![](templates/Classic/images/spacer.gif) |
shalimar GURU
![](images/avatars/114658559147aeed8fee539.gif)
Joined: 04 Aug 2002 Posts: 4685 Location: Pensacola, FL, USA
|
Posted: Mon Apr 11, 2022 6:21 pm |
The first example is the one cited in #HELP #THREAD.
Have you found a given script that reliably fails using that syntax? |
|
_________________ Discord: Shalimarwildcat |
|
|
![](templates/Classic/images/spacer.gif) |
hpoonis2010 Adept
![](images/avatars/1873888255ff6db71d8987.jpg)
Joined: 18 Jun 2019 Posts: 279
|
Posted: Wed Apr 13, 2022 4:27 am |
Aye.
Code: |
#LOCAL $search
#LOCAL $tempFindItem
#LOCAL $tempFindRec
#LOCAL $minlev
#LOCAL $maxlev
$potMnemonic=%1
#SWITCH (%numparam())
(1) {$minlev=1;$maxlev=@eqCharLevel}
(2) {$minlev=%2;$maxlev=@eqCharLevel}
(3) {$minlev=%2;$maxlev=%3}
$potKeys=%dbkeys(@potion)
#SWITCH ($potMnemonic)
("arm") {$search="armor"}
("bls") {$search="bless"}
("fly") {$search="fly|levitate"}
("hp") {$search="cure light|serious|critical|heal"}
("invis") {$search="invis"}
("mn") {$search="lotus"}
("mv") {$search="refresh"}
("sanc") {$search="sanctuary"}
("str") {$search="strength"}
#WIN EQ "***** Potion: "$search" Level:"$minlev"-"$maxlev" *****"
//#THREAD "potFind" {
#FORALL $potKeys {
$item=@potion.%i
#FORALL $search {
#IF ((%pos(%j,$item.spells)) AND ($item.level>=$minlev) AND ($item.level<=$maxlev) AND (%item.weight<=2)) {
#WIN EQ "Lev:"$item.level" Room:"%roomkey($item.room)" Zone:"%zonename(%roomzone(%roomkey($item.room)))" Keywords:"$item.keywords
}
}
}
//} |
Which fails to run the code inside the thread block. I REM'd it out after if fails to run.
But...
happily runs. |
|
|
![](templates/Classic/images/spacer.gif) |
shalimar GURU
![](images/avatars/114658559147aeed8fee539.gif)
Joined: 04 Aug 2002 Posts: 4685 Location: Pensacola, FL, USA
|
Posted: Wed Apr 13, 2022 2:39 pm |
Does the failed script work outside of a thread?
I would imagine there is something getting misinterpreted with all those quote marks. |
|
_________________ Discord: Shalimarwildcat |
|
|
![](templates/Classic/images/spacer.gif) |
|
|