antiblock
Elveron
  • Chatbox

    You don't have permission to chat.
    Load More
Sign in to follow this  
NewWars

[Python] Sistema Dia-Noite

15 posts in this topic

Boas pessoal


Peguei no codigo http://cyber-gamers.org/topic/20963-sistema-day-night-em-phyton-com-skybox/ que aqui está, que está muito mal feito e horrível, e simplifiquei a cena.


 


root/constInfo.py



CURRENT_DAY_MODE = 0

root/game.py



# SYSTEM_DAYMODE
def DayModeSystem(self):
localtime = time.strftime("%H")
dayMode = constInfo.CURRENT_DAY_MODE
if (localtime >= "21" and localtime <= "23") or (localtime >= "00" and localtime <= "04"): #NOITE
dayMode = 6

if localtime >= "11" and localtime <= "16": #DIA CLARO
dayMode = 3

if localtime >= "05" and localtime <= "07": #AMANHECER
dayMode = 1

if localtime >= "08" and localtime <= "10": #MANHÃ
dayMode = 2

if localtime == "17" or localtime == "18": #TARDE
dayMode = 4

if localtime == "19" or localtime == "20": #ANOITECER
dayMode = 5

if constInfo.CURRENT_DAY_MODE == dayMode:
return

constInfo.CURRENT_DAY_MODE = dayMode

self.dayModesDirectories ={
1 : {1 : "d:/ymir work/environment/mtthunder.msenv", 2 : 2},
2 : {1 : "d:/ymir work/environment/morning.msenv", 2 : 2},
3 : {1 : "d:/ymir work/environment/capedragonhead.msenv", 2 : 2},
4 : {1 : "d:/ymir work/environment/evening.msenv", 2 : 2},
5 : {1 : "d:/ymir work/environment/bayblacksand.msenv", 2 : 2},
6 : {1 : "d:/ymir work/environment/moonlight04.msenv", 2 : 1},
}

background.RegisterEnvironmentData(self.dayModesDirectories[dayMode][2], self.dayModesDirectories[dayMode][1])
background.SetEnvironmentData(self.dayModesDirectories[dayMode][2])

# END_SYSTEM_DAYMODE

 

e no def OnUpdate adicionem:



self.DayModeSystem()

Codigo muito mais limpo e facil de entender/modificar/whatever.


Comparem o codigo dos dois, plz.


Hasta


Share this post


Link to post
Share on other sites
antiblock
diamwall

 

Boas pessoal

Peguei no codigo http://cyber-gamers.org/topic/20963-sistema-day-night-em-phyton-com-skybox/ que aqui está, que está muito mal feito e horrível, e simplifiquei a cena.

 

root/constInfo.py

CURRENT_DAY_MODE = 0

root/game.py

# SYSTEM_DAYMODE
	def	DayModeSystem(self):
		localtime = time.strftime("%H")
		dayMode = constInfo.CURRENT_DAY_MODE
		if (localtime >= "21" and localtime <= "23") or (localtime >= "00" and localtime <= "04"): #NOITE
			dayMode = 6
				
		if localtime >= "11" and localtime <= "16": #DIA CLARO
			dayMode = 3
				
		if localtime >= "05" and localtime <= "07": #AMANHECER
			dayMode = 1
				
		if localtime >= "08" and localtime <= "10": #MANHÃ
			dayMode = 2
				
		if localtime == "17" or localtime == "18": #TARDE
			dayMode = 4
				
		if localtime == "19" or localtime == "20": #ANOITECER
			dayMode = 5
		
		if constInfo.CURRENT_DAY_MODE == dayMode:
			return
			
		constInfo.CURRENT_DAY_MODE = dayMode
		
		self.dayModesDirectories ={
			1	:	{1 : "d:/ymir work/environment/mtthunder.msenv", 2 : 2},
			2	:	{1 : "d:/ymir work/environment/morning.msenv", 2 : 2},
			3	:	{1 : "d:/ymir work/environment/capedragonhead.msenv", 2 : 2},
			4	:	{1 : "d:/ymir work/environment/evening.msenv", 2 : 2},
			5	:	{1 : "d:/ymir work/environment/bayblacksand.msenv", 2 : 2},
			6	:	{1 : "d:/ymir work/environment/moonlight04.msenv", 2 : 1},
		}

		background.RegisterEnvironmentData(self.dayModesDirectories[dayMode][2], self.dayModesDirectories[dayMode][1])
		background.SetEnvironmentData(self.dayModesDirectories[dayMode][2])
		
	# END_SYSTEM_DAYMODE
 
e no def OnUpdate adicionem:
self.DayModeSystem()

Codigo muito mais limpo e facil de entender/modificar/whatever.

Comparem o codigo dos dois, plz.

Hasta

 

 

Giiii parece que algo deu errado a barra de login passa chega ao fim nao sai dali...

 

syss

 

0306 04:12:36276 :: GRANNY: r:/granny/rt/granny_file_info.cpp(145): File has run-time type tag of 0x8000000f, which doesn't match this version of Granny (0x80000010).  Automatic conversion will be attempted.
0306 04:12:49664 :: Traceback (most recent call last):
 
0306 04:12:49664 ::   File "networkModule.py", line 245, in SetGamePhase
 
0306 04:12:49665 ::   File "system.py", line 130, in __pack_import
 
0306 04:12:49665 ::   File "
0306 04:12:49665 :: <string>
0306 04:12:49665 :: ", line 
0306 04:12:49665 :: 2283
0306 04:12:49665 :: 
 
