Just a quick question, how do i teleport an item (the item is a ball)
I found this code on a demo on teleporting
turf/Teleorter//the name of our turf
icon='teli.dmi'
Entered(mob/M)
if(istype(M,/mob))//is it a mob that entered?
M.loc=locate(1,1,1)//if it is a mob move it to the x,y,z coordinates
Im guessing its along those lines, but im not sure how to relate this to an item?
Also another quick question
When the ball goes onto turf/lines i need it to stop and move left
How do i do this?
Thanks alot
ID:267958
Jan 6 2004, 10:19 am
|
|
CHESTER GUY wrote:
Just a quick question, how do i teleport an item (the item is a ball) It depends on how exactley you want this to work, but if you want to "teleport" and obj you would need to modify its loc, such as src.loc=locate(1,1,1) if you were using coordinates. To make it "teleport" when it enters a turf, you would need to do something like this: turf/portal icon='portal.dmi' Entered(obj/ball/B) if(istype(B,/obj/ball)) B.loc=locate(2,2,2)//enter your coordinates here try looking up Move() loc and locate(), in the help in DM(F1) |
In response to DerDragon
|
|
Neither of those seem to work... the ball just stays there when it enter's the turf...
Another way i could do it is, when it enter's the turf it gets deleted and another ball respawns in its original starting place? Is there a way to do this? Thanks for trying |
In response to CHESTER GUY
|
|
Could you post some of the code your using for this? It should work, in fact I tested it and it does work. May not be compatible with your code, if you could post it that would help.
|
In response to Valderalg
|
|
Ok, basicly my game is a football(Soccer game) Its still in its early stages
The problem is that when i score, the ball gets stuck in the back of the net and cant be removed, so i need to teleport it back to the centre... Here's the code for the movable ball atom movable Bump(var/atom/O) ..() O.Bumped(src) atom proc Bumped(var/atom/movable/O) return obj ball icon = 'ball.dmi' density = 1 var bounce = 0 Bumped(var/atom/movable/O) var/direction = O.dir src.bounce = 1 for(var/count = 1;count<1.5;count++) var/success = step(src,O.dir) if(!success) break sleep(5) Bump(var/atom/O) if(bounce) src.bounce = 0 step(src,get_dir(O,src)) ..() That basicly makes you move with the ball The ball-enter goal code is turf/goal //This is the turf the arrow will react to when entering Entered(O) //This is the entered proc, and O is whatever has entered the turf. if(istype(O,/obj/ball)) //Here we check to see if whatever entered is an /obj/arrow or not world << "BLUE TEAM SCORES!" And the question about bouncing the ball of lines turf is because the ball keeps getting stuck in the corners... Any help? |
In response to CHESTER GUY
|
|
turf/goal //This is the turf the arrow will react to when entering
Entered(O) //This is the entered proc, and O is whatever has entered the turf. if(istype(O,/obj/ball)) //Here we check to see if whatever entered is an /obj/arrow or not world << "BLUE TEAM SCORES!" try Entered(obj/ball/O) instead of Entered(O) |
I'm sorry, I totally misread your question. What I posted was code to teleport TO and object.
turf/goal/Entered(atom/movable/M) // atom/movable's are the only things that can really "enter" a turf |
In response to CHESTER GUY
|
|
Here's how I'd do it:
obj/ball That's just for the movement of the ball, basically. You would further test if the ball has collided with a wall, and change its direction away from the wall, that way the ball would at least bounce off the side. You may still get it stuck in corners, doing this, however. You could make another check, that if the ball has no where to go when being kicked, it swaps positions with the person kicking it, so you could get it out of corners... I don't know, this is getting too long. |
In response to Valderalg
|
|
YAY got it working with the:
turf/portal icon='portal.dmi' Entered(obj/ball/B) if(istype(B,/obj/ball)) B.loc=locate(2,2,2)//enter your coordinates here Code, must have done somthing wrong the first time... Thanks Prehaps for the bouncing off the walls... Ive seen this done on a few games, where the character walks into the door, it opens and then closes behind him... Prehaps if i was to make the door the same colour as the pitch, that would enable the character to go off the pitch, and re-line himself up to get the ball back into play, without the all leaving the field... Thats just a long shot... |
In response to CHESTER GUY
|
|
Ok (Leaving the bouncing problem for a while) Now that ive got it to:
turf/goal icon='goal.dmi' Entered(obj/ball/B) if(istype(B,/obj/ball)) world << "BLUE TEAM SCORES!" sleep(20)//Wait a little... B.loc=locate(10,12,1)//enter your coordinates here I wondering how to add a visible point to the team (there's also A similar one for "goal2" for the red team) That will be the same for everyone on the server? I guess its done with variables, but will that stay the same for everyone? If someone could give me a help with the code for this id be most gratefull Thanks for your time :) |
In response to CHESTER GUY
|
|
When i say point i mean register it on the scoresheet, should have made that more clear...
|
In response to CHESTER GUY
|
|
Depends how your scoresheet is set up. You might have something like "redgoals" and "bluegoals" vars; if so, you can just add one to the appropriate var when someone scores a goal.
<code>//Define the global vars; they're global because then they'll be the same for everyone var redgoals=0 bluegoals=0 //Display the goals to people in a stat panel (this is just an example) mob/Stat() statpanel("Score") stat("Red",redgoals) stat("Blue",bluegoals)</code> |
In response to Crispy
|
|
Will that show for everyone on the server?
So its just a standard +1 to the variable when "blue" score? |
In response to CHESTER GUY
|
|
Yes. Because it's defined under <code>mob</code>, every mob will have it displayed to them. So yes, everyone in the server will see it.
Yes, just add 1 to the appropriate variable. |
In response to Crispy
|
|
The only problem is that with the code:
var redgoals=0 bluegoals=0 //Display the goals to people in a stat panel (this is just an example) mob/Stat() statpanel("Score") stat("Red",redgoals) stat("Blue",bluegoals) turf/goal2 icon='goal.dmi' Entered(obj/ball/B) if(istype(B,/obj/ball)) world << "RED TEAM SCORES!" sleep(20)//Wait a little... B.loc=locate(10,12,1)//enter your coordinates here When i add the code to add a goal to red, it complains about inconsistant indentation... whre on the line do you think it should go? Thanks |
For your other question, its dependent on how you make your ball move. If you're using the walk() proc, you can probably just call it again with a different direction as the argument.