ID:266566
 
else
for(var/M=rand(1,7))
usr.PL+=M
usr.underlays+='a.dmi'
if(usr.PL>=PLM)
usr.PL=usr.PLM
usr.underlays-='a.dmi'
..()


ok it says that in the for statement the M is an unused var?
Strange Kidd wrote:
else
for(var/M=rand(1,7))
usr.PL+=M
usr.underlays+='a.dmi'
if(usr.PL>=PLM)
usr.PL=usr.PLM
usr.underlays-='a.dmi'
..()

ok it says that in the for statement the M is an unused var?

Small surprise, since that's not a valid for() statement.

Lummox JR
In response to Lummox JR
hmmmm thanks but can you tell me why so i cant try and fix it
In response to Strange Kidd
Strange Kidd wrote:
hmmmm thanks but can you tell me why so i cant try and fix it

Because it isn't formed as the reference suggests:

http://www.byond.com/docs/ref/info.html#/proc/for/loop
or
http://www.byond.com/docs/ref/info.html#/proc/for/list
In response to Skysaw
for(var/mob/M in oview(2)) How is that any different then the one i posted befause that one i posted earlier?
In response to Skysaw
for(var/mob/M in oview(2)) How is that any different then the one i posted befause that one i posted earlier?
In response to Strange Kidd
Strange Kidd wrote:
for(var/mob/M in oview(2)) How is that any different then the one i posted befause that one i posted earlier?

Observe:
for(var/mob/M in oview(2))

This is looping M through a list of mobs in the list oview(2,usr).
for(var/M=rand(1,7))

In this statement, you're setting M to a value, not looping through a list or a range of values.

The second is just completely and catastrophically wrong. It's not a loop; it's an assignment. Instead of saying "For every mob in this list", you're saying "For every... no wait! That one right there!" I'm amazed the compiler isn't giving you a major error message right there.

Lummox JR
In response to Lummox JR
can you possibly tell me exactly what ill need to put?
In response to Strange Kidd
Strange Kidd wrote:
can you possibly tell me exactly what ill need to put?

Well it looks to me like it's not your intention to loop through a list at all, so you should just get rid of the for() and put var/M=rand(1,7) by itself, unindenting everything that was previously in the loop.

Lummox JR
In response to Lummox JR
ya but its supposed to be usr.HP+=M sleep(10) do it again and again until the usrs HP = usr.HPM
In response to Strange Kidd
Strange Kidd wrote:
ya but its supposed to be usr.HP+=M sleep(10) do it again and again until the usrs HP = usr.HPM

In that case, you still don't want a for() loop--you want a while() loop.
while(HP<HPM)
HP=min(HP+rand(1,7),HPM)
if(HP<HPM) sleep(10)

I deliberately didn't use usr in there--you should never use it outside of a verb unless you're absolutely crystal clear on what it will be.

Lummox JR
In response to Lummox JR
Ok thanks Now here is ma whole code


obj/Bed
icon='bed.dmi'
density=1
verb/Sleep()
var/test=usr.icon_state
set src in oview(1)
if(usr.HP<usr.HPM)
usr.icon_state="sleep"
usr.loc=src
usr.Lock(usr)
while(usr.HP<usr.HPM)
usr.HP=min(usr.HP+rand(1,7),usr.HPM)
if(usr.HP<usr.HPM) sleep(100)



ok now i want after the users HP is at its max to change the usrs icon state to test then the unlock the user
In response to Strange Kidd
Strange Kidd wrote:
Ok thanks Now here is ma whole code


obj/Bed
icon='bed.dmi'
density=1
verb/Sleep()
var/test=usr.icon_state
set src in oview(1)
if(usr.HP<usr.HPM)
usr.icon_state="sleep"
usr.loc=src
usr.Lock(usr)
while(usr.HP<usr.HPM)
usr.HP=min(usr.HP+rand(1,7),usr.HPM)
if(usr.HP<usr.HPM) sleep(100)

ok now i want after the users HP is at its max to change the usrs icon state to test then the unlock the user

Easy enough:
  ...
while(usr.HP<usr.HPM)
sleep(100)
usr.HP=min(usr.HP+rand(1,7),usr.HPM)
usr.icon_state="test"
usr.Unlock(usr)

I moved the sleep up because that's probably the desired behavior. Otherwise it'd be possible to fully heal a few points of damage without putting in any sleeping time.

Lummox JR
In response to Lummox JR
Thanks now 1 more question how would i slowly increase the HP by whenever the user wants to stop it by them selves