[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  disable all scripts temporarily

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: disable all scripts temporarily
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  3  

Posted by Worstje   Netherlands  (867 posts)  [Biography] bio
Date Sat 02 Aug 2008 07:20 AM (UTC)  quote  ]
Message
Fair enough, the thought crossed my mind too.

Alternatively, you could add another switch which would need to be consciously turned on by the user, maybe as part of the allowed plugins stuff you have in the Lua sandbox. Or maybe make it a special feature that would only work in global plugins.

With the advent of miniwindows, I can imagine a number of helper plugins being written, not unlike the Ungagger I started writing. Things like changing the 'Omit from Log' for certain triggers in certain plugins because it could be beneficial for certain plugins (for example you want to log a fight in a roleplay, but because of it being a roleplay you want it to actually end up in the log), or maybe to set the 'Keep evaluating' flag because it prevents the matching of a trigger you made dynamically in your plugin as a part of some debugging process.

Maybe some kind of helper plugin that would try to help resolve incompatibility between different plugins without executing a dozen traces and back-and-forth communication between the user and a helpful person or the actual writer of one of those plugins. Something that would automatically figure out 'trigger A in plugin X prevents the execution of trigger B in plugin Y' by trying to test such stuff by removing/adding certain flags to triggers.

Honestly, I am thinking quite much in the direction of adding features to MUSHclient that might not be fit for the actual client, but that certain people could get a lot of use from. Maybe in time it will actually end up producing some really worthwhile plugins.
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Sat 02 Aug 2008 06:25 AM (UTC)  quote  ]
Message
Sorry I missed the question amongst all the chatter about "not X and 1 or 0" and so on.

My attitude so far has been that a plugin author ought to be able to write a plugin, secure in the knowledge that its internal state, or variables, won't be changed by other plugins, or the main world script.

Indeed if they could do so, you could get into a race condition, where sometimes it works if plugin A disables plugin B, but other times plugin B disables plugin A first.

I would need to see a more compelling case made than the one so far, which was solved by simply making a fairly simple accelerator.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Worstje   Netherlands  (867 posts)  [Biography] bio
Date Sat 02 Aug 2008 04:04 AM (UTC)  quote  ]
Message
Nick, any chance on an answer to my question above?
[Go to top] top

Posted by Fiendish   USA  (851 posts)  [Biography] bio   Global Moderator
Date Thu 31 Jul 2008 06:59 PM (UTC)  quote  ]

Amended on Thu 31 Jul 2008 07:00 PM (UTC) by Fiendish

Message
"not" creates a boolean. The problem was that somehow I didn't realize it was always creating a bad one because I'm not used to languages that don't make int and bool equivalent. Though I'm fairly certain that I tried it at one point and I thought I saw that it was working, I must have been mistaken. So my suggestion that I should have used 1-X was to replace not the X and 1 or 0, but rather to replace "not X and 1 or 0" in a way that actually works for integer X.

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Thu 31 Jul 2008 03:55 PM (UTC)  quote  ]
Message
It wasn't exactly obvious to me that you had switched from booleans to integers, given that you were talking about booleans immediately before that. (Yes, I know that the MUSHclient function returns an integer. And yes, I am "moderately" familiar with Lua.) Anyhow, it's unclear to me what you're doing with these, and where these booleans are coming from in the first place, so... :shrug:

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Fiendish   USA  (851 posts)  [Biography] bio   Global Moderator
Date Thu 31 Jul 2008 03:23 PM (UTC)  quote  ]

Amended on Thu 31 Jul 2008 03:26 PM (UTC) by Fiendish

Message
Quote:
1-X for boolean X
I meant it for integer X to toggle 1 and 0, which is what GetOption returns.

For boolean X, the and 1 or 0 works fine to convert to an integer. They serve different purposes, you see.

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Thu 31 Jul 2008 03:17 PM (UTC)  quote  ]
Message
Since Lua doesn't treat them the same, I think it would be more cautious to not try converting "false" to 0. 0 is not false in Lua, after all.

1-X for boolean X doesn't do anything helpful (in Lua). By that I mean that it is a runtime error. :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Fiendish   USA  (851 posts)  [Biography] bio   Global Moderator
Date Thu 31 Jul 2008 02:50 PM (UTC)  quote  ]

