So I'm trying to make an herbing script for the web client, and I need it to send multiple commands at the same time. Right now my code looks something like this:
gwc.connection.send("disembark");
if (gwc.gmcp.data.room.id == "6fTEU.") {
gwc.connection.send("n");
gwc.connection.send("n");
gwc.connection.send("search here for herbs");
}
In Mudlet, all I'd have to do is use "sendAll". Is there any way I can condense potentially hundreds of commands into one line of JS?
JavaScript: Sending multiple commands at once
Forum rules
- Use common sense and be respectful towards each other at all times, even when disagreeing.
- Do not reveal sensitive game information. Guild secrets, player seconds are examples of things not allowed.
- Use common sense and be respectful towards each other at all times, even when disagreeing.
- Do not reveal sensitive game information. Guild secrets, player seconds are examples of things not allowed.
JavaScript: Sending multiple commands at once
Alea iacta est. Serius regredi est.
Re: JavaScript: Sending multiple commands at once
uhm?
[ 'n', 'e', 'w' ].map((word) => gwc.connection.send)
[ 'n', 'e', 'w' ].map((word) => gwc.connection.send)
Re: JavaScript: Sending multiple commands at once
Another way would be something like this...
What you do here is you create an array with each of the commands you would like to send, then you use a forEach function on that array to execute the gwc.connection.send function on each element of that array. If you have multiple room IDs you want to check, then have a long series of if--elseif--else conditions and use the last few lines at the end of the script.
Code: Select all
if (gwc.gmcp.data.room.id == "6fTEU.") {
actions = ['n', 'n', 'search here for herbs'];
}
actions.forEach(function(action) {
gwc.connection.send(action);
});
http://tworzymyatmosfere.pl/przescieradla-jedwabne-z-gumka/