|
kjaerhus Magician
Joined: 18 Dec 2006 Posts: 317 Location: Denmark
|
Posted: Sat Aug 09, 2008 12:53 pm
[2.35] Signal problems |
I have some simple combat scripts that relies on signals to work. If I run one of the scripts by typing the name of the alias in the prompt it will work fine. However if I press a button which runs the alias the #WAITSIGNAL commands will not wait at all which I find is unexpected behavior and certainly annoying. The same goes for scripts called from the map. Code is below:
ALIAS: lightEdgedCombat (the alias I call from either command prompt or a button)
Code: |
#ECHO *** Light edged combat initiated ***
beginActivity
#WHILE (!@activityStopping()) {
attack "parry"
attack "feint"
attack "draw"
attack "slice"
attack "chop"
}
endActivity
#ECHO *** Light edged combat stopped ***
|
ALIAS: attack (parameter: $move)
Code: |
#IF (!@activityStopping()) {
#IF (@feintCombatEnabled && $move <> "parry" && $move <> "dodge" && $move <> "feint") {
#IF (@offhandCombatEnabled) {
rtCommand "feint "$move" left" ""
} {
rtCommand "feint "$move ""
}
} {
#IF (@offhandCombatEnabled && $move <> "parry" && $move <> "dodge") {
rtCommand ""$move" left" ""
} {
rtCommand ""$move ""
}
}
}
|
ALIAS: rtCommand (parameters: $command, $hideOption)
Code: |
#SECTION rtCommandSection {
$command = %exec($command) // In this situation %exec() just returns what it WOULD have sent
// Reset roundtime signal
#SIGNAL roundtime 0
// Execute command
#IF ($hideOption == "hide") {
#WINDOW Commands $command
#SENDRAW $command
} {
#SEND $command
}
}
#WAITSIGNAL roundtime
// Wait for another half second for safety
#WAIT 600
|
ALIAS: beginActivity
Code: |
//DragonRealms/Activities/Private/activityInProgress = true
//DragonRealms/Activities/Private/activityStopping = false
|
ALIAS: endActivity
Code: |
//DragonRealms/Activities/Private/activityInProgress = false
//DragonRealms/Activities/Private/activityStopping = true
|
FUNCTION: activityStopping
Code: |
#RETURN @//DragonRealms/Activities/Private/activityStopping
|
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Aug 11, 2008 5:23 pm |
In the button, try using the code:
Code: |
#THREAD BtnThread {lightEdgedCombat} |
to see if that makes it work. It's possible that the button code is running in the main UI thread and is not creating a background thread. Only background threads can pause and wait for signals. The command line has code to determine if a thread should be created or not, and triggers also have code for that, but I'm not sure about buttons. So let me know.
The mapper certainly won't create a thread because the mapper doesn't currently know about any of the fancy thread stuff in CMUD. Not until the mapper rewrite it finished. |
|
|
|
kjaerhus Magician
Joined: 18 Dec 2006 Posts: 317 Location: Denmark
|
Posted: Mon Aug 11, 2008 7:58 pm |
With the construction you suggest there nothing happens at all. However using #WAIT command is working fine. For the time being I use that for the map. It is however annoying because it's the same scripts you want to call whether it's from the commmand line, the map or the buttons.
|
|
|
|
kjaerhus Magician
Joined: 18 Dec 2006 Posts: 317 Location: Denmark
|
Posted: Sun Aug 17, 2008 6:10 pm |
Can I get feedback on whether this is something you consider a bug and intend to fix?
As a user I would certainly expect a script to behave the same whether I call it by typing it from the prompt or whether I call it from a button pressed. I cannot use signals right now as I need both ways to call scripts and would have to convert to #WAIT commands instead as they seem to work. However if you agree that it's a bug and say that it will be fixed in the near future I might choose to wait for it.
...you feel your eyelids getting heavier and heavier. When you wake up all you want to do is to fix the bug, fix the bug, fix the bug... |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Aug 18, 2008 4:59 pm |
This is on my list to look at, but I have not had time to try and reproduce it yet. It sounds like a bug, but it's obscure enough that it's not going to take priority over the mapper stuff that I am currently working on, sorry.
|
|
|
|
kjaerhus Magician
Joined: 18 Dec 2006 Posts: 317 Location: Denmark
|
Posted: Mon Aug 18, 2008 5:41 pm |
Well, the mapper has the same problem so fine with me.
Not sure why it's obscure though. I don't suppose I'm the only one running scripts from buttons... |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Aug 18, 2008 7:22 pm |
It's obscure because very few people are using #WAITSIGNAL. Signals (and other threading commands) are considered extremely advanced and are used by only a small number of people. Combine that with doing it from a button and you've got something obscure.
|
|
|
|
kjaerhus Magician
Joined: 18 Dec 2006 Posts: 317 Location: Denmark
|
Posted: Mon Aug 18, 2008 8:18 pm |
Fair enough.
|
|
|
|
Arde Enchanter
Joined: 09 Sep 2007 Posts: 605
|
Posted: Wed Aug 20, 2008 5:59 pm |
I can confirm the problem with buttons. CMUD silently skips line with the #THREAD command. Sadly, putting #THREAD in an alias also not help - button script calls that alias normally, but then again skip thread launching command.
Test settings:
Code: |
<button type="Toggle" autosize="false" width="200" height="25" transparent="false" color="white" priority="6480" id="1">
<caption>Thread: STOPPED</caption>
<value>//Set thread' Stop Flag to 0
Stop = 0
//Launch thread
#THREAD "TestThread" {wThread}
//Show threads running
#THREAD</value>
<state caption="Thread is running" color="lime">//Set thread' Stop Flag to 1
Stop = 1</state>
</button>
<class name="TestThread" initenable="true" id="3">
<notes>All the threading stuff</notes>
<alias name="wThread" id="4">
<value>#WHILE (@Stop == 0)
{
#PRINT "No job to do, wait 500 msec. Type ""Stop=1"" to stop this thread"
#WAIT 500
}</value>
<notes>Working thread</notes>
</alias>
<var name="Stop" type="Integer" usedef="true" id="6">
<value>1</value>
<default>0</default>
<notes>=1 if the tread must exit now</notes>
</var>
</class> |
Usage:
At command line:
-To run a thread, type "Stop=0;#THREAD "TestThread" {wThread}"
-To stop running thread, type "Stop=1"
With use ofbutton:
-To run a thread press the button - it has the same "Stop=0;#THREAD "TestThread" {wThread}" script (will not work)
Interestingly, I've add the #THREAD command to button script and it shows "No threads running." message. It not sees even the main thread. |
|
|
|
|
|