ID:143910
 
Take 2 here for referance.
http://developer.byond.com/forum/ index.cgi?action=message_read&id=549224&forum=3&view=1

Ok the third take on my little learning spree

        Gate
icon='PGate.dmi'
var/address=""
var/active=0
var/busy=0
var/obj/Stargate/Gate/G
var/obj/DHD/D
Bumped(atom/O)//line 68
if(G.address==D.current)
src.loc = locate(G.x,G.y-1,G.z)

atom/proc/Bumped(atom/movable/bumped_by)
atom/movable/Bump(atom/O)
if(O) O.Bumped(src)


runtime error: Cannot read null.address
proc name: Bumped (/obj/Stargate/Gate/Bumped)
source file: Stargates.dm,68
usr: Yorae (/mob)
src: Gate (/obj/Stargate/Gate)
call stack:
Gate (/obj/Stargate/Gate): Bumped(Yorae (/mob))
Yorae (/mob): Bump(Gate (/obj/Stargate/Gate))

In my DHD i made the gate solid after you finish dialing so you can bump it after the gate activation, but when i bump the gate i get an runtime error. I've tracked down the error to the above code. I'm really sure i was right on this one but i guess not.
You didn't show the actual error, you cut the top off :P

Check that both G and D are being set correctly. It's likely one of them is null, which would give you a "cannot read null.[var]" error.
In response to DarkCampainger
DarkCampainger wrote:
You didn't show the actual error, you cut the top off :P

Fixed.
In response to Yorae
Yea, I guessed right. G isn't set the gate as you expected. Is it supposed to be the gate you're connected to?

Scratch that, of course it is. Check that you're actually setting G after you contact the other gate.
In response to DarkCampainger
Heres the new dhd.... i was going to add this on to the other post but you posted....
    DHD
icon='PDHD.dmi'
icon_state="DHD"
var/memory=""
var/current
var/obj/Stargate/Gate/G
DblClick()
memory=""
current=""
current = "[input("Dial me") as num|null]"
current += "[input("Dial me") as num|null]"
current += "[input("Dial me") as num|null]"
current += "[input("Dial me") as num|null]"
current += "[input("Dial me") as num|null]"
current += "[input("Dial me") as num|null]"
memory += num2text(current)
for(G in world)//as well bellow
if(G.address==current)//line that detects the gate in world
flick("woosh",G)
G.density=1
//die()
for(G in view(9))
flick("woosh",G)
G.density=1
In response to DarkCampainger
Check that you're actually setting G after you contact the other gate.

I don't get what you mean
In response to Yorae
Instead of giving blocks of code, I'm going to walk you through the steps. If I explain something poorly, I'll be glad to go through it in further detail. GateA and DHDA will be on your side of the wormhole, and GateB and DHDB will be the other side.

Ok, first thing you need to do is connect GateA/B/C with its nearby DHDA/B/C. Now, if you do this at New() and set it to a variable, you won't need to worry about it again (for now). I would suggest doing it under /obj/DHD/New() since you're more likely to find a DHD-less Gate than a Gate-less DHD. You have the basic idea down at the end of the DblClick(): Loop through the surrounding area for a gate. However, this time you're going to save what you find in a variable (Give it a good name, like Gate or CGate). Also, instead of just setting the DHD's connected Gate, also set the Gate's connected DHD.

Now that everything knows what it's connected to on its side of the wormhole, you can set up the variables for the other side. When you establish a connection at the end of DblClick(), a few variables need to be set. First, you need to save GateB to a variable in GateA. This is the variable that we'll use to send players through. You also need to set the density for both GateA and GateB, set them to active, and busy (is there a difference between this and active?).

Arg, I'm losing my train of thought, so here's an ordered list:

1. Connect Gates to DHDs and vice-versa in obj/DHD/New()
2. Once you dial:
- A. Save GateB in a variable in GateA
- B. Send GateA/B's densities
- C. Set active and busy for both gates
- D. Set icons
3. When a player bumps into a gate, check if it is active
- A. If it is, check if there is Gate in the variable (Step 2)
- - - I.  If there is a gate, set the player loc to that gate's loc
- - - II. If not, kill them (If you want wormholes one-way, like in the show)
- B. If not, do nothing
4. Set up a timer for the players to get through the gate. When it runs out:
- A. Set both gates Active to 0
- B. Turn off their densities
- C. Set the variable to the other gate to null
- D. Reset icon


I think that about covers it.
In response to DarkCampainger
I understood everything you said but.

Connect Gates to DHDs and vice-versa in obj/DHD/New()

Would you beable to explain this in more detail.
In response to Yorae
Yorae wrote:
I understood everything you said but.

Connect Gates to DHDs and vice-versa in obj/DHD/New()

Would you beable to explain this in more detail.

Sure. Under obj/DHD/New(), you're going to loop through all object in the surrounding area looking for the gate:
obj
Stargate
Gate
var/obj/DHD/DHD
obj
DHD
var/obj/Stargate/Gate/Gate
New()
Gate = locate() in range(9,src) //Locate a Gate in range and set our Gate variable to it. (Type defaults to the type of the variable)
if(Gate) //If one was found, Gate will have a value
Gate.DHD=src //Set that gate's DHD to this
break //Don't bother looking any further
..()


Now the DHD has a link to its Gate (src.Gate), and vice-versa (Gate.DHD).
In response to DarkCampainger
Ok i think i get it all now thanks for the help again i really appreciate it.

But i think you made a few errors in your code you posted.