ID:170912
Nov 30 2004, 6:06 pm
|
|
One thing I have not learned yet is how to pass a certain var. Jon88 was trying to teach me but i'm still having problems. Could someone really fast just like explain it to me. Also, if I have to vars for a text parser, and the proc i'm calling only expects one var. When the text parser finds that word, it doesn't work because it expects 1 var and gets to or something.
|
In response to Lummox JR
|
|
Yeah I thought that, thats why I was sort of hoping for an explenation. But alright....:
var/list/Attacking = list("Silencio" = "<i>Silencio</i>", "Expelliarmus" = "<i>Expelliarmus</i>") If you see anything else that looks wrong, can you please tell me, Thanks. |
In response to N1ghtW1ng
|
|
N1ghtW1ng wrote:
If you see anything else that looks wrong, can you please tell me, Thanks. Well for starters you never said what you were trying to change in that code and what you were having trouble with. I do see a couple of minor things in SpellFinder(), just design issues really. First, the "as text" part in the arguments is unnecessary unless you end up using this proc as a verb. Second, that same proc has the line "return msg" several times when it's only needed once; in fact in one place it's preventing a second loop from running. Just put that at the end and anywhere you need to bail out of a loop. I also suspect the entire if(spellname in Passive) block is indented too far. Lummox JR |
In response to Lummox JR
|
|
Alright, what i'm having problems with is, when ever I call any of the Spells it doesn't work. It use to work until I added the whole attacking thing with the mob/Caster and mob/Defender.
Also, yeah I was sorta editing before as I was posting and tabbed it over I forgot why...but yeah. Also, don't I need the other return's incase it doesn't find the Spell in the list? |
Ok, well. It's simple, really. You're probably already doing it without knowing what it is. Say all mobs have a var called HP. Most do, so it's a good one to use. Now, let's say when your mob is hit, it checks the damage against it's HP, which most do. For the sake of argument (heh), though, let's say you want the check to happen in a global proc, so you can't just use src.HP in the mob's own proc. To do this, we need to pass the damage and the mob's HP to this global proc, because it has no direct reference to either, unlike the mob.
mob Ok, so there is our variable, HP belonging to the mob. Simple enough. Let's do the damage checking proc now. It's global, remember, so it just starts off the left under the word proc. It doesn't belong to anything, that's why it's global. Anyone can use it. proc But, we need to pass the HP of the mob and the damage to the DamageCheck() proc, we do that by first telling the proc it should expect 2 arguments. We need to name them as well, so let's do that now. proc See how that works? DamageCheck() now expects two variable, which it knows by the names Damage and CurrentHP. These variables only work inside the DamageCheck() proc, so you won't be able to use CurrentHP elsewhere without declaring it again. Anyways, now we have the proc just waiting for these values to be passed to it, so how do we do that? Easy, just call the proc and fill the values in the () when you call it. mob See how that works? We made a call to DamageCheck() and placed our values in the () after the proc's name. The order has to match the order of our proc definition above, unless you name the arguments. That's just a fancy way of saying: mob See there? We reversed the position of the values, but it's ok, because we told the proc which is which by applying the name we gave the vars in our original proc defintion to the values we are passing. The proc will be able to look at the variables, see they have names it recognises, and know which is which, even out of order. Optional arguments is another can of worms, though. If you'd like more information on that topic, I suggest a more experienced programer. I have no real experience with the process myself. I hope this has helped. ~X |
In response to Xooxer
|
|
Yes, that helped some. I am begining to understand it a little more. My problem though is that my text parser is expecting 2 vars, but my proc that is called by it only is expecting one I think. Well it doesn't work >.>. So yeah...if you wanted to take a look its under Lummox's post.
|
In response to N1ghtW1ng
|
|
Ok, well you don't need all 3 variables to be passed to the SpellFinder() proc. The only one you need is the msg itself. The src of the SpellFinder() proc would be the caster, so there's no need to pass that variable. The only thing you'll have trouble with might be determining who the defender is. As it stands now, there is no way for the code to know who the caster is casting the spell on.
You'll need to have some sort of targeting system, whether it's a simple random pick of someone in a certain range, the caster clicking to select target, or some other means, you have to tell the game who to cast the spell on. Right now, you're not. That's probably the main point of confusion for you. You have the variable, you just don't have a way to fill in it's value. ~X |
In response to Xooxer
|
|
Alright I think I figured it out now, but i'm still having some problems.
mob I know I made a loop in Click() but I couldn't think of a better way. Also now I can read the message's in worldsay, but the spell does not activate. |
In response to N1ghtW1ng
|
|
You don't need that while() loop, just asign the player that was clicked as the target. Also, your top if()s in SpellFinder() should be for() loops, so it looks at all the spells of the type. The way you had it the if()s would never be true because spellname was never set to anything. Also, you're returning the msg when you don't need to. Just return if(equiped) is false, and after the two for() loops. Otherwise, it'll return the msg if the spellname isn't the first item in the first list. Try this instead:
mob ~X |
In response to Xooxer
|
|
Thanks! It works great now, just one problem. Not exactly having to do with it but I don't want to make another topic
I get the runtime: runtime error: Cannot read "\[Master] Night".equiped proc name: Expelliarmus (/mob/proc/Expelliarmus) source file: Spells.dm,40 usr: the j (/mob) src: the j (/mob) call stack: the j (/mob): Expelliarmus(the j (/mob), "\[Master] Night") the j (/mob): SpellFinder("Expelliarmus") the j (/mob): World Say("Expelliarmus") The proc is: Expelliarmus(mob/Caster,mob/Defender) Yeah..I debugged it and it only goes to #3. Thanks again, for helping me with the parser, and to anyone who helps with the runtime. |
In response to N1ghtW1ng
|
|
I was wondering about that myself, actually, but thought you were going to handle locating the target by their text name. The problem is back in your targeting system, the Click() proc for Clickable mobs. You're setting the usr.target to the text name of the target, not to the mob itself. Change those lines from usr.target = "[src.name]" to usr.target = src. Then it will pass the mob to your spells, not the mob's name.
~X |
In response to Xooxer
|
|
Thanks, that got it working. I understand the Passing arguement's also. So thanks!
|
Lummox JR