ID:174036
 
i want to insert if statements like if the usr strength is greater than 10, than it will say "This user is kinda strong" and if the user strength is greater than 100 than it will say another thing and so on...
this is my current browse function
mob
verb
Stats()
for(var/mob/M in oview(3))
var/Stats ={"
Stats for [M]
Name: [M]
Race: [M.RACE]
Strength: [M.STR]
Defense: [M.DEF]
"}
usr << browse(Stats, "window=page")
ZDarkGoku wrote:
i want to insert if statements like if the usr strength is greater than 10, than it will say "This user is kinda strong" and if the user strength is greater than 100 than it will say another thing and so on...
this is my current browse function
mob
verb
Stats()
for(var/mob/M in oview(3))
var/Stats ={"
Stats for [M]
Name: [M]
Race: [M.RACE]
Strength: [M.STR]
Defense: [M.DEF]
"}
usr << browse(Stats, "window=page")

First of all, you are looping through the mobs within close view, and changing Stats each time for each one. You will end up having only the stats of the last one in your browser when the proc ends. If you want to fix that, put in Stats="" as the first line in there, and use Stats += {"[text here] instead of Stats ={"[text here]

I suggest you make an additional proc that will return a text string and embed it within the text string that you are browsing.

example:
proc/approx_strength(mob/body_builder)
if(body_builder.strength<10)
return "He looks like he's about to fall under his own weight!"
if(body_builder.strength<100)
return "He looks like the average Joe."
if(body_builder.strength<1000)
return "Wow, he must've been raised by bears."
else
return "O_O!!! Is that thing human?"

mob
verb
Stats()
for(var/mob/M in oview(3))
var/Stats ={"
Stats for
[M]
Name:
[M]
Race:
[M.RACE]
Strength:
[M.STR]
Defense:
[M.DEF]
[approx_strength(M)]
"}

usr << browse


With that, you will be able to have conditional statements within your browser. You could also do it by setting a variable to the required text earlier in the proc and imbedding that variable in there the same way, but I prefer doing it this way. You use whichever you like.
In response to Loduwijk
Loduwijk wrote:
> proc/approx_strength(mob/body_builder)
> if(body_builder.strength<10)
> return "He looks like he's about to fall under his own weight!"
> if(body_builder.strength<100)
> return "He looks like the average Joe."
> if(body_builder.strength<1000)
> return "Wow, he must've been raised by bears."
> else
> return "O_O!!! Is that thing human?"


I would suggest changing the last two IFs to ELSE IFs. Otherwise you're never going to see the first two messages. :)