ID:154185
 
I am trying to make a fishing code and its not going too good. can any 1 show me an example or something?
Also how do you keep verbs from the list until you are by the object or turf?
obj/rod

turf/water
var
fish = 30
verb
fish()
set src in view(1)
if(obj/rod in usr.contents)
if(rand(1,100)<=src.fish)
usr << "A bite!"
//fishing code here
else
usr << "Nothing..."
else
usr << "You do not have a rod to fish with."

You could have different instances of turf/water with different chances of catching fish, eg.

turf/water
var/water
New()
..()
water = rand(30,50)
In response to ArticWOLF
This line is problematic:

if(obj/rod in usr.contents)

This checks to see if the object type obj/rod is in the user's contents, not the object itself. You should use locate:

if (locate(obj/rod) in usr.contents)

In response to Skysaw
obj/rod

turf/water
var
fish = 30
verb
fish()
set src in view(1)
if(obj/rod in usr.contents)
if (locate(obj/rod) in usr.contents)
usr << "A bite!"
//fishing code here
else
usr << "Nothing..."
else
usr << "You do not have a rod to fish with."


I tryed that in my game.. and that fish = 30 part gives me a inconsistent indentation error.

In response to ShadowSiientx
I tryed that in my game.. and that fish = 30 part gives me a inconsistent indentation error.

Then for heaven's sake, fix the inconsistent indentation!

If you don't understand how, please read this: http://www.deadron.com/byond/ ByondBwicki.dmb?IndentationErrors
In response to Skysaw
loading Bladed Knightz.dme
repop.dm:9:error:obj:undefined var
repop.dm:9:error:rod:undefined var
repop.dm:10:error:obj:undefined var
repop.dm:10:error:rod:undefined var

Bladed Knightz.dmb - 4 errors, 0 warnings (double-click on an error to jump to it)

heres where i tabed it:

obj/rod

turf/water
var
fish = 30
verb
fish()
set src in view(1)
if(obj/rod in usr.contents)
if (locate(obj/rod) in usr.contents)
usr << "A bite!"
//fishing code here
else
usr << "Nothing..."
else
usr << "You do not have a rod to fish with."

In response to ShadowSiientx
var
fish = 30


if you put the var name on the next line, it must be indented one more than the var keyname.
In response to Skysaw
heres my customized made up.. fishing verb.

turf/water
verb
fish()
usr <<"You wait.."
sleep(50)
usr <<"You catch a fish."
usr contents += new/obj/fish
else
usr <<"you catch nothing,"

but that else! gives me errors.

I have tabed it to the left! all the way.. and all the way to the right and...i still get errors.
In response to ShadowSiientx
ShadowSiientx wrote:
heres my customized made up.. fishing verb.

turf/water
verb
fish()
usr <<"You wait.."
sleep(50)
usr <<"You catch a fish."
usr contents += new/obj/fish
else
usr <<"you catch nothing,"


but that else! gives me errors.

I have tabed it to the left! all the way.. and all the way to the right and...i still get errors.

Tab all the bolded text once.
In response to ShadowSiientx
ShadowSiientx wrote:
heres my customized made up.. fishing verb.

turf/water
verb
fish()
usr <<"You wait.."
sleep(50)
usr <<"You catch a fish."
usr contents += new/obj/fish
else
usr <<"you catch nothing,"

but that else! gives me errors.

I have tabed it to the left! all the way.. and all the way to the right and...i still get errors.

Else??

Else means nothing without an if.
In response to Skysaw
if("what")
In response to ShadowSiientx
ShadowSiientx wrote:
if("what")

Thats would not work...

"What" is not a defined var.

Lee
In response to Mellifluous
I KNOW "WHAT" do i put there?
In response to ShadowSiientx
ShadowSiientx wrote:
I KNOW "WHAT" do i put there?

I'm sorry, but that is for you to decide. What exactly do you want to check for? What conditions must be true for someone to catch a fish?
In response to Skysaw
ShadowSiientx, how long have you been using Byond? It shouldn't take too long to work out indentation.

did you come from another coding system?
In response to Mellifluous
Thanks everyone!
I can probly use the examples here to make the other stuff i need.........

FireGuy

Aim ID: trashplanet420