Unterminated string constant?

Posted by Zendu on Wed 12 May 2004 08:30 AM — 8 posts, 27,514 views.

#0
What does this mean?
the context is "you have 261 gold"
trigger "you have (*.) gold"
send SetVariable "count-gold", CInt (GetVariable ("count-gold)) + %1
USA #1
try adding the second " after the "count-gold"))
erm, so,
SetVariable "count-gold", CInt (GetVariable ("count-gold")) + %1

At least, thats what I think youre asking. Honestly, with that many words, Ive no idea.

Oh, and your regexp should be .* not *.
Im assuming that is just a typo, which is why its usually more reliable (so we know if the typo is in your trigger, or just in the translating to forum) to just copy/paste the trigger.
Amended on Wed 12 May 2004 08:37 AM by Flannel
#2
ya it was the " cant belive i missed that

Now it says either Cint shouldnt be there (when removed, it says: invalid use of setvariable.

hrmm i have something very similar working atm, so i must be missing somehting with wildcard...
Amended on Wed 12 May 2004 08:49 AM by Zendu
Australia Forum Administrator #3
Where did you put the quote?

As Flannel says, copy and paste the actual trigger - it is very easy to do (one click) then we know what you actually have.
#4
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="^(.*?) myrrh$"
regexp="y"
send_to="12"
sequence="100"
lowercase_wildcard="y"
>
<send>SetVariable &quot;count-myrrh&quot;, CInt (GetVariable (&quot;count-myrrh&quot;)) + %1</send>
</trigger>
</triggers>



Theres the whole thing
Australia Forum Administrator #5
OK, your script part is:

SetVariable "count-myrrh", CInt (GetVariable ("count-myrrh")) + %1

Now if the variable "count-myrrh" does not exist VBscript complains that you are trying to do a CInt on a "null" variable. Just make sure the variable exists first (eg. set to 0) or have a test like:


if not isnull (GetVariable ("count_myrrh")) then
  SetVariable "count_myrrh", CInt (GetVariable ("count_myrrh")) + %1
end if


Note also that the variable "count-myrrh" will *never* exist, because MUSHclient variables cannot have hyphens in them. You want something like "count_myrrh" which I used in the code above when I was testing it.



Australia Forum Administrator #6
Also, if you have a prompt or something before the word "myrrh" you will get an error, eg.


<1000/1000 hp 100/100 m 110/110 mv>14 myrrh


This is because %1 will be in this case "<1000/1000 hp 100/100 m 110/110 mv>14".

A better regular expression might be:

match="^(\d+) myrrh$"

The \d+ says one or more digits, whereas what you had (.*) means zero or more of anything.
USA #7
Actually, a better regexp would be (\d+) myrhh
no ^ since it would prohibit matching on lines with prompts.
This way having
<[prompt]> 33 myrhh
will still match, unless you dont want it. And if you want it anchored to the end of the line $ afterwards.

(actually, I agree, it would be smart to anchor it, since otherwise it will match on people talking about on it. So, while this will match on more things, it will match on too many, Im only posting, to bring up the anchors, you can edit if needed, to suit your needs)