Simimi2007-07-16 19:28:14
Well here we are again !
I have moved everything to script variables in my system except for balance. I keep creating internal script errors while trying to solve the same 3 problems, I'm hoping someone here sees something that me and requiem and gray are not seeing.
Ok so I have an 3 empty tables.
affs stores my current afflictions, defs stores current defs, and bal is supposed to store current balances.
Well I noticed that triggering the defense lines to put or remove things from the table works well, except when I log out and log back in, I still have all of my defs, when I do not really have the. For each table I have aliases to print what is in them, such that;
That works fine, since an affliction in the table is only ever true, or nil and thus not in the table...
The same alias works just fine for defs, except that I can not seem to clear the table, like when I die or am thrown from the arena.
But on to Balances. I have lots of balances, not just herb and potion. I have curse balance, quickening balance, magic tome balance, etc etc etc. I was goign through an old thread of mine where I cam across Demetrios post about using a function like
I wanted to use something like that in my system so I could just pass balance to the check function as needed, so I could do, say, for herb curing:
so when I run herb curing it can check for
so that it check if I have herb balance before doing anything.
One of the problems now is that my promptcatch function is not putting balance variables into the table...
And so on and so forth. the only way to know what is in one of these script tables that I know of is to print to myself what is in it. I decided to use the same above function that works for defs and affs:
It returns nothing, leading me to believe I have no balances that are true... all of my balance triggers set the thing in the bal table to true (bal.equilibrium = true) for example. That syntax works with the affs and defs tables, why not the bal tables?
I hope this makes some sense...
I have moved everything to script variables in my system except for balance. I keep creating internal script errors while trying to solve the same 3 problems, I'm hoping someone here sees something that me and requiem and gray are not seeing.
Ok so I have an 3 empty tables.
CODE
affs = {}
defs = {}
bal = {}
defs = {}
bal = {}
affs stores my current afflictions, defs stores current defs, and bal is supposed to store current balances.
Well I noticed that triggering the defense lines to put or remove things from the table works well, except when I log out and log back in, I still have all of my defs, when I do not really have the. For each table I have aliases to print what is in them, such that;
CODE
for k,v in pairs(affs) do
  if v == true then
    print(k)
  end
end
  if v == true then
    print(k)
  end
end
That works fine, since an affliction in the table is only ever true, or nil and thus not in the table...
The same alias works just fine for defs, except that I can not seem to clear the table, like when I die or am thrown from the arena.
But on to Balances. I have lots of balances, not just herb and potion. I have curse balance, quickening balance, magic tome balance, etc etc etc. I was goign through an old thread of mine where I cam across Demetrios post about using a function like
CODE
function HaveBalance(balance)
  if GetVariable(balance .. "balance") = 1 then
    return true
  else
    return false
  end
end
  if GetVariable(balance .. "balance") = 1 then
    return true
  else
    return false
  end
end
I wanted to use something like that in my system so I could just pass balance to the check function as needed, so I could do, say, for herb curing:
CODE
function balancecheck(balance)
for k,v in pairs(bal) do
  if v == true then
  return true
  else
  return false
  end
end
for k,v in pairs(bal) do
  if v == true then
  return true
  else
  return false
  end
end
so when I run herb curing it can check for
CODE
if balancecheck("herb")
so that it check if I have herb balance before doing anything.
One of the problems now is that my promptcatch function is not putting balance variables into the table...
CODE
function promptcheck()
  if string.find (var.promptstring, "") then
    bal.equilibrium = true
  else
    bal.equilibrium = false
  end
  if string.find (var.promptstring, "") then
    bal.balance = true
  else
    bal.balance = false
  end
  if string.find (var.promptstring, "") then
    bal.equilibrium = true
  else
    bal.equilibrium = false
  end
  if string.find (var.promptstring, "") then
    bal.balance = true
  else
    bal.balance = false
  end
