Unknown2010-01-10 01:47:41
To be honest, I didn't test it with the io.close() part, but Treant uses the first two lines in its installation. I think the file is automatically closed when it's all read in, if you use io.input to open it. Keep in mind that using io.input multiple times will overwrite your previously open files, as it only remembers the last file handle. If you want to have multiple files open for input/output at one time, use io.open instead.
The io.open function returns a file handle, which you then use to read/write things.
Untested again, but something like that should work for you.
The io.open function returns a file handle, which you then use to read/write things.
CODE
f = io.open("my.txt", "w")
f:write("blah blah blah")
f:close()
f = io.open("my.txt", "r")
blah = f:read("*a")
f:close()
f:write("blah blah blah")
f:close()
f = io.open("my.txt", "r")
blah = f:read("*a")
f:close()
Untested again, but something like that should work for you.
Mirami2010-01-10 03:40:13
So, I'm trying to make an alias to auto-remove stuff (for influencing). the alias is stuff *, and it's not case-sensitive. However, when I type 'stuff on', nothing happens. (sent to script, expanding variables)
CODE
stuff *
if %1 == "on" then
  Send("wear robes")
  Send("wear cloak")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear watch")
  Send("wear slippers")
  Send("wear pack")
  Send("wear pendant")
  Send("raise hood")
elseif onoff == "off" then
Send("remove robes")
Send("remove cloak")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove watch")
Send("remove slippers")
Send("remove pack")
Send("remove pendant")
end
if %1 == "on" then
  Send("wear robes")
  Send("wear cloak")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear ring")
  Send("wear watch")
  Send("wear slippers")
  Send("wear pack")
  Send("wear pendant")
  Send("raise hood")
elseif onoff == "off" then
Send("remove robes")
Send("remove cloak")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove ring")
Send("remove watch")
Send("remove slippers")
Send("remove pack")
Send("remove pendant")
end
Eldanien2010-01-10 03:44:21
The bolded part looks wrong. Try %1 there, as well.
elseif onoff == "off" then
elseif onoff == "off" then
Mirami2010-01-10 03:51:14
QUOTE (Eldanien @ Jan 9 2010, 07:44 PM) <{POST_SNAPBACK}>
The bolded part looks wrong. Try %1 there, as well.
elseif onoff == "off" then
elseif onoff == "off" then
Oh, yes. That needs to be changed back. Although, changing that doesn't actually fix the problem...
Unknown2010-01-10 04:07:33
Use ^stuff (\\w+)$ instead.
Eldanien2010-01-10 04:11:52
Ok, not so helpful. A test shows %1 there is carrying a nil value. Going to play around with it a bit.
Ilyarin2010-01-10 04:39:40
QUOTE (Zarquan @ Jan 10 2010, 01:47 AM) <{POST_SNAPBACK}>
To be honest, I didn't test it with the io.close() part, but Treant uses the first two lines in its installation. I think the file is automatically closed when it's all read in, if you use io.input to open it. Keep in mind that using io.input multiple times will overwrite your previously open files, as it only remembers the last file handle. If you want to have multiple files open for input/output at one time, use io.open instead.
The io.open function returns a file handle, which you then use to read/write things.
Untested again, but something like that should work for you.
The io.open function returns a file handle, which you then use to read/write things.
CODE
f = io.open("my.txt", "w")
f:write("blah blah blah")
f:close()
f = io.open("my.txt", "r")
blah = f:read("*a")
f:close()
f:write("blah blah blah")
f:close()
f = io.open("my.txt", "r")
blah = f:read("*a")
f:close()
Untested again, but something like that should work for you.
This is great, thanks!
Eldanien2010-01-10 04:43:06
For a temporary fix, you could use the following.
For the alias:
      script="Stuff"
    match="^stuff (.*?)$"
    enabled="y"
    regexp="y"
    send_to="12"
    sequence="100"
  >
 Â
For the script in your scriptfile:
For the alias:
CODE
 Â
    match="^stuff (.*?)$"
    enabled="y"
    regexp="y"
    send_to="12"
    sequence="100"
  >
 Â
For the script in your scriptfile:
CODE
function Stuff (name, trig_line, wildcards)
  local myvar = wildcards
  if myvar == "on" then
    Send("wear robes")
    Send("wear cloak")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear watch")
    Send("wear slippers")
    Send("wear pack")
    Send("wear pendant")
    Send("raise hood")
  elseif myvar == "off" then
    Send("remove robes")
    Send("remove cloak")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove watch")
    Send("remove slippers")
    Send("remove pack")
    Send("remove pendant")
  end
