Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Lets start the conversion.
Lets start the conversion.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
3
4 5
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #45 on Mon 13 Dec 2004 10:40 PM (UTC) |
Message
|
Quote: I have added a couple of new things to MUSHclient 3.60. The first one lets you do a script just before MUSHclient saves its world to disk. This is a logical spot to serialize from internal variables to the external variables.
yeah, I used to have a timer that did that every 5 minutes or so, but I don't remember the exact syntax... Not to mention when, I re-scripted it after my computer meltdown, it didn't save in the spot that I wanted it too, it kept saving in C:\My Documents, which I didn't want, I wanted it saved in D:\Program Files\MUSHclient\worlds
Anyways... I'll figure that out eventually. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #46 on Mon 13 Dec 2004 11:01 PM (UTC) |
Message
| A save with no filename should save in the default place (ie. the current file).
eg.
Save "" |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #47 on Mon 13 Dec 2004 11:03 PM (UTC) |
Message
| I think you can use .. "|%1"
But if that doesnt work, you can probably also use .. "|" .. "%1"
And then you have expand variables checked, and (@replacetext) in your match text. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #48 on Mon 13 Dec 2004 11:07 PM (UTC) Amended on Mon 13 Dec 2004 11:11 PM (UTC) by David Berthiaume
|
Message
| The only issue I see with that is a possible nil return when there is no variable there in the first place.
run it through a script(you're gonna be scripting in it already to set the table element):
if GetVariable ("replacetext") == nil then
SetVariable ("replacetext", "%1")
else
SetVariable ("replacetext", "@replacetext" .. "|" .. "%1")
end -- if
On a side note, I was just thinking of my infobar script, I could do away with variables completely, I think. Use table's to store the information, nothing would really change, but instead of saving to the variable list, it would be updating the table... Then along with all my other tables, when I save the world, or whatever, it'll save that into a single variable, which will reload itself aferwards. Man, I like this table thing... I never understood it in VBscript before, but Lua seems pretty straight forward in how the tables work. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #49 on Mon 13 Dec 2004 11:20 PM (UTC) |
Message
| You can make that a bit shorter. For one thing testing for not-nil can be done without the == nil bit.
Second, if you use the "var" table you can save the GetVariable/SetVariable stuff. So it could read:
if var.replacetext then
var.replacetext = var.replacetext .. "|%1"
else
var.replacetext = "%1"
end -- if
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #50 on Mon 13 Dec 2004 11:22 PM (UTC) |
Message
| In many ways it is easier to stick with tables anyway, and use table.concat to put in the "|" symbols. Here is an example:
t = { "fish", "chips", "cat", "dog" }
print (table.concat (t, "|"))
-- Ouput: fish|chips|cat|dog
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #51 on Mon 13 Dec 2004 11:27 PM (UTC) |
Message
| Yeah, that's true, it would be easier to stick with tables, but that doesn't change the fact that I need a regexp trigger to match against the table...
That reminds me, if we get the replace text thing working perfectly, then they'll be one last issue, it's CAPS sensitive. even if you're matching ignore case, it won't work. I tested that earlier when I first started playing with it. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #52 on Tue 14 Dec 2004 12:04 AM (UTC) Amended on Tue 14 Dec 2004 02:06 AM (UTC) by Nick Gammon
|
Message
| In what context are you doing the test? Triggers can be made case-insensitive. So can regexps.
The output from that table concatenation (fish|chips|cat|dog) can be used in a regexp. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #53 on Tue 14 Dec 2004 12:13 AM (UTC) Amended on Tue 14 Dec 2004 12:21 AM (UTC) by Flannel
|
Message
| Why would the variable be empty to begin with?
and I dont see how sticking with tables would help.
Youd need to have a table to keep your targets, as well as a MC variable.
Edit:
I see, youre using the table to store the information for the switch. So you add to the table, and then regenerate your MC variable. Wouldnt the output be both columns though?
As for a long term storage solution, which could just be a MC variable for each thing (name, and replacement names), or you can store it in a database.
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #54 on Tue 14 Dec 2004 12:22 AM (UTC) |
Message
| All right:function textreplace (name, line, wildcards, styles)
for _, v in pairs (styles) do
ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
(string.gsub (v.text, "Altair", "Dummy")))
end
end
This is the case sensitive part:(string.gsub(v.text, "Altair", "Dummy")))
<triggers>
<trigger
enabled="y"
ignore_case="y"
keep_evaluating="y"
match="Altair"
omit_from_output="y"
regexp="y"
repeat="y"
script="textreplace"
sequence="100"
>
</trigger>
</triggers>
We have success, this works, Altair(script version) == Altair(Trigger Version)
Ok, lets change it now. Now we match on "altair"
altair(Trigger with ignore case) does not match Altair in the script
Flip it around again, Make the Trigger Altair, and the script altair, it doesn't match up.
Now if you match on altair, and you type say altair, then it will work, if you type: say Altair, no dice, it won't work...
So what I mean is that the code that you put up is case senstive, even thought the trigger says it's not supposed to be... That might be a slight bug... Perhaps. I don't know. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #55 on Tue 14 Dec 2004 12:30 AM (UTC) |
Message
| You can check the "convert wildcards to lowercase" OR you can just cast the name (wildcard, once its passed) to lowercase while you're checking.
Then you'll have to have your match table be all lower case (you convert to lowercase (.lower) when you add it). |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #56 on Tue 14 Dec 2004 12:34 AM (UTC) |
Message
| yeah, converting to lowercase works, but annoying when you have to script AddTrigger... *shrugs* Oh well, such is life.
I'm still trying to work out how to combine the first replace text script, and the second example Nick gave us.
I should probably stop for the night, go to bed, and think about it tommorrow morning. when I'm not brain dead tired. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #57 on Tue 14 Dec 2004 12:51 AM (UTC) |
Message
| Why are you scripting addtrigger?
Thats why were using the variable, so you can match on anyone inside your list, and then convert. All in one trigger. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #58 on Tue 14 Dec 2004 01:09 AM (UTC) |
Message
| Ok, so you set the variable... how do you match lines of the mud to a variable?
You have to use a trigger.
That's why you have to script an AddTriger
AddTrigger("Textreplace", var.replacetext , "", trigger_flag.Enabled , custom_colour.Custom15, 0, "", "")
make it regexp and lowercase wilds, and what not. Anyways, you have to keep replacing the trigger that matches the replacetext that you want. Otherwise setting up the variable is useless, and like Nick said, we don't even need the variable really, we can script it right into a table and that will speed things up. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #59 on Tue 14 Dec 2004 01:22 AM (UTC) |
Message
| But then you have a trigger for each name.
Which you might as well ditch the table for, and hard code it directly into the trigger (no more lookup, just a subroutine which replaces X with Y).
You can have a trigger match ANY name in your table (which is also in your variable) using expand variables and a variable-regexp. So the same trigger matches constantly, and you dont use AddTrigger anywhere.
Oh, youre hard-coding the variable into the trigger. The problem with that is then you have to add the parenthesis to the outsides of the list. Which, is doable.
You would lose the information about the trigger (number of matches and such) which may or may not be an issue.
And I'd imagine setting the variable takes less time than adding a trigger. You'd need to set the MC variable eventually to save your list between sessions (or use a database, but I think a database might be overkill). |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | 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.
149,635 views.
This is page 4, subject is 5 pages long:
1
2
3
4 5
It is now over 60 days since the last post. This thread is closed.
Refresh page
top