ID:1745328
 
Code:
mob

var/O = /obj/rockT
proc
TrainingRock()
spawn(10)
var/obj/rock/R1 = new/obj/rockT
world << "test"


Problem description: To be honest the code above is all I have at the moment and it might not even be right. I'm trying to figure out how to make a new obj appear on the game. I need the rock to stay dense. The idea is for the player to catch the rock from the other side of the fence but the player can't cross the fence. So the rock starts from the Rock tosser, moves south 4-5 tiles goes through the fence, and if the player is on the other side of the fence the player will catch the rock. If not the rock will del.

For right now I'm just trying to figure out how to make the object appear in the game without me adding it to the map.

I want to learn what I am doing so if you can provide me with what command I need to look into or a small snippet for me to test and learn from that would be great! Thanks


You can pass a location in parentheses.
new /mob(locate(1,1,1))

Also, that indentation with the world statement isn't going to work.
Thanks for the advice. Im currently this far.

mob

var/O = /obj/rockT
proc
TrainingRock()
spawn(10)
var/RT = new /obj/rockT
var/S = /obj/shooter


What I'm stuck on is I have 5 shooters lined up next to each other. I want the rock to appear on the screen 1 spot lower (y-1) from a random shooter. To make things more complicated. If I were to make another one of these 5 shooters somewhere else on the map. I don't want the rock going to one of them but to 1 of the 5 the player is currently at.

I seem to have a lot of trouble figuring out the loc and locate code. Any advice on any of the above would be greatly appreciated.
mob

var/O = /obj/rockT
var/NOF = 0 //Number Of Rocks
proc
TrainingRock(var/obj/rockT/o as obj)
spawn(10)
var/RT = new /obj/rockT
var/S = /obj/shooter
var/MS = /obj/shooterM // Main Shooter
var/RL = rand(-2,2) // Random X location from Main Shooter
if(NOF == 0)
o.Move(RL,10,1,Dir=SOUTH)
world << "RT [RT], S[S], src[src], o[o]" //RT is rockt, S is shooter, src is me, o is me


Still playing around with this but how do I get rockT to be o or use RT.Move? everytime I try it gives me an error about it being a proc. I want to control the location of rockT. What am I missing?
You need to clarify in your own mind what exactly you're trying to do. Names like:

                var/S = /obj/shooter
var/MS = /obj/shooterM // Main Shooter

confuse the matter no-end.

I'm at work, so can't run DreamMaker, so this code probably WILL NOT COMPILE. But it should demonstrate how I would approach this.

obj
Rock
icon='bla.dmi'
icon_state="Rock"

mob
RockThrower
var/numberOfRocks = 1
proc
TrainingRocks()
if(src.numberOfRocks) //Ensure RockThrower has more rocks to throw
var/obj/Rock/rock = new(locate(src.x,src.y-1,src.z) //Create a new rock run tile below the RockThrower
walk(rock,src.dir,5,0) //move the rock in the direction RockThrower is facing.
src.numberOfRocks-- //Reduce number of rocks left by one.


Remember; this is a proc, so it won't do anything until you call it. You'll need to describe some context before anyone can offer help on how/when to do that.

And you asked about loc and locate. loc is a var that belongs to an atom. It is WHERE that atom is or, more correctly, WHAT that atom is INSIDE.

For co-ords of an atom, use x, y, z.

locate (http://www.byond.com/docs/ref/info.html#/proc/locate) FINDS things. If you give it x,y,z it will FIND and RETURN the turf there. If you ask it for a type of object, and give it a list of objects, it will FIND and RETURN an object of the specified type.
I've gotten much further with my training process but I'm having a lot of trouble with calling a proc under a different atom. I've tried looking into a call() but either im doing it wrong or its not what I should be using.

I have a Bump() under the parent mob that works great for when the mob bumps into the rock(projectile). However if the mob gets to where the rock is heading and waits there until the rock bumps the mob it wont run that code.

So I had to make a Bump() under the parent obj that kind of does what I want it to but it has to delete the rock upon hitting the mob. I want to call my proc "mob/proc/TrainingRock" from the "obj/Bump". It gives the error undefined proc.

Is there any way for me to call that proc from obj/Bump? It will run the new rock projectile. If my code is needed to explain this just let me know. Thanks for your time.
I think I know what you're asking, but I'm not sure.

Assuming that you have Bump(mob/m), you could call the proc with m.TrainingRock(). You would want to put in some sanity checks as well, in case it doesn't actually bump a mob.
What do I check for when the src bumps into the edge of the game? not the turf, a mob, or an obj. Just the edge of the game. I want to delete the src when it bumps into the edge of the game but I'm not sure what its called.
There isn't anything there, so there is nothing to bump. You'll have to do it a different way. Maybe like having a turf that checks if the next turf in that direction exists or not upon Exit().