Stargate Journey

Stargate Journey

5M Downloads

Computercraft Examples

Herobr1ne opened this issue ยท 7 comments

commented

Hey,
I want wo ask if its possible for you to post some computercraft examples? Maybe a lua script that calls a specific address.
I have problems to create some cause i dont find any examples yet for this mod.

commented

I have one (not exactly great, but working) example specifically for Milky Way gates here

The other gates are much simpler to dial with computers in comparison, since all that's needed to dial is to use the engageSymbol() method multiple times in a row.

commented

Really nice, But how can u open the portal without the use of an dhd to push the button? I cant to seem to open the portal with cc: tweaked. How could wwe do that?

commented

Really nice, But how can u open the portal without the use of an dhd to push the button? I cant to seem to open the portal with cc: tweaked. How could wwe do that?

By encoding the Point of Origin, which is Symbol 0. Basically, the same steps you've done to encode the other Symbols of the Address you repeat for 0.

commented

Thnx, is that the same for the other galaxy's? As i remember in the series and movies they have an other point of origin, Like when i want to go to pegasus galaxy with the milkyway portal? Still use the 0 at the end ?

I love ur example, im writing my own scripe and make a loop with a button to close the program, and eventual i will make the monitor info for it.

commented

Nope, the Point of Origin was always the end for Extragalactic Addresses even in the show. The extra Symbol is actually a prefix at the start of the Address.

Mechanic-wise, the entire Address changes when dialing, so for example the Earth Address which is normally -27-25-4-35-10-28- becomes -1-35-4-31-15-30-32- (both are based on the Addresses shown in the show) but as in general, I give all the Extragalactic Addresses in the same Galaxy the same prefix, so all Extragalactic Addresses for Milky Way planets start with 1 and for Pegasus with 18.

The Extragalactic Address for Lantea itself is -18-20-1-15-14-7-19-

commented

Here is my example for now

-- For advance computers else change colours to black and white!!

sleep(1)

local interface
local Monitor
local OldTerm
local test
local MonitorState = "T"
local found = false

local CLS = term.clear
local setCurs = term.setCursorPos
local Loop = true

for i,name in pairs(peripheral.getNames()) do

for j,method in pairs(peripheral.getMethods(name)) do
	
	if (method == 'clear') then
        
        Monitor = peripheral.wrap(name)
		found = true
		
    end
    
	if (found) then
		
		break
		
	end

end

if (found) then
	
	break
	
end

end

if Monitor then
OldTerm = term.redirect(Monitor)
MonitorState = "M"
end

local X, Y

if MonitorState == "M" then
X, Y = Monitor.getSize()
elseif MonitorState == "T" then
X, Y = term.getSize()
end

local X2, Y2 = X / 2, Y /2
local a = X + 1 - X2
local b = Y + 1 - Y2

local MenuScreen = window.create(term.current(),1,1,X2,Y)
MenuScreen.setBackgroundColour(colours.blue)
MenuScreen.setTextColour(colours.white)
MenuScreen.clear()
local MenuScreenX, MenuScreenY = MenuScreen.getSize()
local MenuScreenX2, MenuScreenY2 = MenuScreenX/2, MenuScreenY/2

local DailScreen = window.create(term.current(),X2+1,1,a,Y2)
DailScreen.setBackgroundColour(colours.green)
DailScreen.setTextColour(colours.black)
DailScreen.clear()
local DailScreenX, DailScreenY = DailScreen.getSize()
local DailScreenX2, DailScreenY2 = DailScreenX/2, DailScreenY/2

local IncomingScreen = window.create(term.current(),X2+1,Y2+1,a,b)
IncomingScreen.setBackgroundColour(colours.red)
IncomingScreen.setTextColour(colours.black)
IncomingScreen.clear()
local IncomingScreenX, IncomingScreenY = IncomingScreen.getSize()
local IncomingScreenX2, IncomingScreenY2 = IncomingScreenX/2, IncomingScreenY/2

local Text = ""
local timer

local Addresses = {
[1] = {
Name = "Abydos",
Address = {26,6,14,31,11,29,0}
},
[2] = {
Name = "Chulak",
Address = {8,1,22,14,36,19,0}
},
[3] = {
Name = "Lantea",
Address = {18,20,1,15,14,7,19,0}
},
[4] = {
Name = "Earth",
Address = {16,23,32,12,19,15,18,22,0} -- own made potal
},
[5] = {
Name = "Space Fairy",
Address = {35,27,26,29,34,25,23,31,0} -- Space station orbid
},
[6] = {
Name = "Nether Roof",
Address = {8,35,34,25,14,27,15,2,0} -- found nether roof portal
}
} -- add your own adress to TXT or Press = in Menu

local file

if fs.exists("Addresses.txt") then
file = fs.open("Addresses.txt", "r")
Addresses = textutils.unserialize(file.readAll())
file.close()
else
file = fs.open("Addresses.txt", "w")
file.write(textutils.serialize(Addresses))
file.close()
end

found = false

