Hey guys! I just started getting back into byond and one thing I never really got into was the Bump proc. Well, my bump looks like this:
mob
player
Bump(atom/Sign1)
alert("Welcome to my game.","Sign","Ok",)
Well, i wanted to know how to make it so this only shows up when i bump the sign. As of now it comes up anytime i hit anything on the same screen as the sign. :( Thanks in advance! Any help would be great!
ID:176929
![]() Nov 26 2002, 11:13 pm
|
|
Thanks a lot! Especially for the different codes, that was a realy help. Thanks again Zero! Later yo!
|
Hehehehehe....ummmmmmm, sorry. I thought the code would work just by looking at it but unfortunetly, when I try to use the first code I get a Objects.dm:14:error:obstacle.name:undefined var
even tho I define it like Zero said to. I now have no idea what's wrong. Is there another mistake I made? Any help would be awesome! Thanks in advance! |
First, it should be atom/obstacle.
Second, the code is very, very bad. What if someone's name is "Sign?" The name var can be changed by players, and thus, nothing should be based on it. So use the type var. mob/Bump(atom/Obstacle) if(istype(Obstacle,/obj/Sign/)) var/obj/Sign/S = Obstacle src << alert(src,S.message,S.name) obj Sign var/message = "BLAH!" name = "Not a sign" |
SSTrunks7 wrote:
Hey guys! I just started getting back into byond and one thing I never really got into was the Bump proc. Well, my bump looks like this: Well, there are two problems here. First, there's no guarantee that you're hitting a sign; Bump() is called no matter what you hit, and Sign1 would be the name of the var representing what you bumped into. A better way to go about this would be something along these lines: mob The second problem you have is actually eliminated by the above code, because I didn't use alert(). (I find alert() to be fairly sloppy anyway. Reserve this for emergencies.) The problem is that alert() sends a box to usr by default, not to src. Unfortunately, Bump() will be called when you move and bump into something whether you initiated the movement or not. If something else tries to push you, for example, using Move(), then usr will not be your character and thus the alert box will go to the wrong player--or to a non-player, and cause an error. When you use alert() inside Bump(), send src as the first argument: alert(src,"Hi","Sign") Lummox JR |
Oops, alert should have src as the first argument, and it should alert src, not usr... changed accordingly.
|
Try this
mob/player
Bump(obstacle)
if(obstacle.name=="Sign")
alert("I like cheese")
obj/sign
name="Sign"
But for a more robust bump, try this.
mob/player
Bump(obstacle)
if(obstacle.message!=null)
alert("[obstacle.message]")
obj/sign
var message="I like cheese"
-Project Zero