Severian2007-10-26 04:54:21
I was brooding over how to build my system, and I realized I should tap into the large source that I've heard this forum is. I'm running Mushclient, hoping to script in Lua, and have a little experience coding, so I know basic syntax etc.
My question ist his, conceptually what is the relationship between the different parts of a system? How do the triggers relate to the script? How do the aliases, timers and variables relate to the script? The only things that have come to mind are that the triggers, well, trigger off of an output, call a particulary function in a script which runs the function, and then does whatever else needs doing (setting variables etc.). While this seems the plausible answer I'd like feedback. I'm aiming to have a very quick and efficient system. I don't wish to buy one, I want to build my own so I know how it works, and am willing to put in lots of time. I've perused the Mechanic's Corner forum a bit and gleaned some important tidbits of knowledge, but if you could enlighten me further I'd be greatly appreciative.
Another slight question: I've had a look over Ethelon's base system, which I think is written in VBscript, and he has everything divided up by 'sub''s. Is this essentially creating a function? Within the scope of my knowledge of programming the only way I can see scripting working is if you create a bunch of functions and then call them when you need their processes. For instance on a script that returns 5 sets of statistical information on a car (solar car in my experience) you have functions for conversions. When you write the output script you include the conversions script, and then are free to use the functions in that script. This may not seem clear, but to me it seems the logical process to execute (setting up functions that eat herbs or cure somehow and then use the function somehow when the line triggers).
Is it efficient to use variables to account for balances? For instance if I get hit with stupidity, recklessness and get paralyzed, is it efficient speed wise to have a trigger go when it says 'Why must everything be so hard to figure out' or whichever the afflict line is, and have it set the variable stupidity to 1? In my mind, this would allow me to keep track of my afflictions and be able to list them in order of importance for curing purposes. Using the previous example, I'd have stupidity, recklessness and paralyze all set to 1, denoting that I have them. I would have two separate queues for each set of balances (I don't know how complicated that would be). The first queue would be stupidity and the second queue would be paralysis and recklessness. Somehow I'd set stupidity to be priority since it can hinder other commands, and eat pennyroyal. At the same time have focus body trigger so that I can keep attacking. That would set both of those afflictions to 0. Then after I get mind balance back I could focus mind, or whatever is the most efficient way of healing recklessness. (I'm seeing know that I'd want equilibrium free most so that I can keep my offensive up, just can't remember which herb heals recklessness).
So any ideas, tips, suggestions etc. would be greatly appreciated. I will be posting here as I work along, asking questions. I'm sure I will have many as I am a simple man and don't know much about how all this works.
Thanks!
Daniel
My question ist his, conceptually what is the relationship between the different parts of a system? How do the triggers relate to the script? How do the aliases, timers and variables relate to the script? The only things that have come to mind are that the triggers, well, trigger off of an output, call a particulary function in a script which runs the function, and then does whatever else needs doing (setting variables etc.). While this seems the plausible answer I'd like feedback. I'm aiming to have a very quick and efficient system. I don't wish to buy one, I want to build my own so I know how it works, and am willing to put in lots of time. I've perused the Mechanic's Corner forum a bit and gleaned some important tidbits of knowledge, but if you could enlighten me further I'd be greatly appreciative.
Another slight question: I've had a look over Ethelon's base system, which I think is written in VBscript, and he has everything divided up by 'sub''s. Is this essentially creating a function? Within the scope of my knowledge of programming the only way I can see scripting working is if you create a bunch of functions and then call them when you need their processes. For instance on a script that returns 5 sets of statistical information on a car (solar car in my experience) you have functions for conversions. When you write the output script you include the conversions script, and then are free to use the functions in that script. This may not seem clear, but to me it seems the logical process to execute (setting up functions that eat herbs or cure somehow and then use the function somehow when the line triggers).
Is it efficient to use variables to account for balances? For instance if I get hit with stupidity, recklessness and get paralyzed, is it efficient speed wise to have a trigger go when it says 'Why must everything be so hard to figure out' or whichever the afflict line is, and have it set the variable stupidity to 1? In my mind, this would allow me to keep track of my afflictions and be able to list them in order of importance for curing purposes. Using the previous example, I'd have stupidity, recklessness and paralyze all set to 1, denoting that I have them. I would have two separate queues for each set of balances (I don't know how complicated that would be). The first queue would be stupidity and the second queue would be paralysis and recklessness. Somehow I'd set stupidity to be priority since it can hinder other commands, and eat pennyroyal. At the same time have focus body trigger so that I can keep attacking. That would set both of those afflictions to 0. Then after I get mind balance back I could focus mind, or whatever is the most efficient way of healing recklessness. (I'm seeing know that I'd want equilibrium free most so that I can keep my offensive up, just can't remember which herb heals recklessness).
So any ideas, tips, suggestions etc. would be greatly appreciated. I will be posting here as I work along, asking questions. I'm sure I will have many as I am a simple man and don't know much about how all this works.
Thanks!
Daniel
Xenthos2007-10-26 05:14:19
I'm not sure how it works in MushClient, but I'd assume that they'd allow you to create lists of some sort that you can check to see if certain items are members of it. You could then make one variable for afflictions and then do things like #if (%ismember(stupidity, @afflictions)){;cure stupidity}
That's zMud code so can't be imported directly over, but might want to look into its manuals for how to do it. Centralizing things like this should help keep it all straight (a new affliction is just another #if check, not a "create a whole new variable to deal with" mess).
That's zMud code so can't be imported directly over, but might want to look into its manuals for how to do it. Centralizing things like this should help keep it all straight (a new affliction is just another #if check, not a "create a whole new variable to deal with" mess).
Severian2007-10-26 05:20:27
Ah thank you for your quick reply!
Zmud isn't too hard to switch over in code, but it's a headache because I think it's more straightforward in zmud to script priority lists. I think I saw a pinned thread in here or in combat guide about building your system. It coincided with my ideas about priority lists and variables to denote when a certain affliction is positive. Your point is interesting and I will look into it. It would seem though that it's not this easy. I can't perceive how to come close to prioritizing in lua... I hope someone who knows a bit of direct knowledge about it will drop by.
I appreciate your help very much, thank you!
Daniel
Zmud isn't too hard to switch over in code, but it's a headache because I think it's more straightforward in zmud to script priority lists. I think I saw a pinned thread in here or in combat guide about building your system. It coincided with my ideas about priority lists and variables to denote when a certain affliction is positive. Your point is interesting and I will look into it. It would seem though that it's not this easy. I can't perceive how to come close to prioritizing in lua... I hope someone who knows a bit of direct knowledge about it will drop by.
I appreciate your help very much, thank you!
Daniel
Xenthos2007-10-26 05:31:29
Well, in zMud, you can do a priority by chaining together if/else statements, though it's likely not the most efficient way to do things.
For example, an alias "herbeating" might do the following:
#if (%ismember(herbbalance, @mechanics) and !%ismember(anorexia, @afflictions)){#if (%ismember(stupidity, @afflictions)){eatherb pennyroyal;eatherb pennyroyal} {#if (%ismember(confusion, @afflictions)){eatherb pennyroyal}}
It would check for stupidity first, then do a check for confusion if it doesn't find stupidity. Another option, group by herb cure:
#if (%ismember(herbbalance, @mechanics) and !%ismember(anorexia, @afflictions)){#if (%ismember(stupidity, @afflictions) or %ismember(confusion, @afflictions)){eatherb pennyroyal} {#if (succumb, @afflictions){eatherb reishi}}
This one checks for any pennyroyal affliction. If it finds one, it eats pennyroyal. It then checks for the reishi affliction.
There are major systems out there that use both sorts of priority. The second one is easier to write, but not as good in the field curing-wise.
Edit: As a note, these are not actually checked in zMud for syntax. These are rough guesstimates. I don't remember if the ! needs ( ) around it in zMud or not. Other than that, it should be pretty functional, and it gives you the general direction.
For example, an alias "herbeating" might do the following:
#if (%ismember(herbbalance, @mechanics) and !%ismember(anorexia, @afflictions)){#if (%ismember(stupidity, @afflictions)){eatherb pennyroyal;eatherb pennyroyal} {#if (%ismember(confusion, @afflictions)){eatherb pennyroyal}}
It would check for stupidity first, then do a check for confusion if it doesn't find stupidity. Another option, group by herb cure:
#if (%ismember(herbbalance, @mechanics) and !%ismember(anorexia, @afflictions)){#if (%ismember(stupidity, @afflictions) or %ismember(confusion, @afflictions)){eatherb pennyroyal} {#if (succumb, @afflictions){eatherb reishi}}
This one checks for any pennyroyal affliction. If it finds one, it eats pennyroyal. It then checks for the reishi affliction.
There are major systems out there that use both sorts of priority. The second one is easier to write, but not as good in the field curing-wise.
Edit: As a note, these are not actually checked in zMud for syntax. These are rough guesstimates. I don't remember if the ! needs ( ) around it in zMud or not. Other than that, it should be pretty functional, and it gives you the general direction.
Severian2007-10-26 05:39:11
See that's what I conceptualized when I was browsing the forums, I just need a way to do it in mushclient. I'm sure there is a way and I just can't figure it out. I've been working in php recently and I think the 'ismember' function is similar to php's 'isset' function. PHP scriptin is an option in mushclient, but I want to be able to share some of my scripts so I want to make sure it is easy to transfer to zmud coding if someone uses it. I'll have to ponder more as I go to sleep about how to work this out in mushclient. Your help is very, very much appreciated Xenthos. Thank you for taking your time.
Daniel
Daniel
Forren2007-10-26 06:01:47
Check the signature for helpful system lines.
Faymar2007-10-26 07:25:25
QUOTE(Severian @ Oct 26 2007, 08:39 AM) 453511
See that's what I conceptualized when I was browsing the forums, I just need a way to do it in mushclient. I'm sure there is a way and I just can't figure it out. I've been working in php recently and I think the 'ismember' function is similar to php's 'isset' function. PHP scriptin is an option in mushclient, but I want to be able to share some of my scripts so I want to make sure it is easy to transfer to zmud coding if someone uses it. I'll have to ponder more as I go to sleep about how to work this out in mushclient. Your help is very, very much appreciated Xenthos. Thank you for taking your time.
Daniel
Daniel
In Lua, if you wish to check if there is a specific entry in a table, you just need to compare it with "nil". Like this:if (elixaff.aeon ~= nil) then
end -- if
If you want to check if a table is empty, you use the "next" function. If next(table) returns nil, then the table is empty. Else, it has entries.
EDIT: I actually like Mush more than zmud, it's more flexible in my opinion. And faster.
Simimi2007-10-26 09:17:11
If you go the Mechanics section and look for thread started by me. There is a thread about Mush using Lua for every aspect of system design, with examples and code and everything. I must have bugged the hell out of people for help when I first started learning it. Lots of good stuff there. Also there are Free Mush Plugins which you are free to gank the code from and improve upon, but if you do improve it, do give it back so others can grovel at your work.
Xinael2007-10-26 11:24:19
You don't actually need to do
because the results of the expression are checked against nil and false anyway. This works just as well
without the extra check.
CODE
if elixaff.aeon ~= nil then whatever end
because the results of the expression are checked against nil and false anyway. This works just as well
CODE
if elixaff.aeon then whatever end
without the extra check.
Severian2007-10-26 13:37:41
Ah, Forren: I have extensively perused your signature links... they were the first things I looked at and they are very helpful. Thank you for compling those... I am eternally grateful.
Faymar: That is helpful, but how do I place it in the table to begin with? Would that include setting variables to either 1 or 0, and then checking for that? It seems I'm missing a bit of information to connect what you said, and what I asked. Thank you for your attempt though!
Simimi: I can't find your thread... is it on the first page still? I saw your plugins thread, and was irked that the prompt plugin turned in an xml error when I tried to open it to download.. I think someone else experienced this problem as well.
Xinael: Ah, simplicity is the best. Thank you!
I'll be back this afternoon with time to actually mess around with a script line or two... maybe that will pester more questions out of me. Thank you all for your time!
Daniel
Faymar: That is helpful, but how do I place it in the table to begin with? Would that include setting variables to either 1 or 0, and then checking for that? It seems I'm missing a bit of information to connect what you said, and what I asked. Thank you for your attempt though!
Simimi: I can't find your thread... is it on the first page still? I saw your plugins thread, and was irked that the prompt plugin turned in an xml error when I tried to open it to download.. I think someone else experienced this problem as well.
Xinael: Ah, simplicity is the best. Thank you!
I'll be back this afternoon with time to actually mess around with a script line or two... maybe that will pester more questions out of me. Thank you all for your time!
Daniel
Faymar2007-10-26 19:11:23
QUOTE(Xinael @ Oct 26 2007, 02:24 PM) 453554
You don't actually need to do
because the results of the expression are checked against nil and false anyway. This works just as well
without the extra check.
CODE
if elixaff.aeon ~= nil then whatever end
because the results of the expression are checked against nil and false anyway. This works just as well
CODE
if elixaff.aeon then whatever end
without the extra check.
If I understand correctly, that would mean that if a member of a table has a boolean value, it will first check to see if it is nil, then if it is false, so that would actually add another check, whereas my script will tell Lua to only check it against nil, or false, not both.
You can add an element to a table by simply assigning a value to it, like flag.trying_to_def = 1. Want it removed? You assign nil to it, like this flag.trying_to_def = nil.
You could take a look at the MUSH forums, they are really helpful there. Here, this is a topic I have found very useful when I started learning Lua: http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6030
Severian2007-10-26 20:24:28
Indeed, I have been using the thread that is under that link, thank you. This still seems a bit hazy to me, but I suppose I'll work it out in time. I've asked on the MUSH forums before, but didn't get an answer, about how I should create a timestamp and prompt stat decreases/increase values. ie something that looks like this
3114h, 3858m, 2814e, 10p esSix-<10:13:04:23>
2114h, 3358m, 2814e, 5p esSix-<10:13:05:01> |-1000 health| |-500 mana|
or something to that effect.
3114h, 3858m, 2814e, 10p esSix-<10:13:04:23>
2114h, 3358m, 2814e, 5p esSix-<10:13:05:01> |-1000 health| |-500 mana|
or something to that effect.
Forren2007-10-26 21:11:57
QUOTE(Severian @ Oct 26 2007, 04:24 PM) 453653
Indeed, I have been using the thread that is under that link, thank you. This still seems a bit hazy to me, but I suppose I'll work it out in time. I've asked on the MUSH forums before, but didn't get an answer, about how I should create a timestamp and prompt stat decreases/increase values. ie something that looks like this
3114h, 3858m, 2814e, 10p esSix-<10:13:04:23>
2114h, 3358m, 2814e, 5p esSix-<10:13:05:01> |-1000 health| |-500 mana|
or something to that effect.
3114h, 3858m, 2814e, 10p esSix-<10:13:04:23>
2114h, 3358m, 2814e, 5p esSix-<10:13:05:01> |-1000 health| |-500 mana|
or something to that effect.
At the end of my prompt trigger I go:
#VAR oldHealth @currentHealth
#VAR oldMana @currentMana
#VAR oldEgo @currentEgo to store my previous values.
For timer:
#if (@settings.timer==1)
{
#SAYP %ansi(green)/-%time("h:nn:ss.zzz")-/%ansi(high, cyan)|
}
For HP change:
$hpChange = @currentHealth - @oldHealth
#if (@currentHealth > @oldHealth)
{
$hpChange = "+"$hpChange
}
#if ($hpChange != 0)
{
#SAYP %ansi(high,green)HP: $hpChange%ansi(high,cyan)|
}
Severian2007-10-27 00:24:18
Would you mind sticking in a few script comments? While I've worked most of it out, it seems incomplete for some reason, and I'm probably missing something. If it isn't too much trouble could you either explain further the function of each part, or just edit the old post with comments? No problem if you don't have time, I'm sure I'll figure it out eventually. Thank you.
Unknown2007-10-27 00:47:36
That last bit of code Faymar posted is for CMUD, I believe. You'd have to do it differently in MUSHclient. I highly recommend using CONFIG PROMPT ADD LINEBREAK in the game, too, if you haven't done so already. I'd bet Simimi has a prompt add-on tracker in her arsenal somewhere...
Severian2007-10-27 01:38:25
She does but I still can't get it... >< I'd want it just for reference... I'm determined to have my whole system be home made by me, since I think that if it is good enough i'll sell it. (thinking on that now I doubt I can make a system that is quick enough that people will want it)
Unknown2007-10-27 01:51:10
Speed isn't really an issue in MUSHclient, thankfully. You can write some fairly badly designed scripts, and as long as they work, you're good.
Severian2007-10-27 01:56:29
So how do I denote each script function in lua? Just create 'function yarrow '? That obviously isn't the right way to write that, but is that the general idea? As opposed to 'sub' in VBscript.
Severian2007-10-27 03:07:27
Well I see no reason to not use Simimi's prompt tracker now that I've figured out how to get it to work. I would use her autosipper, but I want it to automatically know the priority on what to sip, similar to how Ethelon has done his. Any ideas on how to accomplish this?
Faymar2007-10-27 05:42:29
When you create a function in Lua, you specify its name and the parameters. Usually, you make a function and a trigger will call that function.
Edit: It's explained on the mush forums much better than I could ever explain.
Edit: It's explained on the mush forums much better than I could ever explain.