And so on and so forth. the only way to know what is in one of these script tables that I know of is to print to myself what is in it. I decided to use the same above function that works for defs and affs:
CODE
for k,v in pairs(bal) do
  if v == true then
    print(k)
  end
end
  if v == true then
    print(k)
  end
end
It returns nothing, leading me to believe I have no balances that are true... all of my balance triggers set the thing in the bal table to true (bal.equilibrium = true) for example. That syntax works with the affs and defs tables, why not the bal tables?
I hope this makes some sense...
Simimi2007-07-16 19:48:52
Ok well I fixed the balance not showing me if I have balance, the problem now is...
When i log in, it shows I have no balances until it gets a new balance message... is there a way to remedy this so it tracks balance or assume I have it unless told otherwise?
When i log in, it shows I have no balances until it gets a new balance message... is there a way to remedy this so it tracks balance or assume I have it unless told otherwise?
Forren2007-07-16 20:10:29
QUOTE(Simimi @ Jul 16 2007, 03:48 PM) 426304
Ok well I fixed the balance not showing me if I have balance, the problem now is...
When i log in, it shows I have no balances until it gets a new balance message... is there a way to remedy this so it tracks balance or assume I have it unless told otherwise?
When i log in, it shows I have no balances until it gets a new balance message... is there a way to remedy this so it tracks balance or assume I have it unless told otherwise?
Are you tracking off of the prompt? If x is in the prompt characters following the normal health/mana/ego/endurance/wp, you have balance.
Simimi2007-07-16 20:21:23
I thought I was, but recent testing showed my tracking off the prompt is not working... here is what I have...
The promptcheck function runs as follows...
the mush variable promptstring (since I have not figured out how to store my prompt as a scriptside variable...) for some reason is set to 1 or nothing, and not letters...
EDIT: Health and mana and such is tracked accordingly, but the letters do not seem to be...
CODE
^(\\d+)h\\, (\\d+)m\\, (\\d+)e\\, (\\d+)p\\, (\\d+)en\\, (\\d+)w\\ (.*)\\-$
which does:
var.health = "%1"
var.mana = "%2"
var.ego = "%3"
var.power = "%4"
var.endurance = "%5"
var.willpower = "%6"
var.promptstring = "%7"
promptcheck()
which does:
var.health = "%1"
var.mana = "%2"
var.ego = "%3"
var.power = "%4"
var.endurance = "%5"
var.willpower = "%6"
var.promptstring = "%7"
promptcheck()
The promptcheck function runs as follows...
CODE
function promptcheck()
  if string.find (var.promptstring, "") then
    bal.equilibrium = true
  else
    bal.equilibrium = false
  end
  if string.find (var.promptstring, "") then
    bal.balance = true
  else
    bal.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
    bal.leftarmbalance = true
  else
    bal.leftarmbalance = false
  end
  if string.find (var.promptstring, "") then
    bal.rightarmbalance = true
  else
    bal.rightarmbalance = false
  end
  if string.find (var.promptstring, "") then
    def.kafe = true
  else
    def.kafe = false
  end
  if string.find (var.promptstring, "") then
    def.deaf = true
  else
    def.deaf = false
  end
end;
  if string.find (var.promptstring, "") then
    bal.equilibrium = true
  else
    bal.equilibrium = false
  end
  if string.find (var.promptstring, "") then
    bal.balance = true
  else
    bal.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
    bal.leftarmbalance = true
  else
    bal.leftarmbalance = false
  end
  if string.find (var.promptstring, "") then
    bal.rightarmbalance = true
  else
    bal.rightarmbalance = false
  end
  if string.find (var.promptstring, "") then
    def.kafe = true
  else
    def.kafe = false
  end
  if string.find (var.promptstring, "") then
    def.deaf = true
  else
    def.deaf = false
  end
