Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[Inne] AtomOS


Rekomendowane odpowiedzi

Opublikowano

Witam, zacząłem uczyć się Lua do modyfikacji ComputerCraft do Minecraft'a, wstawiam tutaj kod, do oceny profesjonalistów, nie jest w 100% skonczony, ale działa zarządzanie redstone'm, menu gier, funkcja uruchom...(małe problemy moga wystapic) oraz uruchamianie painta, obsługiwane myszką wymaga Advanced Computer ale ja pisałem w Emulatorze moda. Jako że chodzi mi o ocene samego kodu to wolałem napisać tutaj.

 

 

 

--kolory
black = colors.black
white = colors.white
red = colors.red
lime = colors.lime
gray = colors.gray
orange = colors.orange
-----------------------
term.setBackgroundColor(white)
term.setTextColor(black)
term.clear()

function dn(n)
	for i=1, n do
	write "\n"
	end
end

function cent(n)
	for i=1, n do
	write " "
	end
end

function clear()
	term.clear()
	term.setCursorPos(1,1)
end

function center(text, height)
	local w, h = term.getSize()
	term.setCursorPos(math.floor(w / 2 - text:len() / 2 + .5), height)
	write (text)
end

function load()
		cent(20)
		for i=1, 11 do
		term.setBackgroundColor(gray)
		write " "
		sleep(0.05)
		end
		term.setBackgroundColor(white)
		term.setCursorPos(1, 1)
		clear()
end

-- szerokosc 51    wysokosc 19

function dot(color)
term.setBackgroundColor(color)
write " "
term.setBackgroundColor(white)
end

function redstone()
clear()
term.setCursorPos(50,1)
term.setBackgroundColor(red)
write "<<"
term.setBackgroundColor(white)
term.setCursorPos(1,1)
dot(orange)
	print " Lewa"
dot(orange)
	print " Prawa"
dot(orange)
	print " Tyl"
dot(orange)
	print " Przod"
dot(orange)
	print " Gora"
dot(orange)
	print " Dol"
	
		if rs.getOutput("left") == false then
			term.setCursorPos(8,1)
			dot(red)
		elseif rs.getOutput("left") == true then
			term.setCursorPos(8,1)
			dot(lime)
		end
		
		if rs.getOutput("right") == false then
			term.setCursorPos(8,2)
			dot(red)
		elseif rs.getOutput("right") == true then
			term.setCursorPos(8,2)
			dot(lime)
		end
		
		if rs.getOutput("back") == false then
			term.setCursorPos(8,3)
			dot(red)
		elseif rs.getOutput("back") == true then
			term.setCursorPos(8,3)
			dot(lime)
		end
		
		if rs.getOutput("front") == false then
			term.setCursorPos(8,4)
			dot(red)
		elseif rs.getOutput("front") == true then
			term.setCursorPos(8,4)
			dot(lime)
		end
		
		if rs.getOutput("top") == false then
			term.setCursorPos(8,5)
			dot(red)
		elseif rs.getOutput("top") == true then
			term.setCursorPos(8,5)
			dot(lime)
		end
		
		if rs.getOutput("bottom") == false then
			term.setCursorPos(8,6)
			dot(red)
		elseif rs.getOutput("bottom") == true then
			term.setCursorPos(8,6)
			dot(lime)
		end
	
	local event, button, xPos, yPos = os.pullEvent()
	if yPos == 1 then
		if xPos >= 1 and xPos <= 8 then
			if rs.getOutput("left") == true then
			rs.setOutput("left", false)
			redstone()
			elseif rs.getOutput("left") == false then
			rs.setOutput("left", true)
			redstone()
			end
		elseif xPos >= 50 and xPos <= 51 then
			home()
		else
		redstone()
		end
	elseif yPos == 2 then
		if xPos >= 1 and xPos <= 8 then
			if rs.getOutput("right") == true then
			rs.setOutput("right", false)
			redstone()
			elseif rs.getOutput("left") == false then
			rs.setOutput("right", true)
			redstone()
			end
		else
		redstone()
		end
	elseif yPos == 3 then
		if xPos >= 1 and xPos <= 8 then
			if rs.getOutput("back") == true then
			rs.setOutput("back", false)
			redstone()
			elseif rs.getOutput("back") == false then
			rs.setOutput("back", true)
			redstone()
			end
		else
		redstone()
		end
	elseif yPos == 4 then
		if xPos >= 1 and xPos <= 8 then
			if rs.getOutput("front") == true then
			rs.setOutput("front", false)
			redstone()
			elseif rs.getOutput("front") == false then
			rs.setOutput("front", true)
			redstone()
			end
		else
		redstone()
		end
	elseif yPos == 5 then
		if xPos >= 1 and xPos <= 8 then
			if rs.getOutput("top") == true then
			rs.setOutput("top", false)
			redstone()
			elseif rs.getOutput("top") == false then
			rs.setOutput("top", true)
			redstone()
			end
		else
		redstone()
		end
	elseif yPos == 6 then
		if xPos >= 1 and xPos <= 8 then
			if rs.getOutput("bottom") == true then
			rs.setOutput("bottom", false)
			redstone()
			elseif rs.getOutput("bottom") == false then
			rs.setOutput("bottom", true)
			redstone()
			end
		else
		redstone()
		end
	else 
	redstone()
	end


