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...
1
2
In response to A.T.H.K
|
|
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 .
|
In response to Filthynate
|
|
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.. |
In response to Filthynate
|
|
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 |
In response to A.T.H.K
|
|
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 :/
|
In response to Filthynate
|
|
but it still doesnt work D:
|
In response to Filthynate
|
|
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. |
In response to Robertbanks2
|
|
Robertbanks2 wrote:
Filthynate wrote: well it still isnt' working, any idea why? |
In response to Filthynate
|
|
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. |
In response to Robertbanks2
|
|
the deathcheck works fine, im having trouble assigning a levelup()
|
In response to Filthynate
|
|
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.
|
In response to Robertbanks2
|
|
oh alright, im sorry. So I assign M to the deathcheck, then I can link it to the levelup, allowing it to function properly?
|
In response to Filthynate
|
|
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 |
In response to Robertbanks2
|
|
oh, so I put the definition of the deathcheck within it?
|
In response to Filthynate
|
|
No... Follow the instructions I gave you. All you're doing is changing 2 lines of code.
|
In response to Robertbanks2
|
|
blegh, im sorta confused. sorry that im so dumb xD literally started yesterday
|
In response to Filthynate
|
|
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 |
In response to Filthynate
|
|
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. |
In response to Kccmt
|
|
mob |
1
2
First thing I noticed is you are using : instead of .