Hi to all. I have a question, i've been killing my mind to try to figure this out, and i can't.
I have an alias, like this:
-stringo -(.*) -(.*) -(.*) -(.*)
What it does is the following:
var item;
var newitem;
var short;
var long;
item = "%1";
newitem = "%2";
short = "%3";
long = "%4";
My problem is that if the name (newitem) has 2 or more words, the code gives an error.
Example: The newitem will have the name mighty hammer gods.
When it does the short description on it, it gets the full name, mighty hammer gods, and not only one of the names. What i need is a line of code, that if it has one keyword, it uses that keyword, if it has 2 keywords, it sets the name to those 2 keywords, but when doing the short or the long, it uses only one of those keywords. And so on, if it has 3 the same thing.
What am i doing wrong?
Thank you.
It is used for restring objects on the MUD. I don't know if all MUD's are alike.
The error is that on the second world.send, the newitem can only have one word, and not more then one word. If i name the item like i sayd before, the string saved on the var new item will be the all name, and i only need one, the first word for example.
N:Reorx Vnum:1205 Incog: Wizi:
-stingo -book -book pedro -book pedro -Here lies a book
Huh?
N:Reorx Vnum:1205 Incog: Wizi:
string obj book name book pedro
string obj [b]book pedro[/b] short book pedro
string obj [b]book pedro[/b] long Here lies a book.
N:Reorx Vnum:1205 Incog: Wizi: Syntax:
string char <name> <field> <string>
fields: name short long desc title spec racetext
string obj <name> <field> <string>
fields: name short long extended
N:Reorx Vnum:1205 Incog: Wizi: Syntax:
string char <name> <field> <string>
fields: name short long desc title spec racetext
string obj <name> <field> <string>
fields: name short long extended
N:Reorx Vnum:1205 Incog: Wizi:
This is the MUD output. The two last outputs are the error, that's why i can't do what it suposed to do.
Thank you Nick.
I have posted all the outputs. I don't know what to do more :(.
The commands on the MUD are as followed:
string obj (object) name (new name)
string obj (new name) short (short description)
string obj (new name) long (long description)
These are the commands that are inputed on the MUD, so you can change the name of the object. The () are there only to show that it is what you need to input.
So i need to make an alias to do those 3 commands, in Jscript or with something else. See the (new name) that's where my problem is. If you set the new name with one word, there is no problem, but if you put 2 words on the new name, the second command don't work cause the (new name) must be entered on only one word. If i do those 3 commands, separated, by hand, they work fine.
He's trying to match that to his input rather than mud output Nick. At least I'm pretty sure that's what I'm reading in his next to last post.
Halig, try putting your newitem output in quotes if it contains multiple words. What codebase is this for? Would be a good bit easier to help you with that info.
ex: string obj "(multi-word new name)" short (short description)
If the server doesn't complain about the " " enclosure, change your alias to put keywords in quotes so that it doesn't 'confuse' the server with multiple keywords. That's why it's failing the way you set it up initially - the server is looking for a single 'word' for keyword when you restring and it should treat "(stuff stuff stuffy stuff)" as a single 'word' and allow you to use the alias like you're trying to do. If it's still complaining with the " " enclosure, you're going to need to rework the alias to properly fit the expected input pattern which could get very tricky if you've got something that was built with a lot of keywords.
Thank you again.
The alias still getting messed up. Can you help me with the rewritten of that?
I'm really stuck, cause it works if you type one command at a time, but i want to automated that, make the three commands on one alias.
Be sure expand variables is checked or this is guaranteed to fail spectacularly.
<aliases>
<alias
match="-stringo -(.*?) -(.*?) -(.*?) -(.*?)"
enabled="y"
expand_variables="y"
group="Restring"
regexp="y"
send_to="12"
keep_evaluating="y"
sequence="100"
>
<send>var item;
var newitem;
var short;
var long;
item = "%1";
newitem = "%2";
short = "%3";
long = "%4";
world.execute(string obj @item name @newitem);
world.execute(string obj "@newitem" short @short);
world.execute(string obj "@newitem" long @long);</send>
</alias>
</aliases>
I'm pretty sure I got that right at least. Using execute rather than send should keep the expanding variables functioning properly within the quotes and if not, Nick should spot any mistakes I made fairly easily. This one's a little beyond what I normally do with aliasing and the command syntax for string is definitely complicating things.
That still leaves an issue if he wants to do something like
-stringo -foo -chocolate bar -pedro -hello world
Passing string obj chocolate bar short pedro is going to cause the command to fail because the syntax will be 'wrong' despite the info being accurate. Is there a simple way to put the newitem info into quotes when its passed? I'm thoroughly out of my area of expertise on that issue.
Actually, it just occurred to me that I've been trying to do that the hard way. Halig, forget about trying to put quotes around the newitem variable when it's passed to the server, put quotes around your keywords if you're going to use multiple keywords. The quotes will get passed as part of the variable and the server should treat the entire thing as 1 'word' for command syntax purposes.
ie -stringo -foo -"chocolate bar" -pedro -hello world
item foo
newitem chocolate bar
short pedro
long hello world
string obj foo name chocolate bar
string obj chocolate bar short pedro
string obj chocolate bar long hello world
The hyphens delimit the different word groups. You could conceivably add the quotes in the alias, eg.
item foo
newitem chocolate bar
short pedro
long hello world
string obj "foo" name "chocolate bar"
string obj "chocolate bar" short "pedro"
string obj "chocolate bar" long "hello world"
Now it works. Thank you all.
There is only one problem. When you put that, the name on the nweitem appears with the "chocolate bar".
Is there any way to take off the ""?
item book
newitem book of pedro
short book of pedro
long Here lies the book of pedro.
string obj "book" name "book of pedro"
string obj "book of pedro" short "book of pedro"
string obj "book of pedro" long "Here lies the book of pedro."
If then you look at your inventory, the item book of pedro, has the "booke of pedro", meaning that the item got the name with the "".
Still nothing.
I guess i just have to make three aliases to make those things. If i have the three separated, everything is good.
Thank you for trying to help.
Nick, let's try this diferently.
Tell me something, if i have a variable that countains let's say, book of pedro.
How can i use that variable but get only the first word?
That's all i need, to collect from the variable the first word.
Thank you.
Hello again Nick,
Thank you for your patience, but how ca i do that using Jscript?
I have more scripts assigned to aliases and if i change the script of MushClient to lua, the other ones don't work.
Thank you again.
I recommend you use Lua. If you don't want to, put the other aliases into a plugin. Plugins each have their own script language, so some plugins can use Jscript and others Lua.
There must be a way of find a single word in Jscript, I suggest Google.
Thank you Nick. I didn't knew that you could turn all the other aliases and triggers into a plugin using diferent languages. Thank you. All is working now.