end;
the mush variable promptstring (since I have not figured out how to store my prompt as a scriptside variable...) for some reason is set to 1 or nothing, and not letters...
EDIT: Health and mana and such is tracked accordingly, but the letters do not seem to be...
Unknown2007-07-16 20:42:03
I would expect your promptstring to get the full prompt flags and everything after them, including the '-' at the end. You should be doing a non-greedy match, using (.*?)\\- at the end of the pattern.
Also, balances don't really need to be stored using SetVariable and retrieved with GetVariable (if I gave you that snippet, I apologize, but it was just off the top of my head). They can be stored in Lua tables and not in your world file. Remember, your world file is persistent data that you want to keep between sessions (i.e., charges on enchantments, max health/mana/ego, sipping enabled, etc) and the Lua tables are non-persistent (unless you serialize them to a world variable or text file) and you use them for session things that reset when you log back in again (i.e., defenses, balances, etc). However, this means that if you don't close your world file in between sessions that you need to reset your Lua variables back to square one, synchronizing them with your character's true state.
You don't need a balancescheck function if you're just storing true/false/nil in a bal table. You're looping when you could just be returning the value associated with that balance from the bal table.
The square brackets are unnecessary in the string.find function, too.
Also, balances don't really need to be stored using SetVariable and retrieved with GetVariable (if I gave you that snippet, I apologize, but it was just off the top of my head). They can be stored in Lua tables and not in your world file. Remember, your world file is persistent data that you want to keep between sessions (i.e., charges on enchantments, max health/mana/ego, sipping enabled, etc) and the Lua tables are non-persistent (unless you serialize them to a world variable or text file) and you use them for session things that reset when you log back in again (i.e., defenses, balances, etc). However, this means that if you don't close your world file in between sessions that you need to reset your Lua variables back to square one, synchronizing them with your character's true state.
You don't need a balancescheck function if you're just storing true/false/nil in a bal table. You're looping when you could just be returning the value associated with that balance from the bal table.
The square brackets are unnecessary in the string.find function, too.
Simimi2007-07-16 21:13:51
No Zarquan you did not give me that snippet, that was Demetrios' explanation of your system of being able to pass balance into a Have Balance("balancetype") function, which I was trying to emulate. When it failed, I decided to use a balance table.
I removed the brackets from the function and I put the (.*?)\\- into the regexp prompt trigger, and it still does not catch or react to the letters in the prompt. the mushclient variable promptstring is empty, and nothing is caught off of the %7.
Well I have tried it using..
(.*) and (.*?) and (*) and (.*)? and still, the variable has noting in it, and nothing is being captured...
I removed the brackets from the function and I put the (.*?)\\- into the regexp prompt trigger, and it still does not catch or react to the letters in the prompt. the mushclient variable promptstring is empty, and nothing is caught off of the %7.
Well I have tried it using..
(.*) and (.*?) and (*) and (.*)? and still, the variable has noting in it, and nothing is being captured...
Unknown2007-07-16 22:05:43
Have you tried print statements both in the trigger and in the promptcheck function to see the values of %1..%7 and var.promptstring?
Simimi2007-07-16 22:07:28
Well if I put a print into the trigger, var.promptstring has nothing in it, as it also has nothing in it in the variables tab on the mush window.
Did not think of doing it in the script, let me check real quick
returns nothing.
My main worry is that the letters off the prompt are supposed to be passed to my balance table, and printing the entries in the table is nothing since the table is empty, thus the letters are not being caught...
Also, trying to print anything from that function seems to not return anything, so my print syntax must be off, but it checks out on the compiler...
Did not think of doing it in the script, let me check real quick
CODE
function promptcheck()
print(var.promptstring)
print(var.promptstring)
returns nothing.
My main worry is that the letters off the prompt are supposed to be passed to my balance table, and printing the entries in the table is nothing since the table is empty, thus the letters are not being caught...
Also, trying to print anything from that function seems to not return anything, so my print syntax must be off, but it checks out on the compiler...
Simimi2007-07-16 22:59:08
Ok, the prompt trigger appears to be catching nothing, as the items are being caught of my score...
Also, my prompt trigger has 0 matches...
CODE
^.*?Simimi.*?\\n.+?\\n  Level  \\: (\\d+) \\((\\d+)\\%\\)\\s+Rank      \\: (.+?)\\n  Health \\: (\\d+)\\/(\\d+)\\s+Endurance \\: (\\d+)\\/(\\d+)\\n  Mana  \\: (\\d+)\\/(\\d+)\\s+Willpower \\: (\\d+)\\/(\\d+)\\n  Ego    \\: (\\d+)\\/(\\d+)\\s+Reserves  \\: (\\d+)\\%\\n  Karma  \\: (\\d+)\\%\\s+Esteem    : (\\d+)\\%$
var.level = %1
var.tonextlevel = %2
var.levelname = "%3"
var.health = %4
var.max_health = %5
var.endurance = %6
var.max_endurance = %7
var.mana = %8
var.max_mana = %9
var.willpower = %<10>
var.max_willpower = %<11>
var.ego = %<12>
var.max_ego = %<13>
var.reserves = %<14>
var.karma = %<15>
var.esteem = %<16>
var.level = %1
var.tonextlevel = %2
var.levelname = "%3"
var.health = %4
var.max_health = %5
var.endurance = %6
var.max_endurance = %7
var.mana = %8
var.max_mana = %9
var.willpower = %<10>
var.max_willpower = %<11>
var.ego = %<12>
var.max_ego = %<13>
var.reserves = %<14>
var.karma = %<15>
var.esteem = %<16>
Also, my prompt trigger has 0 matches...
Theomar2007-07-16 23:13:29
Take the \\ out before the space after the "w" in your prompt trigger. That might be messing up your match after it.
Simimi2007-07-16 23:15:07
Tried that, turns out the entire trigger is not matching anything...
Theomar2007-07-16 23:32:26
Do you:
You don't need both Linebreak and IAC EOR/GA selected.
CODE
A: Have CONFIG PROMPT ADD LINEBREAK
B: Have Convert IAC EOR/GA to new line selected
C: Have regular expression selected?
B: Have Convert IAC EOR/GA to new line selected
C: Have regular expression selected?
You don't need both Linebreak and IAC EOR/GA selected.
Simimi2007-07-17 00:00:24
CODE
A: yes
B:no
C: Yes
B:no
C: Yes
Unknown2007-07-17 00:26:53
This is what I was using for my prompt trigger. If you copy this, you should be able to paste it into the MUSHclient triggers dialog and test it there. You'll want to replace the OnPrompt with your own code, of course.
    enabled="y"
  group="Tracking"
  match="^(\\d+)h, (\\d+)m, (\\d+)e, (\\d+)p, (\\d+)en, (\\d+)w (e?l?r?x?k?d?b?p?)(\\<\\>)?\\-$"
  name="prompt"
  regexp="y"
  send_to="12"
  sequence="100"
  >
 ÂOnPrompt(%1, %2, %3, %4, %5, %6, "%7")
 Â
Note: the last part is for a gem of cloaking, but it is optional and doesn't hurt to have it either way. Also, if you're a psionicist or anything with other letters, you'll want to add those, too.
CODE
 Â
  group="Tracking"
  match="^(\\d+)h, (\\d+)m, (\\d+)e, (\\d+)p, (\\d+)en, (\\d+)w (e?l?r?x?k?d?b?p?)(\\<\\>)?\\-$"
  name="prompt"
  regexp="y"
  send_to="12"
  sequence="100"
  >
 Â
 Â
Note: the last part is for a gem of cloaking, but it is optional and doesn't hurt to have it either way. Also, if you're a psionicist or anything with other letters, you'll want to add those, too.
Simimi2007-07-17 00:49:04
IT has been fixed! Everyone, many thanks for all of your help!