end
  local myvar = wildcards
  if myvar == "on" then
    Send("wear robes")
    Send("wear cloak")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear ring")
    Send("wear watch")
    Send("wear slippers")
    Send("wear pack")
    Send("wear pendant")
    Send("raise hood")
  elseif myvar == "off" then
    Send("remove robes")
    Send("remove cloak")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove ring")
    Send("remove watch")
    Send("remove slippers")
    Send("remove pack")
    Send("remove pendant")
  end
end
Unknown2010-01-10 04:52:15
You have to put the %1 in quotes.
CODE
ColourNote("yellow", "black", "The value is %1")
if "%1" == "on" then
ColourNote("yellow", "black", "It's on!")
elseif "%1" == "off" then
ColourNote("yellow", "black", "It's off!")
else
ColourNote("yellow", "black", "It's something else!")
end
if "%1" == "on" then
ColourNote("yellow", "black", "It's on!")
elseif "%1" == "off" then
ColourNote("yellow", "black", "It's off!")
else
ColourNote("yellow", "black", "It's something else!")
end
Mirami2010-01-10 04:55:55
QUOTE (AllergictoSabres @ Jan 9 2010, 08:52 PM) <{POST_SNAPBACK}>
You have to put the %1 in quotes.
CODE
ColourNote("yellow", "black", "The value is %1")
if "%1" == "on" then
ColourNote("yellow", "black", "It's on!")
elseif "%1" == "off" then
ColourNote("yellow", "black", "It's off!")
else
ColourNote("yellow", "black", "It's something else!")
end
if "%1" == "on" then
ColourNote("yellow", "black", "It's on!")
elseif "%1" == "off" then
ColourNote("yellow", "black", "It's off!")
else
ColourNote("yellow", "black", "It's something else!")
end
thanks!
Kaalak2010-01-19 11:15:09
Is it common for Mushclient to completely freeze up?
I just had this happen today after combat when there was less spam.
I just had this happen today after combat when there was less spam.
Unknown2010-01-19 11:26:17
QUOTE (Kaalak @ Jan 19 2010, 06:15 AM) <{POST_SNAPBACK}>
Is it common for Mushclient to completely freeze up?
I just had this happen today after combat when there was less spam.
I just had this happen today after combat when there was less spam.
No, it only locks up when you write a script or set a trigger that sets off an infinite loop.
Ayisdra2010-01-30 17:03:01
I want to have the keypad have the pilot steer when I'm module locked into the chair, and normal movement when I'm not.
Is there a way bind this so I have it on the base keypad? (ie, just having to push the number and not some other button such as Ctrl + keypad)
Edit: error in my trigger found...
Is there a way bind this so I have it on the base keypad? (ie, just having to push the number and not some other button such as Ctrl + keypad)
Edit: error in my trigger found...
Rodngar2010-01-30 17:41:55
Have a variable that flicks on and off with a simple check per button to see if you're in the module or out of the module, then do an appropriate command.
(In zMUD, it'd be something like NUM1 becing #IF (@piloting=1) {shipsteeringthinghere} {n}, where the second response being an IFNOT basically, but I'm unsure if Mushclient is the same way)
(In zMUD, it'd be something like NUM1 becing #IF (@piloting=1) {shipsteeringthinghere} {n}, where the second response being an IFNOT basically, but I'm unsure if Mushclient is the same way)
Razenth2010-02-03 18:39:44
When using plugins has anyone run into the problem where once I close the world it pops up and says that it can't create the save state file for the module? Is this a problem of Mush not having perms where the plugin file is stored (I've put mine in my C:\\Treant\\ file so I can include some of the Treant lua files)?
Unknown2010-02-03 19:27:13
Permissions might be one reason. I don't use plugins that save their states, so I have never had this problem.
Razenth2010-02-03 23:01:30
Hm, interesting. If I put SetVariable and GetVariable function calls inside a plugin file, will it search for those variables in the world file as well as in the script file?
Esano2010-02-03 23:24:54
When Set/GetVariable are called from inside a plugin, it will save/get those variables in the plugin. If you want to get world variables, you need to use GetPluginVariable with an empty string as the 'plugin' argument, e.g. GetPluginVariable("","target").
Razenth2010-02-03 23:58:10
Another question: I want to use some of the functions in Treant, namely the ones in the affs and bals lua files. Is that actually possible in a plugin, given the interdependencies of the files?
Unknown2010-02-04 02:30:18
If you use any scripts in a plugin, they'll be in their own little sandbox. The only information shared is that which you pass back and forth through aliases or some such mechanism. This is reason number one why I do not use plugins for my coding, except in those very limited situations where it's required.