[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]  Jscript
. . -> [Subject]  trigger to assign variable name

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: trigger to assign variable name
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)

Posted by Kingjames_IV   (10 posts)  [Biography] bio
Date Sat 22 Feb 2003 05:51 PM (UTC)  quote  ]
Message
thanks a lot, works perfectly now.
[Go to top] top

Posted by Kingjames_IV   (10 posts)  [Biography] bio
Date Sat 22 Feb 2003 08:37 AM (UTC)  quote  ]
Message
ah ok think i got it now, wasn't putting 3 parameters in my declaration of my function.

And i know sending it to the mud is useless and stupid but i was just using that to test if the script was reading the wildcard, thats not at all what i'm planning to do with it.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 21 Feb 2003 09:09 PM (UTC)  quote  ]
Message
VB arrays cannot be directly used in Jscript. The example script files that ship with MUSHclient show what you need to do. Here is an example, from what Shadowfyr was describing, but coded so it will work in Jscript:


function SaveBadGuy (name, output, wildcardsVB)
{

var wildcards;

  wildcards = VBArray(wildcardsVB).toArray();	

  world.note (wildcards [0]);

}

- Nick Gammon

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

Posted by Shadowfyr   USA  (1,774 posts)  [Biography] bio
Date Fri 21 Feb 2003 05:59 PM (UTC)  quote  ]
Message
It would help to see the 'exact' script you are trying to use. Sounds like you are incorrectly defining something in the script and it is complaining because the array 'wildcards' doesn't actually exist. Without showing us the exact code you are trying to use, we are flying blind here.

However I suspect you are doing something a bit silly. The procedure you call needs to be like:
function SaveBadGuy (name, output, wildcards)
  {
    world.send(wildcards(1));
  }

If you defined the routine this way, then I haven't a clue why it doesn't work. One thing to note though is that the names: name, output and wildcards are 'your' names, not ones that the script engine or mushclient automatically uses. For all anyone knows mushclient thinks they are xyzzy, ziggy and glug. You have to make sure that the number of them are the same as what mushclient expects and it helps to have them be something you understand, but they can be anything you want. In your case 'if' you defined the script like above, then it should have worked as expected.

Note however that since sending the contents of the wildcard 'to' the mud is quite silly, you probably should have used 'world.note(wildcards(1));', which displays it in output, but doesn't try to send it to the mud itself.

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();}
[Go to top] top

Posted by Kingjames_IV   (10 posts)  [Biography] bio
Date Thu 20 Feb 2003 09:56 PM (UTC)  quote  ]
Message
i tried using wildcards(1) in a script and it keeps giving me an error saying object expected. How exactly do you use it? i tried using it in world.send(wildcards(1)); and i got an error tried a few other ways and still no good.
[Go to top] top

Posted by Shadowfyr   USA  (1,774 posts)  [Biography] bio
Date Sun 16 Feb 2003 07:53 PM (UTC)  quote  ]
Message
Aiases and triggers both pass predefined parameters. The are:

(name, output, wildcards)

name - The alias or trigger that called this script.
output - The entire original text that was matched.
wildcards - The information passed as other parameters.

Thus for instance with the trigger example earlier in the thread, if it was used to call a script instead:

Trigger: You poke *
Enabled, Keep Evaluating
Label: badGuy
Script: SaveBadGuy

name = badGuy
output = You poke Fred
wildcards(1) = Fred
wildcards(2)-(9) = Empty

An alias would produce identical results. Basically the parameters are automatically generated and passed based on how many things you told it to pass using * in normal ones or () around the item to be passed in regular expressions. This means of course that in regexp you can match a trigger (or while silly and alias) on an unknown word and actually have the script ignore it as a parameter. i.e. like - 'A (.*) .* into the room', where the second .* could be squishes, hops, wanders or anything else. The sub would only be passed the one in between ( and ). ;)

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();}
[Go to top] top

Posted by Kingjames_IV   (10 posts)  [Biography] bio
Date Sun 16 Feb 2003 04:18 AM (UTC)  quote  ]
Message
I know i can call an alias to run a script but is there a way to pass a parameter to scripts? I tried similar to java programming putting it in the declaration of the function ( eg. script(str String) ) but thats no good.
[Go to top] top

Posted by Demonsurfer   USA  (256 posts)  [Biography] bio
Date Fri 14 Feb 2003 09:00 PM (UTC)  quote  ]

Amended on Sat 15 Feb 2003 08:58 PM (UTC) by Demonsurfer

Message
Yeah you can by getting the alias to call a script to set the variable, but if you hang on a bit, the next version of MUCHclient will apparently have aliases set up like triggers are at the moment, so you can send direct to the variable.

From what Nick has indicated in recent threads (December/January), it should hopefully be released very very soon (mid Feb?). I've been checking the site like every 2 hours for the last couple of days to see if the new vers is out yet heh.. keen as.



[Go to top] top

Posted by Kingjames_IV   (10 posts)  [Biography] bio
Date Fri 14 Feb 2003 07:49 PM (UTC)  quote  ]
Message
Is there also a way to do this with an alias? Went to do it and it would be much more useful to me as an alias rather than a trigger.
[Go to top] top

Posted by Kingjames_IV   (10 posts)  [Biography] bio
Date Fri 14 Feb 2003 07:18 PM (UTC)  quote  ]
Message
oops missed the one line in that post, you did understand, thanks i'll try that.
[Go to top] top

Posted by Kingjames_IV   (10 posts)  [Biography] bio
Date Fri 14 Feb 2003 07:17 PM (UTC)  quote  ]
Message
your misunderstanding, i can already do that. What i want is for the trigger to change a variable to XXX or to send XXX to a script that will change the variable, i can already send XXX to the world.
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Fri 14 Feb 2003 11:01 AM (UTC)  quote  ]
Message
You don't need scripting for that:
Trigger: You poke *
Send: %1
Enabled, Keep Evaluating
Send to: Variable (label is name)
Label: badGuy

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Kingjames_IV   (10 posts)  [Biography] bio
Date Thu 13 Feb 2003 10:29 PM (UTC)  quote  ]
Message
ok i've been trying to figure it out but i must be missing something. I want to make a trigger/script that will for instance react to 'you poke XXX' and change the variable badGuy to be XXX. I've managed to make a trigger that will send XXX to the world and a script that will change variables but can't get the trigger to send XXX to the script. I use Jscript and can't figure out how to get it to let me pass a parameter to a function.
[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.


3,971 views.

[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]