for i,name in pairs(peripheral.getNames()) do

for j,method in pairs(peripheral.getMethods(name)) do
	
	if (method == 'getChevronsEngaged') then
		
		interface = peripheral.wrap(name)
		found = true
		
	end
	
	if (found) then
		
		break
		
	end
	
end

if (found) then
	
	break
	
end

end

function SaveFile()
file = fs.open("Addresses.txt", "w")
file.write(textutils.serialize(Addresses))
file.close()
end

function dial(address)
local a = address.Address
local addressLength = #a
local start = interface.getChevronsEngaged() + 1

term.setBackgroundColour(colours.green)
term.setTextColour(colours.black)

DailScreen.clear()

for chevron = start,addressLength,1 do
	
    local symbol = address.Address[chevron]
    
    if chevron % 2 == 0 then
        interface.rotateClockwise(symbol)
    else
        interface.rotateAntiClockwise(symbol)
    end
    
	DailScreen.clear()
	DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1)
	print("Dailing:",address.Name)
	DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2)
	print("Symbol:",chevron," = ",symbol)
	DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 + 1)
	print("State: Locating")
	
	while(not interface.isCurrentSymbol(symbol)) do
        sleep(0)
    end
	
	if interface.raiseChevron() == 11 then
		
	    DailScreen.clear()
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1)
		print("Dailing:",address.Name)
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2)
		print("Symbol:",chevron," = ",symbol)
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 + 1)
		print("State: Lock On")
		sleep(1)
	end
	
	if interface.lowerChevron() == 1 then
		
		DailScreen.clear()
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1)
		print("Dailing:",address.Name)
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2)
		print("Symbol:",chevron," = ",symbol)
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 + 1)
		print("State: Locked")
		sleep(1)
	end
	
	if chevron == addressLength then
		
		DailScreen.clear()
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1)
		print("Opening portal to:")
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2)
		print(address.Name)
		sleep(3)
		DailScreen.clear()
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1)
		print("Portal Open to")
		DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2)
		print(address.Name)
		term.setBackgroundColour(colours.red)
		IncomingScreen.clear()
		IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 - 1)
		print("Incoming Portal from ")
		IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2)
		print("?")
		IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 + 1)
		print("Portal Open True")
		while interface.isStargateConnected() do
			timer = os.startTimer(3)
			local Event, p1, p2, p3, p4, p5 = os.pullEvent()
			if Event == "timer" then
				sleep(0)
			elseif Event == "key" then
				if p1 == keys.zero or p1 == keys.numPad0 then
					interface.disconnectStargate()
				end
			end
		end
	end
end

term.setBackgroundColour(colours.blue)
term.setTextColour(colours.white)

end

function Incoming()

term.setBackgroundColour(colours.red)
term.setTextColour(colours.black)

MenuScreen.clear()

IncomingScreen.clear()
IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 - 1)
print("Incoming Portal from ")
IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2)
print("?")
IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 + 1)
print("Portal Open True")
while interface.isStargateConnected() do
	timer = os.startTimer(3)
	local Event, p1, p2, p3, p4, p5 = os.pullEvent()
	if Event == "timer" then
		sleep(0)
	elseif Event == "key" then
		if p1 == keys.zero or p1 == keys.numPad0 then
			interface.disconnectStargate()
		end
	end
end
IncomingScreen.clear()
term.setBackgroundColour(colours.blue)
term.setTextColour(colours.white)
CLS()

end

function Recount()

if MonitorState == "T" then
	X, Y = term.getSize()
elseif MonitorState == "M" then
	X, Y = Monitor.getSize()
end

X2, Y2 = X / 2, Y /2
a = X + 1 - X2
b = Y + 1 - Y2

MenuScreen.reposition(1,1,X2,Y,term.current())
MenuScreenX, MenuScreenY = MenuScreen.getSize()
MenuScreenX2, MenuScreenY2 = MenuScreenX/2, MenuScreenY/2

DailScreen.reposition(X2+1,1,a,Y2,term.current())
DailScreenX, DailScreenY = DailScreen.getSize()
DailScreenX2, DailScreenY2 = DailScreenX/2, DailScreenY/2

IncomingScreen.reposition(X2+1,Y2+1,a,b,term.current())
IncomingScreenX, IncomingScreenY = IncomingScreen.getSize()
IncomingScreenX2, IncomingScreenY2 = IncomingScreenX/2, IncomingScreenY/2

end

function AddAddress()

CLS()
setCurs(1,Y2)
term.write("Name: ")
local name = io.read()

CLS()
setCurs(1,Y2)
term.write("Close with a zero")
setCurs(1,Y2+1)
term.write("Adress A:")
local A = tonumber(io.read())
local B
local C
local D
local E
local F
local G
local H
local I

if A ~= 0 and A ~= nil then
	CLS()
	setCurs(1,Y2)
	term.write("Close with a zero")
	setCurs(1,Y2+1)
	term.write("Adress B:")
	B = tonumber(io.read())
end