end

	function button_check()
	while true do
event, button, xPos, yPos = os.pullEvent("mouse_click")

print("X: "..tostring(xPos)..", ".."Y: " .. tostring(yPos))
sleep(0.8)
home()
	end
end

function run()
clear()
term.setCursorPos (50, 1)
term.setBackgroundColor(red)
term.setTextColor(black)
write "<<"
term.setBackgroundColor(white)

term.setCursorPos(1,1)
dot(orange)
write " Program:"
term.setBackgroundColor(gray)
write "               "
term.setBackgroundColor(white)

while true do
	event, button, xPos, yPos = os.pullEvent("mouse_click")
	if yPos == 1 then
		if xPos >= 10 and xPos <= 25 then
			term.setCursorPos(11,1)
			term.setBackgroundColor(gray)
			a = read()
			term.setBackgroundColor(white)
			term.setCursorPos(1,2)
			dot(orange)
			write " Parametry: "
			term.setBackgroundColor(gray)
			write "                "
			term.setBackgroundColor(white)
			term.setCursorPos(14,2)
			term.setBackgroundColor(gray)
			b = read()
			term.setBackgroundColor(black)
			clear()
			shell.run(a,
				if shell.run(a, == false then
					term.setBackgroundColor(white)
					term.setTextColor(black)
					clear()
					center("Nie ma takiego programu", 10)
					sleep(1.5)
					clear()
					run()
				end
		elseif xPos >= 50 and xPos <= 51 then
			home()
		else
			run()
		end
	else
		run()
	end
	
end
end

function gry()
clear()
dot(orange)
print " Snake"
write "\n"
dot(orange)
print " Adventure"

term.setCursorPos(50,1)
term.setBackgroundColor(red)
write "<<"
term.setBackgroundColor(white)

	local event, button, xPos, yPos = os.pullEvent("mouse_click")
		if yPos == 1 then
			if xPos >= 1 and xPos <= 7 then
			term.setBackgroundColor(black)
			clear()
			shell.run("worm")
			elseif xPos >= 50 and xPos <= 51 then
			clear()
			home()
			else
			gry()
			end
		elseif yPos == 3 then
			if xPos >= 1 and xPos <= 11 then
			term.setBackgroundColor(black)
			clear()
			shell.run("adventure")
			else
			gry()
			end
		else
		gry()
		end

end

function paint()
clear()
term.setTextColor(black)
center("Nazwa obrazu:", 9)
dn(1)
write "                   "
term.setBackgroundColor(gray)
write "           "
term.setTextColor(white)
term.setBackgroundColor(white)
term.setCursorPos(50,1)
term.setBackgroundColor(red)
write "<<"
term.setBackgroundColor(white)


	local event, button, xPos, yPos = os.pullEvent("mouse_click")
		if yPos == 1 then
			if xPos >= 50 and xPos <= 51 then
			clear()
			home()
			else
			paint()
			end
		elseif yPos == 10 then
			if xPos >= 20 and xPos <= 31 then
			term.setCursorPos(20,10)
			term.setBackgroundColor(gray)
			term.setTextColor(white)
			local a = read()
			term.setBackgroundColor(white)
			term.setTextColor(black)
			
				if #a >= 12 then
				clear()
				center("Nazwa za dluga!(11 znakow)", 10)
				sleep(1.5)
				clear()
				paint()
				else
				shell.run("paint", a)
				end
			else
			paint()
			end
		else
		paint()
		end
				
			

term.setTextColor(black)
end

function home()
clear()
term.setTextColor(black)

dot(orange)
print "  Gry\n" --1,1 do 6, 1
dot(orange)
print "  Aplikacje\n"  -- 1,3 do 12 3
dot(orange)
print "  Redstone\n" -- 1, 5 do 11,5
dot(orange)
print "  Uruchom...\n"  --1,7 do 13,7
dot(orange)
print "  Siec\n" --1,9 do 7,9
dot(orange)
print "  Paint\n" --1, 11 do 8, 11



term.setCursorPos(1, 19)
dot(red)
write " Uruchom ponownie" -- 1, 19 do 18, 19
term.setCursorPos(44,19) -- 45, 19 do 51,19
write " Wylacz"
dot(red)
	term.setCursorPos(1, 13)
	function wybor()
		local event, button, xPos, yPos = os.pullEvent("mouse_click")
		if yPos == 19 then
			if xPos >= 1 and xPos <= 18 then
			clear()
				load()
				os.reboot()
			elseif xPos >= 45 and xPos <= 51 then
			clear()
				load()
				os.shutdown()
			else
			home()
			end
			
		elseif yPos == 1 then
			if xPos >= 1 and xPos <= 6 then
				gry()
			else
				home()
			end
		elseif yPos == 3 then
			if xPos >= 1 and xPos <= 12 then
				print "Aplikacje"
				sleep(0.5)
				home()
			else
				home()
			end
		elseif yPos == 5 then
			if xPos >= 1 and xPos <= 11 then
				redstone()
			else
				home()
			end
		elseif yPos == 7 then
			if xPos >= 1 and xPos <= 13 then
				run()
			else
				home()
			end
		elseif yPos == 9 then
			if xPos >= 1 and xPos <= 7 then
				print "Siec"
				sleep(0.5)
				home()
			else
				home()
			end
		elseif yPos == 11 then
			if xPos >= 1 and xPos <= 8 then
				paint()
			else
				home()
			end
		else
		home()
		end
		
	end

				wybor()
	
end

function boot()
center("   AtomOS\n", 10)
	for i=1, 1 or 3 do
		center("   AtomOS\n", 10)
		load()
	end
	sleep(0.001)
	home()
end

boot()



 

 

 

 

Kod w spoilerze albo tu (pastebin)

Opublikowano

Fajna sprawa :) Jak ktos chce sobie OS piac to najlepiej w CC dzięki za pomysł! :)

 