0306 04:12:49665 ::     
0306 04:12:49665 :: # END_SYSTEM_DAYMODE
0306 04:12:49665 :: 
 
0306 04:12:49665 ::     
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 :: ^
 
0306 04:12:49666 :: SyntaxError
0306 04:12:49666 :: : 
0306 04:12:49666 :: invalid syntax
0306 04:12:49666 :: 

Share this post


Link to post
Share on other sites

 

Giiii parece que algo deu errado a barra de login passa chega ao fim nao sai dali...

 

syss

 

0306 04:12:36276 :: GRANNY: r:/granny/rt/granny_file_info.cpp(145): File has run-time type tag of 0x8000000f, which doesn't match this version of Granny (0x80000010).  Automatic conversion will be attempted.
0306 04:12:49664 :: Traceback (most recent call last):
 
0306 04:12:49664 ::   File "networkModule.py", line 245, in SetGamePhase
 
0306 04:12:49665 ::   File "system.py", line 130, in __pack_import
 
0306 04:12:49665 ::   File "
0306 04:12:49665 :: <string>
0306 04:12:49665 :: ", line 
0306 04:12:49665 :: 2283
0306 04:12:49665 :: 
 
0306 04:12:49665 ::     
0306 04:12:49665 :: # END_SYSTEM_DAYMODE
0306 04:12:49665 :: 
 
0306 04:12:49665 ::     
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 :: ^
 
0306 04:12:49666 :: SyntaxError
0306 04:12:49666 :: : 
0306 04:12:49666 :: invalid syntax
0306 04:12:49666 :: 

 

Bad syntax num comentario? Nossa, que hacks...

Simplesmente apaga isso

Share this post


Link to post
Share on other sites
0306 04:12:49665 :: ", line 
0306 04:12:49665 :: 2283
0306 04:12:49665 :: # END_SYSTEM_DAYMODE

# END_SYSTEM_DAYMODE na linha 2283

Share this post


Link to post
Share on other sites

continua a dar o mesmo erro se poderes ver isto se ta a faltar algo

 

https://mega.nz/#!P5MgCK5Z!fvETdKzLbg1HGNAe-9p3PGS3H0rO6Sge8r5XY5kGrGQ

Viruztutal: https://www.virustotal.com/pt/file/5ad8796cfd1410d59b93eaadde6ee7fbfa90d76ff005fcef0a96c29102ae3334/analysis/1457235314/

Share this post


Link to post
Share on other sites

amigo coloca a img do erro

 

 

OBS: Tem Client que não da para alterar o root que fica dando erro

Share this post


Link to post
Share on other sites

continua a dar o mesmo erro se poderes ver isto se ta a faltar algo

 

https://mega.nz/#!P5MgCK5Z!fvETdKzLbg1HGNAe-9p3PGS3H0rO6Sge8r5XY5kGrGQ

Viruztutal: https://www.virustotal.com/pt/file/5ad8796cfd1410d59b93eaadde6ee7fbfa90d76ff005fcef0a96c29102ae3334/analysis/1457235314/

O fim do ficheiro têm que ter pelo menos uma nova linha limpa sem nada.

Share this post


Link to post
Share on other sites

amigo coloca a img do erro

 

mano tipo meto id e pass escolho a personagem quando chega a barra ela enche mas não passa dali nao entra no jogo fica sempre na barra cheia 

e no syserr do cliente aparece:

 

Giiii parece que algo deu errado a barra de login passa chega ao fim nao sai dali...

 

syss

 

0306 04:12:36276 :: GRANNY: r:/granny/rt/granny_file_info.cpp(145): File has run-time type tag of 0x8000000f, which doesn't match this version of Granny (0x80000010).  Automatic conversion will be attempted.
0306 04:12:49664 :: Traceback (most recent call last):
 
0306 04:12:49664 ::   File "networkModule.py", line 245, in SetGamePhase
 
0306 04:12:49665 ::   File "system.py", line 130, in __pack_import
 
0306 04:12:49665 ::   File "
0306 04:12:49665 :: <string>
0306 04:12:49665 :: ", line 
0306 04:12:49665 :: 2283
0306 04:12:49665 :: 
 
0306 04:12:49665 ::     
0306 04:12:49665 :: # END_SYSTEM_DAYMODE
0306 04:12:49665 :: 
 
0306 04:12:49665 ::     
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49665 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 ::  
0306 04:12:49666 :: ^
 
0306 04:12:49666 :: SyntaxError
0306 04:12:49666 :: : 
0306 04:12:49666 :: invalid syntax
0306 04:12:49666 :: 
 
já passei # END_SYSTEM_DAYMODE  para a linha 2283 e apague o syserr voltei a tentar e aparece exatamente a mesma coisa e aquilo nao passa da barra será do cliente

Share this post


Link to post
Share on other sites

O fim do ficheiro têm que ter pelo menos uma nova linha limpa sem nada.

Eu sou realmente BASTANTE BURRO xD

Obrigado Giselle resolveu  :) 

Share this post


Link to post
Share on other sites

xD

já esta resolvido xD esqueci de deixar a linha final em branco xD

 

Obrigado Gi

Share this post


Link to post
Share on other sites

Por-favor, façam um favor a toda a gente e antes de sequer mexerem com uma linguagem de programação, aprendam o basico.

https://www.codecademy.com/learn/python

 

Poupam bastante tempo e paciência aos outros.

 

PS: E aprendam a ler, inglês tambem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this