if B ~= 0 and B ~= nil then
	CLS()
	setCurs(1,Y2)
	term.write("Close with a zero")
	setCurs(1,Y2+1)
	term.write("Adress C:")
	C = tonumber(io.read())
end

if C ~= 0 and C ~= nil then
	CLS()
	setCurs(1,Y2)
	term.write("Close with a zero")
	setCurs(1,Y2+1)
	term.write("Adress D:")
	D = tonumber(io.read())
end

if D ~= 0 and D ~= nil then
	CLS()
	setCurs(1,Y2)
	term.write("Close with a zero")
	setCurs(1,Y2+1)
	term.write("Adress E:")
	E = tonumber(io.read())
end

if E ~= 0 and E ~= nil then
	CLS()
	setCurs(1,Y2)
	term.write("Close with a zero")
	setCurs(1,Y2+1)
	term.write("Adress F:")
	F = tonumber(io.read())
end

if F ~= 0 and F ~= nil then
	CLS()
	setCurs(1,Y2)
	term.write("Close with a zero")
	setCurs(1,Y2+1)
	term.write("Adress G:")
	G = tonumber(io.read())
end

if G ~= 0 and G ~= nil then
	CLS()
	setCurs(1,Y2)
	term.write("Close with a zero")
	setCurs(1,Y2+1)
	term.write("Adress H:")
	H = tonumber(io.read())
end

if H ~= 0 and H ~= nil then
	CLS()
	setCurs(1,Y2)
	term.write("Close with a zero")
	setCurs(1,Y2+1)
	term.write("Adress I:")
	I = tonumber(io.read())
end

local Data = { Name = tostring(name), Address = {A, B, C, D, E, F, G, H, I} }

table.insert(Addresses, Data)

SaveFile()

end

CLS()
MenuScreen.clear()

while Loop do

timer = os.startTimer(1)

term.setBackgroundColour(colours.blue)
term.setTextColour(colours.white)

MenuScreen.setCursorPos(2, MenuScreenY2 - 4)
print("Awaiting input:")

local z = MenuScreenY2 - 3

for i in pairs(Addresses) do
	z = z + 1
	MenuScreen.setCursorPos(2, z)
	if i <= 9 then
		print(i," = ",Addresses[i].Name)
	-- elseif i == 10 then
		-- print("A = ",Addresses[i].Name)
	-- elseif i == 10 then
		-- print("A = ",Addresses[i].Name)
	end
end

MenuScreen.setCursorPos(2, z+2)
print("Q = Quit Program")

term.setBackgroundColour(colours.green)
term.setTextColour(colours.black)

DailScreen.clear()
DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 - 1)
print("Dailing:")
DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2)
print("Symbol:")
DailScreen.setCursorPos(DailScreenX2 - 10, DailScreenY2 + 1)
print("State:")

term.setBackgroundColour(colours.red)
term.setTextColour(colours.black)

IncomingScreen.clear()
IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 - 1)
print("Incoming Portal from ")
IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2)
print("?")
IncomingScreen.setCursorPos(IncomingScreenX2 - 10, IncomingScreenY2 + 1)
print("Portal Open False")

term.setBackgroundColour(colours.blue)
term.setTextColour(colours.white)

local Event, p1, p2, p3, p4, p5 = os.pullEvent()

if Event == "key" then
	
	MenuScreen.clear()
	
	if p1 == keys.one or p1 == keys.numPad1 then
		dial(Addresses[1])
	elseif p1 == keys.two or p1 == keys.numPad2 then
		dial(Addresses[2])
	elseif p1 == keys.three or p1 == keys.numPad3 then
		dial(Addresses[3])
	elseif p1 == keys.four or p1 == keys.numPad4 then
		dial(Addresses[4])
	elseif p1 == keys.five or p1 == keys.numPad5 then
		dial(Addresses[5])
	elseif p1 == keys.six or p1 == keys.numPad6 then
		dial(Addresses[6])
	elseif p1 == keys.m and Monitor then -- Change to monitor or back to terminal
		if MonitorState == "T" and Monitor then
			term.setBackgroundColour(colours.black)
			CLS()
			OldTerm = term.redirect(Monitor)
			MonitorState = "M"
			Recount()
			term.setBackgroundColour(colours.blue)
		elseif MonitorState == "M" and Monitor then
			term.setBackgroundColour(colours.black)
			CLS()
			test = term.redirect(OldTerm)
			MonitorState = "T"
			Recount()
			term.setBackgroundColour(colours.blue)
		end
	elseif p1== keys.equals then
		AddAddress()
	elseif p1 == keys.q then
		Loop = false
		CLS()
		setCurs(1, 1)
	elseif p1 == keys.zero or p1 == keys.numPad0 then
		interface.disconnectStargate()
	end
	
	DailScreen.clear()
	CLS()
	
elseif Event == "timer" then
	
	if interface.isStargateConnected() == true then
		Incoming()
	end
	
end

end

os.reboot()

<

commented

Oh wow, that's quite an impressive program