Gammon Forum
Entire forum
MUSHclient
Jscript
Signs
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Stratus
(25 posts) bio
|
Date
| Fri 06 Sep 2002 01:23 AM (UTC) |
Message
| Ok, I wanted to make a script for my 'guild' so that when a player moved into a certain object they were whispered a message by my bot. Here is the script as of now, I know it's wrong because I found a script for it but it was for PerlScript so I just tried changing as best I could:
function SignActivated (thename, theoutput, thewildcardsVB)
{
var SignXY
var Name
SignXY = world.GetTriggerInfo (thename, 102)
Name = world.GetTriggerInfo (thename, 101)
world.EnableTrigger ("SignOutput","false")
world.SetVariable ("SignXY","$signXY")
world.send ("\"l " + Name)
world.EnableTrigger ("SignOutput","true")
} //end of SignActivated
function SignOutput (thename, theoutput, thewildcardsVB)
{
var Name
var signXY
world.EnableTrigger ("SignActivated","false")
Name = world.GetTriggerInfo (thename, 101)
signXY = world.GetVariable (SignXY)
if ("signxy" eq " & 9")
world.send ("wh " + Name + " Hello, and welcome to the Island of Fincayra! This is the newest sparring guild to come to Furcadia. (Note: This guild is still under -major- construction.")
world.EnableTrigger ("SignOutput","false")
world.EnableTrigger ("SignActivated","true")
} //end of SignOutput
Any idea of how I could make this script work? If so, be sure to reply! |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #1 on Sat 07 Sep 2002 02:12 AM (UTC) |
Message
| Not sure what you are trying to do here, but here are a few comments:
- I wouldn't quote "true" and "false", it should read like this:
world.EnableTrigger ("SignOutput", false)
- Using dollar signs for variable contents is a Perl thing, try this instead:
world.SetVariable ("SignXY", signXY)
- There is not much point in disabling a trigger and re-enabling it, the trigger won't be processed while the script is running anyway.
world.EnableTrigger ("SignOutput", false)
...
world.EnableTrigger ("SignOutput", true)
- What is this line trying to do?
world.send ("\"l " + Name)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Stratus
(25 posts) bio
|
Date
| Reply #2 on Sat 07 Sep 2002 02:42 AM (UTC) |
Message
| I don't know actually. I just found the script but it was for Perlscript so I just put in everything and transfered it to Jscript as best I could. =/ |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | top |
|
Posted by
| Stratus
(25 posts) bio
|
Date
| Reply #3 on Sat 07 Sep 2002 02:45 AM (UTC) Amended on Sat 07 Sep 2002 03:01 AM (UTC) by Stratus
|
Message
| Ok, maybe this will help. Here's the whole script for Perl
sub SignActivated
{
my ($thename, $theoutput, $wildcards) = @_;
$world->enabletrigger ("SignOutput","false");
$signxy = $world->gettriggerinfo ($thename, 102);
$furrexy = $world->gettriggerinfo ($thename, 101);
$world->setvariable ("SignXY","$signxy");
$world->send ("l $furrexy");
$world->enabletrigger ("SignOutput","true");
}
sub SignOutput
{
my ($thename, $theoutput, $wildcards) = @_;
$world->enabletrigger ("SignActivated","false");
$name = $world->gettriggerinfo ($thename, 101);
$signxy = $world->getvariable ("SignXY");
if ("$signxy" eq " & 9")
{
$world->send ("wh $name Hello $name and welcome to the Island of Fincayra.");
}
$world->enabletrigger ("SignOutput","false");
$world->enabletrigger ("SignActivated","true");
}
Any idea of how I would translate it to JScript?
*Note: This script is called when a player moves into a 'sign'
Trigger: ^7 (.*?) 6 \+ 5 3 (.*?) 6$
Send:
Regular Expression: Checked
Label: Sign1
Script: SignActivated |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #4 on Sat 07 Sep 2002 02:50 AM (UTC) |
Message
| You could keep it as Perlscript and make it a plugin.
You can have plugins in different languages, which are not necessarily your "preferred" language for the main scripting configuration. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Stratus
(25 posts) bio
|
Date
| Reply #5 on Sat 07 Sep 2002 03:49 AM (UTC) Amended on Sat 07 Sep 2002 03:54 AM (UTC) by Stratus
|
Message
| I know but I'm just learning JScript right now, so I wanted to see how to do this in JScript so I could do it for all of my 'signs'. I was trying to decide between VBscript and Jscript for my 'bots', I decided on Jscript so I'm trying to learn it real fast and I just thought that by learning all of this script and how it works would help a little I guess. So, I would much appreciate it (not like you have to) show it in Jscript. |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | top |
|
Posted by
| Nick Gammon
Australia (22,975 posts) bio
Forum Administrator |
Date
| Reply #6 on Sat 07 Sep 2002 06:57 AM (UTC) |
Message
| To help me understand this a bit better, can you give me the two other triggers? The script refers to enabling the triggers "SignOutput" and "SignActivated", so what do they do? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Stratus
(25 posts) bio
|
Date
| Reply #7 on Sat 07 Sep 2002 08:22 AM (UTC) Amended on Sun 08 Sep 2002 08:33 AM (UTC) by Stratus
|
Message
| Trigger: ^7 9\!\! \:\! \!\+ 9\!\!$ (It's something like that, I don't actually have the trigger on me right now.)
Send:
Enabled: Checked
Regular Expression: Checked
Label SignnActivated
Script: SignActivated
SignActivated is to begin when the character bumps the sign, then it calls the script SignActivated.
Trigger: ((You see *.)
Send:
Enabled: Unchecked
Label: SignOutput
Script: SignOutput
SignOutput is suppossed to be called after it is enabled by SignActivated and after the bot looks at the character. (l Name). So then it's possible to get the name of the character instead of just their position, then with the script it does all this and whispers them back whatever. :)
I did a little testing with a friend of mine and we got the script to work up until the world.send, here it is:
function SignActivated (thename, theoutput, thewildcardsVB)
{
var name
var signxy
world.EnableTrigger ("SignOutput", false);
name = world.GetTriggerInfo (thename, 101);
signxy = world.GetTriggerInfo (thename, 102);
world.SetVariable ("SignXY", signxy);
world.send ("\"look " + name);
world.EnableTrigger ("SignOutput", true);
}
This works perfectly except instead of sending "Look Name
to the world it send Look * or another character, it's suppossed to retrieve the character's position and look at the person there, then call the next script. But instead it keeps taking a letter or number out of the trigger. |
Trust me, Diet Coke isn't nearly as good as regular.
-Stratus | 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.
16,829 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.