A co do OS to polecam zrobić zużycie pamięci, instalowanie modułów, LAN, podłączanie monitorów (etc.) coś jak GPU :P + APU czyli Karta Muzyczna

Opublikowano

Dużo planów mam, chociażby przeglądarka (przyda się na serwer, planowałem zrobić 1 główny serwer do którego moga podłączyć sie wszystkie komputery z tym systemem, na serwerze mogą być ogłoszenia, jakies stronki dla uzytkownikow itd) jestem w trakcie pisania rednetu, zrobię coś jak outlook żeby odbierac wiadomosci przez RN, i oczywiście jakiś eksplorator plików (chyba użyje z forum moda, tam jest tego pełno a i tak trzeba creditsy zrobić, to moja pierwsza tak duża przygoda z programowaniem :) musze jakoś wykombinować jak instalować aplikacje bez wchodzenia w kod. Obczaje na necie czy jest możliwość zapisania np informacji do pliku .txt, można by tam przetrzymywać np. kontakty z outlook'a(czyt. CraftLook'a) czyli ID komputer z nadanym przez użytkownika opisem :)

Opublikowano

Jak się nie mylę to można by stworzyć serwery ftp, etc. Co powiesz na wspólne "programowanie" w CC? :) Oferuje Serwer Dedykowany z modem CC, możnaby coś fajnego popisać, ostatnio odcinam się od PHP, itp. Chcę odpocząc w innym języku ;)

 

Zapraszam na PW. Podam Ci Info o servie, Skype, etc.

Opublikowano

Wiesz, ja lubię dołączać do czyjegoś projektu lub z nim "rywalizować" proponuję abyśmy stworzyli 2 OS'y (Ty już masz, ja tak za 3-4dni bd pisał swój) i stworzyli przyjazne do obu systemów LAN itp. Możnaby tworzyć serwerownie. Ty byś tworzyć np. Systemy "codzienne" typu Windows (Graficzne) a ja Serwerowe typu Linux (Typowe pod strony www itp. :) )

Pozdrawiam!

Ps. Jestem na wakacjach, także poczytam sobie teraz troszke o API ;)

Opublikowano

Aktualnie mój system to takie podstawowe funkcje jak zarzadzanie redstone'n ale on i nie wyglada najladnie bo pierwszy os jaki napisałem służył do kontrolowania elektrowni atomowe w tekkicie, stąd nazwa AtomOS2 Zastanawiam sie czy nie zacząć pisać 3 wersji, nabrałem troszkę doświadczenia w CC ale jeszcze sporo mi brakuje. UI mojego systemu jest hmmm... powiedzmy że ochydne (parę przycisków z pomaranczowymi kropkami przed napisem, zanim wezmę się za AtomOS3 i tak muszę napisac wlasne API, widziałeś w kodzie i tam jest funkcji, ktorych uzywam w całym kodzie :D (center(), dn(), load()) Masz gg? może nie będziemu tu na forum spamić :D

Opublikowano

Fakt, ja bym chciał aby system był inteligentny, i doradzał userowi ;)

Spam na PW, a co do API to szkoda że chyba w LUA nie ma czegoś takiego jak include :/

  • 2 tygodnie później...
  • 3 tygodnie później...
Opublikowano

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...