mob
proc
deathcheck()
if(src.hp <= 0)
view() << "[src] dies!"
src.hp = 10
src.Move(locate(1,1,1))
usr.exp += 10
del(src)
M:levelup()
mob/Stat()
stat("Health:","[hp] / [maxhp]")
stat("Experience:","[exp] / [100]")
statpanel("Inventory", contents)
stat("Level:","[level]")
mob/proc/levelup()
while(exp >= exp_needed)
exp -= exp_needed
exp_needed = round(exp_needed * 1.5, 1) // increase exp needed each time
++level
... // increase other vars
alright this is a tiny chunk of my code, I am trying to make it so when the deathcheck ends, M:levelup() goes into effect, but it tells me M:levelup() is an undefined variable, what should I do...
Oh, I wasn't aware that . was needed. Another piece of coding I used, to refer to the deathcheck, was like this. M:deathcheck(), and it worked fine so idk. But alright, I will try with the .
|
Filthynate wrote:
Oh, I wasn't aware that . was needed. Another piece of coding I used, to refer to the deathcheck, was like this. M:deathcheck(), and it worked fine so idk. But alright, I will try with the . Made no difference.. |
I said that was the first thing I noticed ..
I am redoing your levelup proc .. mob/proc/levelup() [EDIT] and you are calling M:Levelup() who is M in this proc? Do not use usr in proc ugh |
oh sorry, and I guess M isn't needed, I just want the levelup() to activate after you have acquired the right amount of EXP. i just started coding so im confused, sorry :/
|
Filthynate wrote:
Filthynate wrote: The : operator uses up far more resources than the . operator. As a general rule, you shouldn't use : unless it's impossible or incredibly difficult to use the . operator. |
Robertbanks2 wrote:
Filthynate wrote: well it still isnt' working, any idea why? |
Filthynate wrote:
well it still isnt' working, any idea why? It's not working because you aren't passing the killer as an argument, then assigning it to the variable "M". This means M is null, and the compiler tries to read it as a src(the person dying) variable. When you call deathcheck(), use deathcheck(Attacker), where attacker is whatever you're refering to your attacker as. Then, in the deathcheck() definition, put mob/M in the parentheses. Once all of that is done, you'll be able to refer to the attacker via the "M" variable. |
I told you how to fix your problem, and you ignore me. The issue has nothing to do with your levelup() proc, the issue is that you aren't calling it properly FROM your deathcheck() proc. Do what I told you to and it should work.
|
oh alright, im sorry. So I assign M to the deathcheck, then I can link it to the levelup, allowing it to function properly?
|
That's correct. You should learn how to use arguments in procs, they're a necessity if you plan on doing anything significant in DM.
Here's a link to read up on them a bit: http://www.byond.com/ members/?command=reference&path=proc%2Farguments |
You should probably read some tutorials before trying to make a game. There are plenty.
http://www.byond.com/members/ DreamMakers?command=view_post&post=36143 http://www.byond.com/games/Dantom.YourFirstWorld http://www.byond.com/games/Deadron.StepBYOND |
There are two reasons why that code wouldn't work.
First, the fact that M does not exists, but you should have already corrected that. Second, the fact that you have a del(src) before the procedure call. Deleting the src stops the procedure, so anything called after that will be ignored. |
First thing I noticed is you are using : instead of .