Simimi2007-05-16 20:35:49
Well I now get this when I load the script file...
The first 24 lines of the script are...
I fail to see what is wrong here... maybe I am just not knowing what to look for, or how it is counting lines... var.health is the 24th line from the top though, and it looks like all of my other vars.
And for some reason, the shortcut ctrl+shift+F12 does not work for me... I still do not notice a trigger test ability under the triggers menu either.
CODE
Compile error
World: lusternia
Immediate execution
:24: unexpected symbol near '='
World: lusternia
Immediate execution
:24: unexpected symbol near '='
The first 24 lines of the script are...
CODE
--Simimi System Version 0.2
--**********VARIABLES**********
--@Balances@
var.potionbalance = 1
var.equilibrium = 1
var.balance = 1
var.sparklebalance = 1
var.healingscrollbalance = 1
var.herbbalance = 1
var.salvebalance = 1
var.purgativebalance = 1
var.focusbalance = 1
var.allhealebalance = 1
var.writhebalance = 1
var.rightarmbalance = 1
var.leftarmbalance = 1
var.pickupbalance = 1
--@Tracking@
var.tonextlevel =
var.levelname =
var.health =
var.maxhealth =
var.endurance =
var.maxendurance =
var.mana =
var.max_mana =
var.willpower =
var.maxwillpower =
var.ego =
var.maxego =
var.power =Â Â
var.reserves =
var.karma =
var.esteem =
var.promptstring =
--@Defs@
var.sixthsense =
var.kafe =
var.nightsight =
var.yesod =
var.malkuth =
var.insomnia =
var.deathsight =
var.waterwalk =
var.wings =
var.halo =
var.cloak =
var.timeslip =
var.thirdeye =
var.firepotion =
var.frostpotion =
var.quickening =
var.stigmata =
var.vitae =
var.mercy =
var.kingdom =
var.perfection =
var.beauty =
var.levitate =
--@Utility@
var.target =
var.attack =
var.restarget =
--@Afflictions@
var.prone =
var.anorexia =
var.slickness =
var.hypochondria =
var.impatient =
var.stupidity =
var.slitthroat =
var.asthma =
--**********VARIABLES**********
--@Balances@
var.potionbalance = 1
var.equilibrium = 1
var.balance = 1
var.sparklebalance = 1
var.healingscrollbalance = 1
var.herbbalance = 1
var.salvebalance = 1
var.purgativebalance = 1
var.focusbalance = 1
var.allhealebalance = 1
var.writhebalance = 1
var.rightarmbalance = 1
var.leftarmbalance = 1
var.pickupbalance = 1
--@Tracking@
var.tonextlevel =
var.levelname =
var.health =
var.maxhealth =
var.endurance =
var.maxendurance =
var.mana =
var.max_mana =
var.willpower =
var.maxwillpower =
var.ego =
var.maxego =
var.power =Â Â
var.reserves =
var.karma =
var.esteem =
var.promptstring =
--@Defs@
var.sixthsense =
var.kafe =
var.nightsight =
var.yesod =
var.malkuth =
var.insomnia =
var.deathsight =
var.waterwalk =
var.wings =
var.halo =
var.cloak =
var.timeslip =
var.thirdeye =
var.firepotion =
var.frostpotion =
var.quickening =
var.stigmata =
var.vitae =
var.mercy =
var.kingdom =
var.perfection =
var.beauty =
var.levitate =
--@Utility@
var.target =
var.attack =
var.restarget =
--@Afflictions@
var.prone =
var.anorexia =
var.slickness =
var.hypochondria =
var.impatient =
var.stupidity =
var.slitthroat =
var.asthma =
I fail to see what is wrong here... maybe I am just not knowing what to look for, or how it is counting lines... var.health is the 24th line from the top though, and it looks like all of my other vars.
And for some reason, the shortcut ctrl+shift+F12 does not work for me... I still do not notice a trigger test ability under the triggers menu either.
Unknown2007-05-16 20:40:51
I'm going to guess that this block:
Is all being strung together. So, you get var.tonextlevel = var.levelname (so far, so good) = var.health (bad).
Try putting some value in those lines for those vars and see if it clears the error up.
As for the trigger test, I'll try to remember to look for it when I get home.
CODE
var.tonextlevel =
var.levelname =
var.health =
... so on
var.levelname =
var.health =
... so on
Is all being strung together. So, you get var.tonextlevel = var.levelname (so far, so good) = var.health (bad).
Try putting some value in those lines for those vars and see if it clears the error up.
As for the trigger test, I'll try to remember to look for it when I get home.
Simimi2007-05-16 21:13:27
Ahh ok well that fixed it, and the next two issues... apparantly I do not use var.foo but just foo = bar
Well after going through a list of problems which I subsequently found fixes for... I have run into a big one. After working on this one for the last few hours; I am officially stumped.
If you want to see what I have, you can see it at www.icitan.net/lusternia
In the script I have a variable, called "waterwalk" which is false, such that:
I have a two triggers, both of which do the same thing
I fail to see why these triggers do not change the variables, like, when one of the things trigger, I open the script editor, and the waterwalk is still = false.
D:
Well after going through a list of problems which I subsequently found fixes for... I have run into a big one. After working on this one for the last few hours; I am officially stumped.
If you want to see what I have, you can see it at www.icitan.net/lusternia
In the script I have a variable, called "waterwalk" which is false, such that:
CODE
waterwalk = false
I have a two triggers, both of which do the same thing
CODE
trigger: ^You can walk upon water\\.$
send: waterwalk = true
sendto: script
send: waterwalk = true
sendto: script
CODE
trigger: ^You pull a cosmic web down around your feet,
send: waterwalk = true
sendto: script
send: waterwalk = true
sendto: script
I fail to see why these triggers do not change the variables, like, when one of the things trigger, I open the script editor, and the waterwalk is still = false.
D:
Unknown2007-05-17 06:34:25
You sure you can't just fork up the 28 bucks for Palisade?
Unknown2007-05-17 14:07:19
Again, I don't speak Lua, but it looks to me like you need to use the: SetVariable ("waterwalk", "true") syntax. The other (and better) option seems to be to use the var table, and the var.waterwalk = true syntax, but for that you need to have the contents of the var.lua file in your script file. This file should be in your MUSHclient > lua directory; just copy and paste its contents at the very end of your script file. Either of those worked for me. (Haven't quite figured out what waterwalk = true does, but it doesn't do what you're hoping it does.)
Money's not the point, or it clearly wouldn't be worth the time invested. Some people find doing a little coding fun, and you certainly have a better understanding of how your system works and what its limitations are.
QUOTE(Soraka @ May 17 2007, 07:34 AM) 408907
You sure you can't just fork up the 28 bucks for Palisade?
Money's not the point, or it clearly wouldn't be worth the time invested. Some people find doing a little coding fun, and you certainly have a better understanding of how your system works and what its limitations are.
Simimi2007-05-17 16:44:21
My understanding is that SetVariable only affects the mush client variables, not the internal script ones, Nick replied to my mush client forums post...
http://www.gammon.com.au/forum/bbshowpost.php
I hope I understand his reply... >_<
waterwalk = true is supposed to set the script variable "waterwalk" to "true" as in, I have it. Eventually that would play a role in a defup script, once I remember what that command to do it was (I swear it was like Case, or Count, or something...).
Soraka, I would gladly pay for Palisade, since, it is apparent to me that Zarquan has mad excellent skills, the likes of which I do not have. BUT, at the same time, I want to learn to make a mud system, since, people like Vale_Kant and Zarquan AND DEMETRIOS will not always be there to code a system and hold my hand. Plus, it is kinda fun, when it works.
Anyway, I will apparently have to convert everything to mush client variables, and use the SetVariable blah stuff to make them change, while using scripts in my script file for things like curing priority and whatnot... essentially meaning I am recoding what Ethelon did eons ago... ;_;
http://www.gammon.com.au/forum/bbshowpost.php
I hope I understand his reply... >_<
waterwalk = true is supposed to set the script variable "waterwalk" to "true" as in, I have it. Eventually that would play a role in a defup script, once I remember what that
Soraka, I would gladly pay for Palisade, since, it is apparent to me that Zarquan has mad excellent skills, the likes of which I do not have. BUT, at the same time, I want to learn to make a mud system, since, people like Vale_Kant and Zarquan AND DEMETRIOS will not always be there to code a system and hold my hand. Plus, it is kinda fun, when it works.
Anyway, I will apparently have to convert everything to mush client variables, and use the SetVariable blah stuff to make them change, while using scripts in my script file for things like curing priority and whatnot... essentially meaning I am recoding what Ethelon did eons ago... ;_;
Unknown2007-05-17 16:56:51
Just using "waterwalk = true" will set a Lua script variable, which is different from a MUSHclient world variable. As I explained with my initial code sample, I use Nick's "var" module (installed under the MUSHclient program directory) to access the world variables easily in Lua. You really only need to use world variables for things that persist from one session to the next, not the temp stuff (like defenses or afflictions that reset when you log off).
Plus, Palisade is for zMUD, not MUSHclient.
Plus, Palisade is for zMUD, not MUSHclient.
Simimi2007-05-17 17:01:14
So then, by using the var module, it lets me change the script variables with triggers like "You have died" Send To Script. var.died = "true" ?
Bah this is all very confusing... How will I debug later on if the variables in the script do not -really- change? They are just understood to be changed?
Bah this is all very confusing... How will I debug later on if the variables in the script do not -really- change? They are just understood to be changed?
Unknown2007-05-17 17:10:40
Debugging is something everyone does differently, but I like to put echo messages in key functions to print out what's called with what values.
If you use Nick's var module, as described on the MUSHclient forums, using var.died = 1 would set the MUSHclient world variable (visible on your world properties dialog) to 1. You can then refer to this same variable in your script expressions using var.died (e.g., if var.died then print("You're dead!") end).
Since MUSHclient lacks the pretty GUI buttons and things that many people setup in zMUD, you'll need to make aliases that print out your variables in useful ways, show a list of afflictions or a summary of potions, etc. This will also help you debug your scripts.
There are many neat tricks you could use in Lua, such as the var table does to access world variables. Check the MUSHclient Lua forum for some helpful tips and tricks. (It's easy to get confused if you're still new to the whole programming scene, though. Just stick with it, and you'll figure it out!)
If you use Nick's var module, as described on the MUSHclient forums, using var.died = 1 would set the MUSHclient world variable (visible on your world properties dialog) to 1. You can then refer to this same variable in your script expressions using var.died (e.g., if var.died then print("You're dead!") end).
Since MUSHclient lacks the pretty GUI buttons and things that many people setup in zMUD, you'll need to make aliases that print out your variables in useful ways, show a list of afflictions or a summary of potions, etc. This will also help you debug your scripts.
There are many neat tricks you could use in Lua, such as the var table does to access world variables. Check the MUSHclient Lua forum for some helpful tips and tricks. (It's easy to get confused if you're still new to the whole programming scene, though. Just stick with it, and you'll figure it out!)
Unknown2007-05-17 17:18:48
Just to kind of ride on Zarquan's coattails and make sure it's clear which variables are being changed where by what:
1) MUSH variables are the ones defined in the UI (or the XML file, to be specific). These variables are changed in one of two ways:
SetVariable("myvariablename", "1")
or, if you're using the var module:
var.myvariablename = "1"
In either case, changes to those variables should be visible in the GUI and will save to the XML file if you save it.
2) Variables defined entirely in script are only changed by having an actual script line put a new value in there, like so:
myvariablename = "1"
This is actually done as a line in your script -or- (and I didn't realize this until looking at your post, although it should have been obvious) sending the line:
myvariablename = "1"
to script via a Send to: Script operation in your trigger or alias.
Regardless of how a script variable's value is changed, the changed value will not actually alter your script file and what you see there. The only way to know what a script variable's value is -right this second- is to display it or some such.
Hope that helps, even though you didn't mention me along with Zarquan and Vale Kant, above. I understand, though.
1) MUSH variables are the ones defined in the UI (or the XML file, to be specific). These variables are changed in one of two ways:
SetVariable("myvariablename", "1")
or, if you're using the var module:
var.myvariablename = "1"
In either case, changes to those variables should be visible in the GUI and will save to the XML file if you save it.
2) Variables defined entirely in script are only changed by having an actual script line put a new value in there, like so:
myvariablename = "1"
This is actually done as a line in your script -or- (and I didn't realize this until looking at your post, although it should have been obvious) sending the line:
myvariablename = "1"
to script via a Send to: Script operation in your trigger or alias.
Regardless of how a script variable's value is changed, the changed value will not actually alter your script file and what you see there. The only way to know what a script variable's value is -right this second- is to display it or some such.
Hope that helps, even though you didn't mention me along with Zarquan and Vale Kant, above. I understand, though.
Simimi2007-05-17 17:32:10
Is this the var table thing you are talking about, Zarquan?
http://www.gammon.com.au/forum/?id=4904
If so, I would like to give it a try, assuming I can understand it all... I thought by a variable table he meant like
OMG I AM SO SORRY DEMETRIOS!!!!! I PROMISE I MEANT NO DISRESPECT IT IS JUST THAT I SCANNED UP THE PAGE AND....PLEASE FORGIVE ME AND DO NOT WITHDRAW YOUR VALUABLE AIDE FROM MEEEE ;_;
http://www.gammon.com.au/forum/?id=4904
If so, I would like to give it a try, assuming I can understand it all... I thought by a variable table he meant like
CODE
var {}
{name = "waterwalk", state = "false"}
}
so then I can use var.waterwalk = true, to set it...?
{name = "waterwalk", state = "false"}
}
so then I can use var.waterwalk = true, to set it...?
OMG I AM SO SORRY DEMETRIOS!!!!! I PROMISE I MEANT NO DISRESPECT IT IS JUST THAT I SCANNED UP THE PAGE AND....PLEASE FORGIVE ME AND DO NOT WITHDRAW YOUR VALUABLE AIDE FROM MEEEE ;_;
Unknown2007-05-17 17:51:30
QUOTE(Simimi @ May 17 2007, 12:32 PM) 409070
Is this the var table thing you are talking about, Zarquan?
http://www.gammon.com.au/forum/?id=4904
If so, I would like to give it a try, assuming I can understand it all... I thought by a variable table he meant like
http://www.gammon.com.au/forum/?id=4904
If so, I would like to give it a try, assuming I can understand it all... I thought by a variable table he meant like
CODE
var {}
{name = "waterwalk", state = "false"}
}
so then I can use var.waterwalk = true, to set it...?
{name = "waterwalk", state = "false"}
}
so then I can use var.waterwalk = true, to set it...?
That post is what he's talking about, but your code sample there is something different.
1) You can use tables to hold variable data, which is what you're doing in your snippet up there.
2) You can use a metatable to interface between your script and your MUSH variables, which is what the link above is describing.
In order to do 2, you need Nick's actual code in your script file, namely:
CODE
var = {}Â Â Â Â -- variables table
setmetatable (var,
{
-- called to access an entry
__index =
function (t, name)
  return GetVariable (name)
end;
-- called to change or delete an entry
__newindex =
function (t, name, val)
local result
  if val == nil then    -- nil deletes it
    result = DeleteVariable (name)
  else
    result = SetVariable (name, tostring (val))
  end
  -- warn if they are using bad variable names
  if result == error_code.eInvalidObjectLabel then
    error ("Bad variable name '" .. name .. "'")
  end
end;
})
setmetatable (var,
{
-- called to access an entry
__index =
function (t, name)
  return GetVariable (name)
end;
-- called to change or delete an entry
__newindex =
function (t, name, val)
local result
  if val == nil then    -- nil deletes it
    result = DeleteVariable (name)
  else
    result = SetVariable (name, tostring (val))
  end
  -- warn if they are using bad variable names
  if result == error_code.eInvalidObjectLabel then
    error ("Bad variable name '" .. name .. "'")
  end
end;
})
This will allow you to access your MUSH-defined variables with the syntax:
var.whatevermyvariablenameis = whatever
That thread also suggests some improvements, including one by Zarquan, that I use.
Keep in mind that, if you use Nick's script, you should NOT create your own tables named "var," but that should be used solely to access your MUSH variables (I actually call my metatable MUSHVars instead of var, just for clarity, and change them with: MUSHVars.Balance = 1 and such).
QUOTE
OMG I AM SO SORRY DEMETRIOS!!!!! I PROMISE I MEANT NO DISRESPECT IT IS JUST THAT I SCANNED UP THE PAGE AND....PLEASE FORGIVE ME AND DO NOT WITHDRAW YOUR VALUABLE AIDE FROM MEEEE ;_;
ROFL!
All right, you convinced me.
Unknown2007-05-17 18:10:18
Yup! You got it! I think Demetrios gave a very good explanation of the differences and usefulness already, too.
There are other things you might want to use tables for in Lua, such as tracking what vials hold which potions or which players have a shield up, but some of those are more advanced and can be saved for later. A more practical example might be to have a table with all afflictions curable by salves and what salve cures them, which you could use for healing salve-cured afflictions in a function, maybe:
Lookup tables like this can be very useful when used properly in other functions. Remember, however, that the order you add things into a table doesn't mean they'll stay in that order. (I actually use a Lua script I found, called phpTable, that keeps them in the order they're added, so I could use this as a priority order for curing.)
There are other things you might want to use tables for in Lua, such as tracking what vials hold which potions or which players have a shield up, but some of those are more advanced and can be saved for later. A more practical example might be to have a table with all afflictions curable by salves and what salve cures them, which you could use for healing salve-cured afflictions in a function, maybe:
CODE
salve_affs = {}
salve_affs = "apply melancholic to chest"
salve_affs = "apply regeneration to head"
salve_affs = "apply mending to head"
salve_affs = "apply regeneration to gut"
salve_affs = "apply regeneration to gut"
salve_affs = "apply regeneration to chest"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to chest"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to arms"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to head"
salve_affs = "apply mending to head"
salve_affs = "apply regeneration to gut"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to legs"
salve_affs = "apply mending to arms"
salve_affs = "apply mending to legs"
salve_affs = "apply melancholic to chest"
salve_affs = "apply melancholic to head"
salve_affs = "apply melancholic to chest"
salve_affs = "apply regeneration to gut"
salve_affs = "apply regeneration to head"
salve_affs = "apply mending to head"
salve_affs = "apply regeneration to arms"
salve_affs = "apply mending to arms"
salve_affs = "apply liniment"
salve_affs = "apply liniment"
salve_affs = "apply liniment"
salve_affs = "apply liniment"
salve_affs = "apply melancholic to head"
salve_affs = "apply melancholic to head"
salve_affs = "apply regeneration to arms"
salve_affs = "apply regeneration to arms"
salve_affs = "apply regeneration to head"
salve_affs = "apply regeneration to head"
salve_affs = "apply melancholic to chest"
salve_affs = "apply regeneration to head"
salve_affs = "apply mending to head"
salve_affs = "apply regeneration to gut"
salve_affs = "apply regeneration to gut"
salve_affs = "apply regeneration to chest"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to chest"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to arms"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to head"
salve_affs = "apply mending to head"
salve_affs = "apply regeneration to gut"
salve_affs = "apply regeneration to legs"
salve_affs = "apply regeneration to legs"
salve_affs = "apply mending to arms"
salve_affs = "apply mending to legs"
salve_affs = "apply melancholic to chest"
salve_affs = "apply melancholic to head"
salve_affs = "apply melancholic to chest"
salve_affs = "apply regeneration to gut"
salve_affs = "apply regeneration to head"
salve_affs = "apply mending to head"
salve_affs = "apply regeneration to arms"
salve_affs = "apply mending to arms"
salve_affs = "apply liniment"
salve_affs = "apply liniment"
salve_affs = "apply liniment"
salve_affs = "apply liniment"
salve_affs = "apply melancholic to head"
salve_affs = "apply melancholic to head"
salve_affs = "apply regeneration to arms"
salve_affs = "apply regeneration to arms"
salve_affs = "apply regeneration to head"
salve_affs = "apply regeneration to head"
Lookup tables like this can be very useful when used properly in other functions. Remember, however, that the order you add things into a table doesn't mean they'll stay in that order. (I actually use a Lua script I found, called phpTable, that keeps them in the order they're added, so I could use this as a priority order for curing.)
Simimi2007-05-17 19:44:23
Well after doing some reading, I think I understand now. All of my previous problems must have been because I did not have Nick's thing loaded... but now >_>
I get this error from Mush:
But! This is the script itself...
You can clearly see Nick's module on the last part there... AND, I went ahead and created all of those variables by hand inside Mush client... Specifically the 6th line variable is...
true
Much confusion I have... it seems like just when I think I have something down and can move on, something new crops up to bite me in the bum. It's all good though, I won't be beaten!
EDIT: And the Syntax passed the check in LuaEdit windows IDE...
I get this error from Mush:
CODE
Run-time error
World: lusternia
Immediate execution
:6: attempt to index global 'var' (a nil value)
stack traceback:
        :6: in main chunk
World: lusternia
Immediate execution
:6: attempt to index global 'var' (a nil value)
stack traceback:
        :6: in main chunk
But! This is the script itself...
CODE
--Simimi System Version 0.3
--**********VARIABLES**********
--@Balances@
var.potionbalance = true
var.equilibrium = true
var.balance = true
var.sparklebalance = true
var.healingscrollbalance = true
var.herbbalance = true
var.salvebalance = true
var.purgativebalance = true
var.focusbalance = true
var.allhealebalance = true
var.writhebalance = true
var.rightarmbalance = true
var.leftarmbalance = true
var.pickupbalance = true
--@Tracking@
var.health = 20
var.maxhealth = 1000
var.endurance = 1005
var.maxendurance = 3800
var.mana = 10
var.maxmana = 1090
var.willpower = 13
var.maxwillpower = 1452
var.ego = 12
var.maxego = 1249
var.power = 1
var.reserves = 9
var.karma = 1
var.esteem = 1
var.promptstring = 1
--@Utility@
var.attack = "cast blast"
var.target = gnome
var.rest = james
--@Defs@
var.sixthsense = false
var.kafe = false
var.nightsight = false
var.yesod = false
var.malkuth = false
var.insomnia = false
var.deathsight = false
var.waterwalk = false
var.wings = false
var.halo = false
var.cloak = false
var.timeslip = false
var.thirdeye = false
var.firepotion = false
var.frostpotion = false
var.quickening = false
var.stigmata = false
var.vitae = false
var.mercy = false
var.kingdom = false
var.perfection = false
var.beauty = false
var.levitate = false
--@Afflictions@
var.prone = false
var.anorexia = false
var.slickness= false
var.hypochondria = false
var.impatient = false
var.stupidity = false
var.slitthroat = false
var.asthma = false
--**********TABLES********** !make a coltsfootpipe alias!
afflictions_herbs = {
{name = "anorexia", cure = coltsfootpipe, state = false },
{name = "slickness", cure = "calamus", state = false },
{name = "hypochondria", cure = "wormwood", state = false },
{name = "impatient", cure = coltsfootpipe, state = false },
{name = "stupidity", cure = "pennyroyal", state = false }
}
--@THEORETICAL FUNCTION TO GO THROUGH afflictions_herbs@
function cureafflictions_herbs ()
    for key, value in afflictions_herbs do
        if v.state == true then
            Send ("outr " .. v.cure)
            Send ("eat " .. v.cure)
        break
        end
    end
end;
afflictions_salves = {
{name = "slitthroat", cure = "apply mending to head", state = false},
{name = "asthma", cure = "apply melancholic to chest", state = false},
}
--**********FUNCTIONS**********
--*Promptcheck
function promptcheck()
  if string.find (var.promptstring, "") then
    var.equilibrium = true
  else
    var.equilibrium = false
  end
  if string.find (var.promptstring, "") then
    var.balance = true
  else
    var.balance = false
  end
-- Probably want to do something here with a precursor trigger
-- to see what sort of prone the "p" might be (impaled, entangled,
-- etc) and then track that.
-- if string.find (var.promptstring, "") then
  -- var.prone = true
  --else
    --var.prone = false
  --end
  if string.find (var.promptstring, "") then
    var.blindness = true
  else
    var.blindness = false
  end
  if string.find (var.promptstring, "")  then
    var.leftarmbalance = true
  else
    var.leftarmbalance = false
  end
  if string.find (var.promptstring, "") then
    var.rightarmbalance = true
  else
    var.rightarmbalance = false
  end
  if string.find (var.promptstring, "") then
    var.kafe = true
  else
    var.kafe = false
  end
  if string.find (var.promptstring, "") then
    var.deaf = true
  else
    var.deaf = false
  end
end;
--*Autosipper
function autosipper ()
if var.potionbalance == true then
    end
    if var.health <= (.50 * var.maxhealth) then
        Send ("drink health")
    --elseif --really bad deepwounds stuffs here, no idea what the lines and such for those are...or how to handle them, or what deepwounds --are even...
        --Send ("apply health to --wounded spot")
    elseif var.mana <= (.50 * var.maxmana) then
        Send ("drink mana")
    elseif var.ego <= (.50 * var.maxego) then
        Send ("drink mana")
    --elseif --more deepwounds stuff once I learn about it
        --Send ("deepwounds cure stuffs")
    elseif var.health <= (.65 * var.maxhealth) then
        Send ("drink health")
    elseif var.mana <= (.65 * var.maxmana) then
        Send ("drink mana")
    elseif var.ego <= (.65 * var.maxego) then
        Send ("drink ego")
    --elseif .. --less bad deepwounds stuffs here
        --Send ("lessbad deepwounds stuffs")
    elseif var.health <= (.80 * var.maxhealth) then
        Send ("drink health")
    elseif var.mana <= (.80 * var.maxmana) then
        Send ("drink mana")
    elseif var.ego <= (.80 * var.maxego) then
        Send ("drink ego")
    end
       Â
end;
--********Nick's VAR Table Thingy**********
var = {}Â Â -- variables table
setmetatable (var,
{
-- called to access an entry
__index =
function (t, name)
  return GetVariable (name)
end,
-- called to change or delete an entry
__newindex =
function (t, name, val)
local result
  if val == nil then -- nil deletes it
    result = DeleteVariable (name)
  else
    result = SetVariable (name, tostring (val))
  end
  -- warn if they are using bad variable names
  if result == error_code.eInvalidObjectLabel then
    error ("Bad variable name '" .. name .. "'", 2)
  end
end
})
return var
--**********VARIABLES**********
--@Balances@
var.potionbalance = true
var.equilibrium = true
var.balance = true
var.sparklebalance = true
var.healingscrollbalance = true
var.herbbalance = true
var.salvebalance = true
var.purgativebalance = true
var.focusbalance = true
var.allhealebalance = true
var.writhebalance = true
var.rightarmbalance = true
var.leftarmbalance = true
var.pickupbalance = true
--@Tracking@
var.health = 20
var.maxhealth = 1000
var.endurance = 1005
var.maxendurance = 3800
var.mana = 10
var.maxmana = 1090
var.willpower = 13
var.maxwillpower = 1452
var.ego = 12
var.maxego = 1249
var.power = 1
var.reserves = 9
var.karma = 1
var.esteem = 1
var.promptstring = 1
--@Utility@
var.attack = "cast blast"
var.target = gnome
var.rest = james
--@Defs@
var.sixthsense = false
var.kafe = false
var.nightsight = false
var.yesod = false
var.malkuth = false
var.insomnia = false
var.deathsight = false
var.waterwalk = false
var.wings = false
var.halo = false
var.cloak = false
var.timeslip = false
var.thirdeye = false
var.firepotion = false
var.frostpotion = false
var.quickening = false
var.stigmata = false
var.vitae = false
var.mercy = false
var.kingdom = false
var.perfection = false
var.beauty = false
var.levitate = false
--@Afflictions@
var.prone = false
var.anorexia = false
var.slickness= false
var.hypochondria = false
var.impatient = false
var.stupidity = false
var.slitthroat = false
var.asthma = false
--**********TABLES********** !make a coltsfootpipe alias!
afflictions_herbs = {
{name = "anorexia", cure = coltsfootpipe, state = false },
{name = "slickness", cure = "calamus", state = false },
{name = "hypochondria", cure = "wormwood", state = false },
{name = "impatient", cure = coltsfootpipe, state = false },
{name = "stupidity", cure = "pennyroyal", state = false }
}
--@THEORETICAL FUNCTION TO GO THROUGH afflictions_herbs@
function cureafflictions_herbs ()
    for key, value in afflictions_herbs do
        if v.state == true then
            Send ("outr " .. v.cure)
            Send ("eat " .. v.cure)
        break
        end
    end
end;
afflictions_salves = {
{name = "slitthroat", cure = "apply mending to head", state = false},
{name = "asthma", cure = "apply melancholic to chest", state = false},
}
--**********FUNCTIONS**********
--*Promptcheck
function promptcheck()
  if string.find (var.promptstring, "") then
    var.equilibrium = true
  else
    var.equilibrium = false
  end
  if string.find (var.promptstring, "") then
    var.balance = true
  else
    var.balance = false
  end
-- Probably want to do something here with a precursor trigger
-- to see what sort of prone the "p" might be (impaled, entangled,
-- etc) and then track that.
-- if string.find (var.promptstring, "") then
  -- var.prone = true
  --else
    --var.prone = false
  --end
  if string.find (var.promptstring, "") then
    var.blindness = true
  else
    var.blindness = false
  end
  if string.find (var.promptstring, "")  then
    var.leftarmbalance = true
  else
    var.leftarmbalance = false
  end
  if string.find (var.promptstring, "") then
    var.rightarmbalance = true
  else
    var.rightarmbalance = false
  end
  if string.find (var.promptstring, "") then
    var.kafe = true
  else
    var.kafe = false
  end
  if string.find (var.promptstring, "") then
    var.deaf = true
  else
    var.deaf = false
  end
end;
--*Autosipper
function autosipper ()
if var.potionbalance == true then
    end
    if var.health <= (.50 * var.maxhealth) then
        Send ("drink health")
    --elseif --really bad deepwounds stuffs here, no idea what the lines and such for those are...or how to handle them, or what deepwounds --are even...
        --Send ("apply health to --wounded spot")
    elseif var.mana <= (.50 * var.maxmana) then
        Send ("drink mana")
    elseif var.ego <= (.50 * var.maxego) then
        Send ("drink mana")
    --elseif --more deepwounds stuff once I learn about it
        --Send ("deepwounds cure stuffs")
    elseif var.health <= (.65 * var.maxhealth) then
        Send ("drink health")
    elseif var.mana <= (.65 * var.maxmana) then
        Send ("drink mana")
    elseif var.ego <= (.65 * var.maxego) then
        Send ("drink ego")
    --elseif .. --less bad deepwounds stuffs here
        --Send ("lessbad deepwounds stuffs")
    elseif var.health <= (.80 * var.maxhealth) then
        Send ("drink health")
    elseif var.mana <= (.80 * var.maxmana) then
        Send ("drink mana")
    elseif var.ego <= (.80 * var.maxego) then
        Send ("drink ego")
    end
       Â
end;
--********Nick's VAR Table Thingy**********
var = {}Â Â -- variables table
setmetatable (var,
{
-- called to access an entry
__index =
function (t, name)
  return GetVariable (name)
end,
-- called to change or delete an entry
__newindex =
function (t, name, val)
local result
  if val == nil then -- nil deletes it
    result = DeleteVariable (name)
  else
    result = SetVariable (name, tostring (val))
  end
  -- warn if they are using bad variable names
  if result == error_code.eInvalidObjectLabel then
    error ("Bad variable name '" .. name .. "'", 2)
  end
end
})
return var
You can clearly see Nick's module on the last part there... AND, I went ahead and created all of those variables by hand inside Mush client... Specifically the 6th line variable is...
CODE
Much confusion I have... it seems like just when I think I have something down and can move on, something new crops up to bite me in the bum. It's all good though, I won't be beaten!
EDIT: And the Syntax passed the check in LuaEdit windows IDE...
Unknown2007-05-17 19:54:51
Put Nick's stuff first.
Unknown2007-05-17 19:56:36
Also (sorry for the double post, but I see you've already read the last one), there's no "return var" line.
Simimi2007-05-17 19:59:05
If that is the answer to it, I'm going to cry if it is something so retardedly simple... let me try it
Ok, after seeing your "there is no return var" thing, I removed it... and zomg it WORKS! So far, I can change my variables on command and what not!!
Now then... Can you maybe try to explain to me how Zarquan's salves afflictions table is different than mine in the above script? If his is more effeicient I will gladly convert my things... right now I have my afflicts as var.affliction, and the triggers set that var.affliction to true/false.
Ok, after seeing your "there is no return var" thing, I removed it... and zomg it WORKS! So far, I can change my variables on command and what not!!
Now then... Can you maybe try to explain to me how Zarquan's salves afflictions table is different than mine in the above script? If his is more effeicient I will gladly convert my things... right now I have my afflicts as var.affliction, and the triggers set that var.affliction to true/false.
Unknown2007-05-17 20:01:55
EDIT: Confusing time reply-response warp.
Simimi2007-05-17 20:04:30
Done and Done, and I just edited the above post
Unknown2007-05-17 20:15:33
QUOTE(Simimi @ May 17 2007, 02:59 PM) 409174
Now then... Can you maybe try to explain to me how Zarquan's salves afflictions table is different than mine in the above script? If his is more effeicient I will gladly convert my things... right now I have my afflicts as var.affliction, and the triggers set that var.affliction to true/false.
Zarquan will have a better explanation, but there is no real difference between his salves table and your afflictions_herbs table. The only difference being that the way you've constructed afflictions_herbs, the entries should be produced in that order, which will allow you to set priorities.
However, it looks like you're also using flag variables to determine if you have a particular affliction or not (var.anorexia, for instance), and there's nothing particularly wrong with that, but you don't need to.
This is the part where I've gone back and forth on the best way to do things, and I don't think there's a lot of difference since MUSHClient can read thousands of table lines in milliseconds, but the two main ways to do this are:
1) Use flag variables to say yea or nay if you have an affliction.
2) Use a table to store current afflictions.
I'm actually working on a third method, where I have one ginormous table that stores most of my afflictions and has fields like "salve_cure," "herb_cure," etc. for each one rather than having a salve table, an herb table, etc. This will -allow- me to also set a flag in that same table as to whether or not I have the affliction.
The main disadvantage is that I'm going through the entire table every single time, rather than being able to only scan certain tables (no need to scan herb_cures if I don't have herb balance or don't have an affliction that is herb curable). The main advantage is that I don't have to cross-reference tables.
There are a handful of afflictions that don't fit nicely and neatly into a table-based method, but you just handle those differently.