|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 03, 2008 1:08 am
Delay Command |
Is there a way I can make it so that while a certain condition is true (say a variable is set to "on") that all commands fed through the command line are delayed until a certain event happens in the MUD (namely a task that can't be interrupted occurs). Specifically, in our game, we have to stop crafting in order to do anything else. The problem is that crafting takes X amount of time, and if you do something it stops and you have to start again from the beginning. So say you mill a log, and milling the log takes 45 seconds. If 35 seconds through it you want to do something, when you mill the log, you'll have to go through the 45 seconds again. Now, there are specific lines that come from completion of milling the log. If I could somehow store up commands and "release" them upon these events, that would be neat.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Fri Oct 03, 2008 2:25 am |
yeah... use an #ONINPUT and disable/enable it via #T-/#T+ according to your variable
#ONINPUT "typedCommandDelay" {^(*)$} {#WAITFOR {craft timer end message};#EXEC {%params}}
Makes me wonder if you can have a #WAITFOR wait for a specific #EVENT to be #RAISEd |
|
_________________ Discord: Shalimarwildcat |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 03, 2008 2:58 am |
The oninput would capture everything typed but only when on?
|
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Fri Oct 03, 2008 3:14 am |
yep
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Fri Oct 03, 2008 4:22 am |
I can see a way that could be broken though: What if one of the things you queued up this way was another craft?
You'd have to build in some kind of safety feature that drops it if it is a craft command, or some kind of queue variable and a trigger for the craft timer message that would then start looping through the queue and firing stuff off, but will pause it again if another craft is initiated.
An example of this would be:
Code: |
#CLASS {CraftQueue}
#VARIABLE CraftQ {}
#ONINPUT "QueueInitiator" {^(*)$} {#VARIABLE CraftQ %additem(%-1,@CraftQ);#NOINPUT}
#TRIGGER {{Craft Start 1|Craft Stat 2|etc etc}} {#T- CraftQRun}
#TRIGGER {{Craft End1|Craft End2|etc etc}} {#T+ CraftQRun}
#CLASS {CraftQueue|CraftRun}
#ALARM CraftQAlarm {*2} {#EXEC %pop(@CraftQ)}
#CLASS 0 |
Which will fire your queued commands every 2 seconds. Goodluck.
PS. And of course while the queue is running out, you can enter commands normally and have instant gratification, including starting another craft that way and having it pause the queue. |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 03, 2008 5:07 am |
I imagined I would have to have some sort of capture trigger which stored the commands in a string list, which is why I'm curious as to how the oninput is supposed to work. Couldn't it do that for me? And, of course, if commands were in the cue then it could turn another variable on which fires when the event happens and causes the string list to be released and emptied.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Fri Oct 03, 2008 5:14 am |
ralgith's version does just that. in the @CraftQ variable
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 03, 2008 10:40 am |
Now that I'm reading it not tired, I see that . I'll try it out and report on it, thanks.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 03, 2008 2:03 pm |
Edit: Fixed, but some other problems:
Quote: |
drop 4 'hickory board' added to Queue
drop 4 'hickory board'
look added to Queue
look
get 'hickory log' added to Queue
get 'hickory log'
mill hickory added to Queue
|
I only want it to add items that I input myself, it, however, seems to want to add trigger input items as well.
I would also like for it to discriminate lines with certain things in them like "ok, say, king, etc...", and instead let those go through. But it can't be just ok, because these are channels that go to the MUD they have information following them, but speaking on channels doesn't halt the craft and thus shouldn't be queued.
Also, would it be wise to make a function for the releasing of the Queue and its clearing?
Edit2:
Code: |
i=1
#Loop q_index
{
#DELNITEM CraftQ @i
i=@i+1
}
#say CraftQ Dumped
|
Refuses to wipe my ClearQ variable! ugh |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Fri Oct 03, 2008 4:56 pm |
For commands to not be added to the queue you'd just need them in a list variable and check against the list. Forget the switch (which zMUD doesn't have :p this isn't C lol) and K.I.S.S. it.
examples:
make a talk list, and a dump list:
Code: |
#IF (%ismember(%1, @talk_list)) {
#EXEC {%params}
} {
#IF (%ismember(%1, @dump_list)) {
#NOINPUT
} {
my current triggers queuing code
}
} |
And of course that is just example code, don't expect it to work out of the box because it wont (as %1 in this case is the exact same as %-1 because you're capturing the whole line)
And why wouldn't triggered commands affect it? Its still sending it to the MUD just as if you had typed it yourself. Are you saying that every command that is triggered is one that wont cut your craft off? |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 03, 2008 5:52 pm |
The triggered commands are being used in my crafting, if it captures them they don't go through and my crafting doesn't go on. I'm a bit confused as to what you posted. It seems like the exceptions list, the problem is: How do I define an exception for a channel when it cannot know what I'm going to say in advance? It's my assumption that this trigger forces it to capture everything, making it hard to pick out parts. And there's no way to have it so that a trigger sends commands without it being like it was sent as if I had typed it?
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Oct 03, 2008 7:04 pm |
#SENDRAW
Also CMud seems to have finally implemented a difference between the predefined variables %lastin and %lastcom. You may be able to test on that to determine the source of the command. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 03, 2008 7:26 pm |
SENDRAW seems like it might work, I'll have to adjust my triggers to use it and make sure they all function properly with it. All I need now is way to get certain commands through it, and to make sure my dumping and clearing the string list will work. I made aliases for both clearing and dumping. The dumping alias works, but I cannot seem to get the clearing one to clear the variable. I suspect I have done something incorrect with the loop and that might be my problem.
Code: |
ID: clear_queue
i=1
#Loop q_index
{
#DELNITEM CraftQ @i
i=@i+1
}
#say CraftQ Dumped
q_index=0
ID: enter_queue
#FORALL @CraftQ {%i}
|
Thanks for the help, I'm sure I'll get this worked out with your help. The oninput trigger and such works, turns off and on appropriately, etc...
Code: |
ID: current board
Pattern: ^You begin to mill a (\w+) log.$
current_board=%1
#IF (@crafting_initial=1)
{
#IF (@crafting="off")
{
#say Crafting On
#SENDRAW crafting="on"
craftinginitial=0
}
}
{
#IF (@crafting="off")
{
#say You are not crafting.
#SENDRAW look
}
}
#T+ Crafting_Queue
Regular Expression
ID: destroyed log
Pattern: ^You destroyed the log.$
#IF (@crafting="on")
{
#SENDRAW look
#SENDRAW get '@current_board log'
#SENDRAW mill @current_board
}
{
#say you are not crafting.
}
#T- Crafting_Queue
ID: Crafting_Queue
Pattern: ^(*)$
#NOINPUT
#VAR CraftQ %additem(%-1,@CraftQ)
#say %-1 added to the Queue
q_index=@q_index+1
Type: Command Input
ID: Queue Off
Pattern: ^You stop milling.$
#T- Crafting_Queue
|
|
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Fri Oct 03, 2008 10:17 pm |
Like I said, the prior stuff wasn't to be taken at face value because it wouldn't work exactly as I put it. And if you just use sendraw in your triggers they skip the oninput as well.
If you give me a full channel list I'll give you the short version of it again with that in there.
Also you did too much in our aliases
Code: |
ID: clear_queue
#Loop %numitems(@CraftQ)
{
#DELNITEM CraftQ %i
}
#say CraftQ Dumped |
That eliminates all your extra variables. |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 03, 2008 10:25 pm |
Well, I'd like to make the channel exception myself, so I know how. I'm just wondering how I'm going to isolate the one part of any particular phrase that might need to be excepted through? Your %ismember thing confuses me, I'll read up on it since I feel that's probably what you're referring to.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Fri Oct 03, 2008 10:54 pm |
%ismember checks to see if an item is part of the given stringlist
you could always try %match as well
I would go with something like
#ONINPUT "QueueInitiator" {^(*)$} {
#NOINPUT
$acceptableCommandStarters="chat|guild|saw|say|etc"
#IF (%ismember(%word(%params, 1), $acceptableCommandStarters)) {#EXEC {%params}} {#VARIABLE CraftQ {%additem(%params,@CraftQ)}}
}
This will check the first word of your commands to see if they should be queued or not. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Fri Oct 03, 2008 11:24 pm |
Well, I mostly have it working.
Code: |
$acceptable="ok|king|say|\'|\>|ooc|auc|quest|tell|reply|gt"
|
It doesn't seem to like characters like ' and >, so I'm not sure what to do in order for those to be accepted. In addition,
Code: |
ID: clear_queue
#Loop %numitems(@CraftQ)
{
#DELNITEM CraftQ %i
}
#say CraftQ Dumped
q_index=0
|
Does delete some things but seems to have a hard time deleting everything which is a bit odd and causes problems. Other than that it seems to be working for the most part. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sat Oct 04, 2008 12:30 am |
thats because ' is not a word, this is where %match comes in handy
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sat Oct 04, 2008 1:22 am |
or more simply, change the #ONINPUT pattern to {^(%w*)$}
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sat Oct 04, 2008 2:42 am |
%match instead of %ismember?
|
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Sat Oct 04, 2008 3:04 am |
Well, in truth, the dump alias is only needed like that if you want to dump certain things. Otherwise if you just want to clear the variable have this as the only text in your alias:
#VAR CraftQ {} |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sat Oct 04, 2008 3:19 am |
not instead of, as well as
%match is basically like a trigger pattern
but the change i last posted makes %match unneeded |
|
_________________ Discord: Shalimarwildcat |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sat Oct 04, 2008 5:23 am |
shalimar wrote: |
not instead of, as well as
%match is basically like a trigger pattern
but the change i last posted makes %match unneeded |
What does your change do? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sat Oct 04, 2008 7:48 am |
my change of the #ONINPUT pattern makes it so that only commands that start with a word, as opposed to punctiation, get processed
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Sat Oct 04, 2008 12:33 pm |
But what if he wants to capture some punctuation, such as a period or an exclamation mark?
|
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
|
|