[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Half second timers

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Half second timers
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1  2 3  

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 24 Dec 2004 03:55 AM (UTC)  quote  ]
Message
Quote:

I need a timer that A. waits 1.5 seconds before sending something to the world ...


Version 3.61 onwards now implements sub-second timers.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 15 May 2001 09:54 AM (UTC)  quote  ]
Message
The prototype for AddAlias is:

long AddAlias(BSTR AliasName, BSTR MatchText, BSTR ResponseText, long Flags, BSTR ScriptName);

You have specified:

World.addalias "Kaioken", "kk", "", "", 1+32, "OnKaioken"

You have supplied 6 arguments whereas AddAlias takes 5. That is your problem.





- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David   USA  (49 posts)  [Biography] bio
Date Tue 15 May 2001 07:07 AM (UTC)  quote  ]
Message
Ok, again, I wasted time with posting, I ended up using elseif statement



It works, but I can not seem to get an alias added from within the script

This is what I am doing, it is giving me an errorsub OnRace (Triggername, triggerline, arrWildCards)
world.SetVariable "Race", arrWildCards (1)
dim flag
flag = world.getvariable ("Race")
if flag = "saiyan" then
world.setvariable "Race", arrWildCards (1)
world.send arrWildCards (1)
world.note "Your have selected: " + world.getvariable ("Race")
world.deletealias "RaceSelection"
world.setVariable "Kaioken", "off"
World.addalias "Kaioken", "kk", "", "", 1+32, "OnKaioken"
elseif flag= "human" then
elseif flag= "namek" then
elseif flag= "android" then
else
world.note "That is an invalid Race selection, Please check spelling and capitalization (hint, Don't capitilize your race)"
end if
end sub

Anyways,
This part isn't working, Why?

World.addalias "Kaioken", "kk", "", "", 1+32, "OnKaioken"



My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
[Go to top] top

Posted by David   USA  (49 posts)  [Biography] bio
Date Tue 15 May 2001 05:03 AM (UTC)  quote  ]
Message
Okies.

When your creating a new character, I want to set a varible for the race that you select

Let me show you the code that I am trying to do, maybe you will know what I am doing wrong

sub OnRace (Triggername, triggerline, arrWildCards)
world.setvariable "Race", arrWildCards (1)

dim flag

flag = world.getvariable ("Race")

if flag = "saiyan|human|namek|android" then
world.setvariable "Race", arrWildCards (1)
world.send arrWildCards (1)
else
world.note "That is an invalid Race selection, Please check spelling and capitalization (hint, Don't capitilize your race)"
end if
end sub

I guess the question is I need the race to be case sensitive The only way I can see how to do this is at character creation

How do I create an "or" statement in the script.

if flag = "any of these possibilities" then
do this
else
world.note "Try again type this"
end if


My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 11 May 2001 02:14 AM (UTC)  quote  ]

Amended on Fri 11 May 2001 02:15 AM (UTC) by Nick Gammon

Message
Quote:

Ok the first trigger is activated it-> runs a script to make a new trigger, and timer->Runs a "sub subroutine"(I.E. AutoCombo)-> The second Trigger comes-> Runs a differnet subroutine(IE autocombo)-> third trigger comes, Runs the same as the second


You confuse me a bit by talking about two subroutines both called Autocombo (as VB is not case-sensitive) however, you can probably achieve what you are doing by having a flag which you test in the trigger.

Something like this:


sub OnTrigger (Triggername, triggerline, arrWildCards) 
dim flag

flag = world.getvariable ("flag")

if flag = "b" then
'  ..... do something here (action B) .....
else
'  ..... do something different here (action A) .....
  world.setvariable "flag", "b"
  world.AddTimer ("blahblah", 0, 0, 5, "", 1029, "On_Fix_Trigger");
end if
end sub

sub On_Fix_Trigger (strTimerName)
  world.setvariable "flag", "a"  
end sub



What you have here is a single trigger that does action A or action B depending on the flag. Initially the flag will be "a" (or empty) so action A is done. In this case we set the flag to "b" so the action B is done next time around, and set up a 5-second timer to change the flag back at the end of the 5 seconds.

The other sub is called by the timer to switch the flag back.





- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 11 May 2001 02:03 AM (UTC)  quote  ]
Message
Quote:

I got the lbound, and the ubound part fine

What if i wanted to access something in the middle?
Is that possible to do?


Well, if ubound is 6 then the middle would be 3.

eg.


blah = split ("rth slgjbgr gohu onaeog setgofnr")
world.note blah (ubound (blah) / 2)


This would show the word half-way through that list of words.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David   USA  (49 posts)  [Biography] bio
Date Thu 10 May 2001 09:27 AM (UTC)  quote  ]
Message
I knew there was a more simple way to do it...

Thanks.

A small side question however

Lets say I got a random set of charcter strings

rth slgjbgr gohu onaeog setgofnr

Ok random set of character strings..

I got the lbound, and the ubound part fine

What if i wanted to access something in the middle?
Is that possible to do?

How would you do so?

Also. another side thought.
I have this Trigger. I want it to run a script... Lets jsut say Autocombo for instance. However once it runs through the combo i get another Combination! ( * ) trigger, but the second Combination! ( * ) that I get, I want the script to act differently.

Is there a way to make the script create a new trigger, and timer to re-enable the old trigger, then run a different subroutine, from within the scrpt, to do something else, then go back to the original script?
____________________________________________________________
Ok this is a better way to put it I think. Its a map of what this thing is suposed to do
____________________________________________________________
Ok the first trigger is activated it-> runs a script to make a new trigger, and timer->Runs a "sub subroutine"(I.E. AutoCombo)-> The second Trigger comes-> Runs a differnet subroutine(IE autocombo)-> third trigger comes, Runs the same as the second-> the timer expires and changes the 2nd, and 3rd trigger, back to the first trigger, and completes the rest of the first script.