Amended on Thu 31 Jul 2008 03:08 PM (UTC) by Fiendish

Message
Quote:
(X and 1) or 0 is logically equivalent to just X, anyhow. :-)
X and 1 or 0 is just a convention for converting a boolean into an integer, because lua doesn't treat them the same like some other languages do.

Clearly I would need to use 1-X instead.

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Worstje   Netherlands  (867 posts)  [Biography] bio
Date Thu 31 Jul 2008 01:16 PM (UTC)  quote  ]
Message
I and my big mouth about writing that plugin quickly. I got it all whipped out, and upon testing I found out there is no such function as SetPluginTriggerOption()... which rather messes it all up if I am also to disable the outputting for other plugins. I got it all working (including spiffy miniwindow to denote an ON state) except for the actual restoring.

Nick, any chance such a function (and mirrors of other GetPlugin* functions) can be added? >_>
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Thu 31 Jul 2008 12:45 PM (UTC)  quote  ]
Message
(X and 1) or 0 is logically equivalent to just X, anyhow. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Fiendish   USA  (851 posts)  [Biography] bio   Global Moderator
Date Thu 31 Jul 2008 08:28 AM (UTC)  quote  ]
Message
I guess my mind has been playing tricks on me. After sleeping and waking up now it only displays 0. Oh well. Off to check the number.

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Thu 31 Jul 2008 04:36 AM (UTC)  quote  ]
Message
Quote:

/Note (not GetOption("enable_triggers") and 1 or 0) shows 1 or 0


No, it doesn't. It always shows 0.

Look, GetOption("enable_triggers") returns type number, so that will *always* be considered true. So you effectively have:

not true and 1 or 0

not true is false, so it becomes:

false and 1 or 0

These are boolean opereations (and and or) so this now becomes:

false and true or 0

It will always return zero.

You don't think this is a tad complicated do you?

GetOption returns a number, how about testing that number?



/AcceleratorTo ("Ctrl+T", [[
if GetOption("enable_triggers") == 1 then
  SetOption("enable_triggers", 0)
  Note "Triggers disabled!"
else
  SetOption("enable_triggers", 1)
  Note "Triggers enabled!"
end -- if
]], sendto.script)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (851 posts)  [Biography] bio   Global Moderator
Date Thu 31 Jul 2008 03:03 AM (UTC)  quote  ]

Amended on Thu 31 Jul 2008 03:25 AM (UTC) by Fiendish

Message
Quote:
/print (GetOption("enable_triggers") ) --> either prints 0 or 1
Yeah, I got that far. On the first one, I guess I'm just too used to the C/C++ equivalence of bools and ints.

What about the second one, though?
/Note (not GetOption("enable_triggers") and 1 or 0) shows 1 or 0

It seems like the "(not GetOption("enable_triggers") and 1 or 0)" part of
/AcceleratorTo ("Ctrl+T", 'SetOption("enable_triggers", (not GetOption("enable_triggers") and 1 or 0))', sendto.script)

is getting processed as I create the accelerator instead of when I use it. I don't understand why, since obviously the "SetOption" part doesn't happen until it's used. Is there a way around that?

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Fiendish   USA  (851 posts)  [Biography] bio   Global Moderator
Date Thu 31 Jul 2008 02:55 AM (UTC)  quote  ]

Amended on Thu 31 Jul 2008 03:01 AM (UTC) by Fiendish

Message
Quote:
If you are not trying the suggestions we are giving you before shooting them down, what is the point?
I didn't. I thought Nick did. Clearly I was mistaken.

Quote:
I could write it some time when I have time, if you'd like.
I am interested.

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Thu 31 Jul 2008 02:53 AM (UTC)  quote  ]
Message
Quote:

why don't either of these work?

/AcceleratorTo ("Ctrl+T", 'if GetOption("enable_triggers") then SetOption("enable_triggers", 0) else SetOption("enable_triggers", 1) end', sendto.script)


Try this:


/print (GetOption("enable_triggers") )  --> either prints 0 or 1


Now in Lua, "if 0 then ..." will evaluate to true. This is basic Lua coding. The only things that are false in Lua are nil and the boolean value false.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


8,285 views.

This is page 1, subject is 3 pages long: 1 2  3  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]