ID:161876
 
I'm aware I posted two days ago, but if it's here I'm going to use it.

In my last post I was working on a fishing system, which I still am now. Though it works now, I want to add some fun stuff to it.

How would I make it so that when you do catch a fish it would have a random size from blank# to blank# (So we can keep sizes realistic, of course).

if(0 to 4)
view()<<output("small worthless message here","window")
sleep(#)
usr<<output("You caught a fishnamehere","window")
usr.contents+=new/obj/Fish/Fishname

How would I go from there into adding a random size to that fish, so say if they caught a gold fish you'd want it to be no more than 2 or 3 inches tops. So I'd want something like a random of 1 to 3? I don't know how to do it exactly, and it's not working all that nicely. I'm pretty sure it could be done the same way the fish is done, but how would I go about adding the variable to the object and what not?

Some help would be so great, thanks.
var/obj/Fish/Fishname/Fish = new/obj/Fish/Fishname
Fish.loc = usr
Fish.size=rand(min,max)

Isn't it simple?
In response to Lyndonarmitage1
Oh my god. My bad, it should be.


I'm so sorry for the inconvenient post, haha.

I'll figure it out, thanks Lyndon.
In response to Lyndonarmitage1
Since size of fishes can very from species to species, genus to genus, I would recommend setting the size when the fish is created, via modifying New():
Fish
Tuna
New() // When the /Fish/Tuna item is created
size = rand(10,25) // Picks a random # between 10-25
size /= 10 // The size is now 1.0 - 2.5 :D
world.log << {"[src.name] ([src.type]) has been created! It is [size]" long!"} // parenthesis quote {" "} are basically like long strings which is able to escape quotes, meaning that the string will not end prematurely with an unescaped quote (\")

Bacteria
Salmonella
New()
size = rand(1,20) / pick(1,10) // Two in one :D The size is from 0.1 - 20 (min: 1/10 - max: 20/1)
world << "Salmonella is [size] micrometers long!"
In response to GhostAnime
What happens with the system is the size is decided for each specific fish when they're caught - The code is pretty long in the means it has different code snippets for each different fish.

So I just create the size there, thanks for the help. :D