This is kinda confusing I am sure, but I think if you look at it, it does make sense in a wierd way

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Thu 10 May 2001 05:05 AM (UTC)  quote  ]
Message
Ah, I see what you are doing now. :)

It is simpler than what you are doing. You don't need a loop just to get the last word in the list. Do this:


sub OnAttacker (Triggername, triggerline, arrWildCards) 
Dim Sense 
 Sense = split (arrWildCards (1)) 
 world.SetVariable "Attacker", sense (ubound (sense)) 
End Sub 



The split will give you one or more words.

"Ubound (sense)" gives you the offset of the last word.

"sense (ubound (sense))" gives you the last word itself.






- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David   USA  (49 posts)  [Biography] bio
Date Thu 10 May 2001 04:01 AM (UTC)  quote  ]
Message
Throw Android 17 down
That doesn't work

Throw "android 17" down
That doesn't work

It has to be a single word

throw android down
throw 17 down

This is what I am currently using to change my varible "attacker" to something that works

sub OnAttacker (Triggername, triggerline, arrWildCards)
Dim Sense
Sense = split (arrWildCards (1))
Dim i
for i=lbound (Sense ) to ubound (sense )
world.SetVariable "Attacker", sense (i)
next
End Sub

What I want to do is change this into seomthing like what we did with throw as the last command in the combo


Instead of setting 2 variables
the first being Android
and the second Being 17

I want it to ignore android and go straight to 17


My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 09 May 2001 04:01 AM (UTC)  quote  ]
Message
I'm not sure why you need to go to this trouble. If the variable contains "Android 17" and you want to send:


throw Android 17 down


... then it will work without further modification. It isn't clear if the problem is getting "Android 17" into a single variable, or what.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David   USA  (49 posts)  [Biography] bio
Date Wed 09 May 2001 02:11 AM (UTC)  quote  ]
Message
Hrm... I tried using the "" or the '' but this is a completely custom mud, it is not based on ANY MUD that I know of. it did not work

Its not ROM its not SMAUG, its not CIRCLE, its coded from scratch

I don't think there is the "" '' in it.

I got the code to do what i want, It splits the names into array's and uses the last one as the variable

What I want to do is make it a little tighter, instead of setting a varible for the first name "King", then "walking" to the next Array "Cold" and setting that variable as well.

I would prefere it to ignore all but the last array

and use that as the variable.

The split works, I just want to make it less cpu intensive... setting one varible instead of cycling through the names in the array's and setting multiple variables

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 08 May 2001 09:58 PM (UTC)  quote  ]
Message
This seems strangely complicated to me.

First, what do you type into the MUD when you see a two-named monster?

throw Android 17 down?
throw 'Android 17' down?
throw "Android 17" down?

Knowing this will help answer the question.

Also, looking back through the messages in this section it isn't obvious how the monster name gets into the variable in the first place. How do you put it there? Through an alias?



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David   USA  (49 posts)  [Biography] bio
Date Tue 08 May 2001 07:16 AM (UTC)  quote  ]
Message
Sorry, Yes it works beautifully. However I need to do something else now...


There are mob names that are more than one string of characters.

For instance, if i am fighting a playe(only one word names)
I.E. Bob, Blastoid, etc...

However, Some mobs have multi-names

King Cold, Frieza's Henchman, Android 17, Android 18, etc...

The throw command has a variable in it.

throw <target> down, or Throw <target> West

This code:

world.send "throw " + world.GetVeriable ("Attacker") + " Down"

Works perfect for characters or mobs that have a single name. I.E. Saibaman, Or any PC name.

It does not work on multi-named mobs.

My question is, Using the split command how wuld I use it to set variables using the second array

sub UnNamed (TriggerName, Triggerline, arrWildCards)
Dim UnNamed
UnNamed= split (arrWildCards (1))
Dim i
for i=lbound (UnNamed ) to ubound (UnNamed )
world.SetVariable "UnNamed" + UnNamed (i)
next
end sub

I think this how I might do it.
This will give me the result I think I want, but it will be kinda sloppy in My opinion.
reason being, it will be continuesly setting multiple variables, potentially hogging CPU speed(although it will prolly be next to nothing)

I would like to tighten it up. so that it will only set the ubound (UnNamed ) as the variable, and ignores the ibound (UnNamed )

I thought about uusing the if, command

if i= ubound (UnNamed ) then
world.setvariable "UnNamed" + UnNamed (i)
end if
next
end sub

I don't think thats right, could you please correct me if I am wrong

Thanks again
Dave

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 01 May 2001 09:46 PM (UTC)  quote  ]
Message
You took out my suggested test for a blank attack (in an earlier post) but yes, that looks about right.

Doesn't it work?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David   USA  (49 posts)  [Biography] bio
Date Tue 01 May 2001 09:21 PM (UTC)  quote  ]
Message

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo ) 
  Select Case AutoCombo (i) 
    case "rp" attack = "punch right"
    case "lp" attack = "punch left"
    case "s" attack = "sweep"
    case "r" attack = "roundhouse"
    case else attack = ""  ' unknown attack type
  End Select          
  if i = ubound (AutoCombo ) then
    world.send "throw " + world.getvariable ("attacker") + " down" 
  else
    world.send attack + " " + world.GetVariable ("attacker")
  end if
next
end sub



Does this look right to you?

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


7,306 views.

This is page 2, subject is 3 pages long:  [Previous page]  1  2 3  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]