Aller au contenu


Script Pour Changer Le Niveau D'eau


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1 Timalk-Ae

Timalk-Ae

    PoneyMaster !


Posté 04 mars 2006 - 18:19

Kuku !
Voilà je me suis remit au script (et j'ai pas commencé par le plus simple  :D ) et j'aimerais en faire un pour qu'à l'activation d'un levier (qui tournera), une cascade apparaisse, fasse monter le niveau d'eau, et disparaisse. Puis à la réactivation du levier (qui retournera), que le niveau d'eau baisse.
Ca marche pas  :)
Une fois que le niveau d'eau est monté, la cascade et le son disparu, à la réactivation du levier, rien ne se passe.
Si qqun voit où est le problème, mercimercimercimerci d'avance ^^
(La précision du niveau d'eau et l'angle du levier ne sont pas capitaux)

PS : Peut-être qu'il y a des moyens d'optimiser le script, je suis doué pour faire des trucks de 300lignes pour rien ^^
begin TIK_1_scr_levier1

Short Sens
Short Etat
Short Position
Float Position2
Short EauE
Float EauM

Set Position2 to GetAngle, Y
Set EauM to GetWaterLevel

If ( OnActivate == 1 )
	If ( Etat == 0 )
		If ( Sens == 0 )
			Set Position to GetAngle, Y 
			Set Etat to 1
		Elseif ( Sens == 1 )
			Set Position to GetAngle, Y
			Set Etat to 1
		Endif
	Else
		Return
	Endif
Endif

If ( Etat == 1 )
	If ( Sens == 0 )
		Set Position to ( Position + 90 )
		Set Etat to 2
	Elseif ( Sens == 1 )
		Set Position to ( Position - 90 )
		Set Etat to 2
	Endif
Endif

If ( Etat == 2 )
	If ( Sens == 0 )
		If ( Position2 <= Position )
			Rotate, Y, 40
		Else
			Set Etat to 3
		Endif
	Elseif ( Sens == 1 )
		If ( Position 2 >= Position )
			Rotate, Y, -40
		Else
			Set Etat to 3
		Endif
	Endif
Endif

If ( Etat == 3 )
	If ( Sens == 0 )
		"TIK_1_act_cascade1"->SetPos Z 23
		"TIK_1_act_ecla1"->SetPos Z -52
		"TIK_1_act_ecla2"->SetPos Z -105
		"TIK_1_act_ecla3"->SetPos Z -183
		Set EauE to 1
	Elseif ( Sens == 1 )
		Set EauE to 1
	Endif
Endif

If ( EauE == 1 )
	If ( Sens == 0 )
		If ( EauM <= 0 )
			ModWaterLevel 3
			PlaySound "Waterfall small"
		Else
			Set EauE to 0
			Set Etat to 0
			Set Sens to 1
			"TIK_1_act_cascade1"->SetPos Z -10000
			"TIK_1_act_ecla1"->SetPos Z -10000
			"TIK_1_act_ecla2"->SetPos Z -10000
			"TIK_1_act_ecla3"->SetPos Z -10000
		Endif
	Elseif ( Sens == 1 )
		If ( EauM >= -384 )
			ModWaterLevel -3
			PlaySound "Machinery"
		Else
			Set EauE to 0
			Set Etat to 0
			Set Sens to 0
		endif
	endif
endif

End


#2 Nenfëa

Nenfëa

    Le poisson bavard de Kalendaar


Posté 04 mars 2006 - 19:24

Il y a un espace entre le "position" et le "2" dans le bloc "if ( Etat == 2 )" ! :D

Edit : les tabulations ne passent pas en Quote... :P :)

Modifié par Nenfëa, 04 mars 2006 - 19:30.

Nenfëa

- Les yeux, Bouh, vise les yeux!
- Pouiiiiiic!!!

Le monde de Gilbertus devenu réalité : Kalendaar!
Il était une fois un site vachement bien avec plein de nistoires dessus... ah, vous la connaissez déjà ?!

Wiwi d'or 2006 du plus serviable ! Tadaaaaaaaa !

#3 Timalk-Ae

Timalk-Ae

    PoneyMaster !


Posté 05 mars 2006 - 13:30

Rekuku !
Merci Nenfëa, tu as raison  :woot C'était tout bête en fait.

Seulement le script fonctionne pour faire monter l'eau, puis la faire redescendre... Une seule fois. Après plus rien.
J'ai modifié le script de façon à ce que le levier tourne dans le même sens à l'aller et au retour (c'est un levier spécial), ce qui permettait d'alléger le script et permettrait peut-être d'enlever le bug. Sauf que ça marchait toujours pas. Le bidule continuait à tourner infiniment quand je l'activais pour la 3eme fois.

Donc j'ai utilisé un timer, ce qui est en fait plus simple... Sauf que j'ai toujours eu une peur bleue des timers, ça rate toujours avec moi, je sais jamais m'en servir ^^

Donc bah ça marche encore moins  :P , cette fois ça tournetournetourne dès que j'active pour la 1ere fois.
J'en conclu que le problème se situe dans le bloc "If ( Etat ==  1 )"... Pourtant je ne vois rien d'anormal  :lol:

Je quémande votre aide à nouveau  ;)

(PS : j'ai aussi modifié le script pour que la cascade et les eclaboussures qu'elle produit disparaissent une fois englouties... Cette partie là fonctionne (du moins elle fait disparaitre les trucks au fur et à mesure) ).

Le script :
begin TIK_1_scr_levier1

Short Sens
Short Etat
Short EauE
Float EauM
Float Temps
Set EauM to GetWaterLevel

If ( OnActivate == 1 )
	If ( Etat == 0 )
		Set Temps to GetSecondsPassed
		Set Etat to 1
	Else
		Return
	Endif
Endif

If ( Etat == 1 )
	If ( Temps <= 2 )
		Rotate, Y, 80
	Else
		Set Etat to 3
	Endif
Endif

If ( Etat == 3 )
	If ( Sens == 0 )
		"TIK_1_act_cascade1"->SetPos Z 23
		"TIK_1_act_ecla1"->SetPos Z -52
		"TIK_1_act_ecla2"->SetPos Z -105
		"TIK_1_act_ecla3"->SetPos Z -183
		Set EauE to 1
		Set Temps to 0
	Elseif ( Sens == 1 )
		Set EauE to 1
	Endif
Endif

If ( EauE == 1 )
	If ( Sens == 0 )
		If ( EauM <= 0 )
			If ( EauM >= -23 )
				"TIK_1_act_cascade1"->SetPos Z -10000
				"TIK_1_act_ecla1"->SetPos Z -10000	
				"TIK_1_act_ecla2"->SetPos Z -10000	
				"TIK_1_act_ecla3"->SetPos Z -10000		
				ModWaterLevel 2			
			ElseIf ( EauM >= -48 )
				"TIK_1_act_ecla1"->SetPos Z -10000	
				"TIK_1_act_ecla2"->SetPos Z -10000	
				"TIK_1_act_ecla3"->SetPos Z -10000	
				ModWaterLevel 2
			ElseIf ( EauM >= -70 )
				"TIK_1_act_ecla2"->SetPos Z -10000	
				"TIK_1_act_ecla3"->SetPos Z -10000	
				ModWaterLevel 2
			ElseIf ( EauM >= -120 )
				"TIK_1_act_ecla3"->SetPos Z -10000	
				ModWaterLevel 2
			Elseif ( EauM <= -120 )
				ModWaterLevel 2		
			endif
		Else
			Set EauE to 0
			Set Etat to 0
			Set Sens to 1
			"TIK_1_act_cascade1"->SetPos Z -10000
			"TIK_1_act_ecla1"->SetPos Z -10000	
			"TIK_1_act_ecla2"->SetPos Z -10000	
			"TIK_1_act_ecla3"->SetPos Z -10000	
		Endif
	Elseif ( Sens == 1 )
		If ( EauM >= -384 )
			ModWaterLevel -2
			PlaySound "Machinery"
		Else
			Set EauE to 0
			Set Etat to 0
			Set Sens to 0
		endif
	endif
endif

End


#4 Angora

Angora

    Danse avec les bugs


Posté 05 mars 2006 - 14:00

Le moyen le plus simple, si tu as Tribunal, c'est de copier le script qui est utilisé dedans...

begin changeWater_-550_400

short changelevel
short crankturn
short currcrank
short initialized

float lowheight
float highheight
float newwaterlevel
float direction
float waterlift
float changerate

float targetheight
float current
float thischange

if ( initialized == 0 )
	set lowheight to -550
	set highheight to 400
	set changerate to 50
	set initialized to 1
endif

if ( MenuMode )
	return
endif

;always set angle to make up for different data
SetAngle X crankturn

set current to GetWaterLevel

if ( OnActivate == 1 )
	if ( changelevel == 0 )
		if ( current >= highheight )
			set direction to -1
			set targetheight  to lowheight
		else 
			set direction to 1
			set targetheight  to highheight
		endif
		set changelevel to 1
		PlaySound3D "Dwemer Door Open"
	endif
endif
if ( changelevel == 0 )
	return
endif

set crankturn to 360 * GetSecondsPassed
set crankturn to crankturn * direction
set currcrank to GetAngle X
set crankturn to currcrank + crankturn

if ( current != targetheight  )
	set thischange to ( changerate * GetSecondsPassed )

	if ( direction == 1  )
		if ( thischange < 0 )
			set thischange to ( thischange * -1 )
		endif
		set current to ( current + thischange )
		if ( current > targetheight  )
			set current to targetheight  
		endif
	else
		if ( thischange > 0 )
			set thischange to ( thischange * -1 )
		endif
		set current to ( current + thischange )
		if ( current < targetheight  )
			set current to targetheight  
		endif
	endif

	SetWaterLevel current
endif


if ( direction == 1 )
	if ( current >= highheight )
		set changelevel to 0
	endif
else
	if ( current <= lowheight )	
		set changelevel to 0
	endif
endif

end

Il marche, c'est garanti.  :P

Faut juste le renommer et changer les hauteurs d'eau dans le bloc "initialized" du début.
Le saviez-vous ?

En français, il n'y a jamais, jamais, JAMAIS, J-A-M-A-I-S, de cédille à un 'c' devant un 'e', un 'i' ou un 'y'. Jamais. Sans aucune exception. Pas la moindre. Zéro. Cédille devant e, i ou y = faute. Un point, c'est tout, c'est comme ça, ça a toujours été comme ça, et ça le sera toujours.

#5 Timalk-Ae

Timalk-Ae

    PoneyMaster !


Posté 05 mars 2006 - 17:24

Merci Angora mais ce script est bien long et bien compliqué pour faire quelque chose qui ne me convient pas  :)
Hé oui, les cascades sont très importantes  :green:
Donc plutôt que de me casser la tête à comprendre ce script, j'ai remanié le mien. Comme faire tourner le levier posait problème, j'ai sauté cette étape ^^ Ca marche à merveille, j'ai même rajouté quelque chose pour faire apparaitre un mur "d'eau" quand la salle se remplit, se vide ou est remplie.
Le Script :

begin TIK_1_scr_levier1

Short Sens
Short Etat
Short EauE
Float EauM
Float Temps

Set EauM to GetWaterLevel

If ( OnActivate == 1 )
	If ( Etat == 0 )
		Set Etat to 3
		PlaySound "Open Lock Fail"
	Else
		Return
	Endif
Endif

If ( Etat == 3 )
	If ( Sens == 0 )
		"TIK_1_stc_eau2"->SetPos Z -83
		"TIK_1_act_murinvi1"->SetPos Z -80
		"TIK_1_act_cascade1"->SetPos Z 23
		"TIK_1_act_ecla1"->SetPos Z -52
		"TIK_1_act_ecla2"->SetPos Z -105
		"TIK_1_act_ecla3"->SetPos Z -183
		Set EauE to 1
		Set Temps to 0
	Elseif ( Sens == 1 )
		Set EauE to 1
	Endif
Endif

If ( EauE == 1 )
	If ( Sens == 0 )
		If ( EauM <= 0 )
			If ( EauM >= -23 )
				"TIK_1_act_cascade1"->SetPos Z -10000
				"TIK_1_act_ecla1"->SetPos Z -10000	
				"TIK_1_act_ecla2"->SetPos Z -10000	
				"TIK_1_act_ecla3"->SetPos Z -10000		
				ModWaterLevel 1			
			ElseIf ( EauM >= -48 )
				"TIK_1_act_ecla1"->SetPos Z -10000	
				"TIK_1_act_ecla2"->SetPos Z -10000	
				"TIK_1_act_ecla3"->SetPos Z -10000	
				ModWaterLevel 1
			ElseIf ( EauM >= -70 )
				"TIK_1_act_ecla2"->SetPos Z -10000	
				"TIK_1_act_ecla3"->SetPos Z -10000	
				ModWaterLevel 2
			ElseIf ( EauM >= -120 )
				"TIK_1_act_ecla3"->SetPos Z -10000	
				ModWaterLevel 1
			Elseif ( EauM <= -120 )
				ModWaterLevel 1		
			endif
		Else
			Set EauE to 0
			Set Etat to 0
			Set Sens to 1
			"TIK_1_act_cascade1"->SetPos Z -10000
			"TIK_1_act_ecla1"->SetPos Z -10000	
			"TIK_1_act_ecla2"->SetPos Z -10000	
			"TIK_1_act_ecla3"->SetPos Z -10000	
		Endif
	Elseif ( Sens == 1 )
		If ( EauM >= -200 )
			ModWaterLevel -1
			PlaySound "Machinery"
		Else
			Set EauE to 0
			Set Etat to 0
			Set Sens to 0
			"TIK_1_stc_eau2"->SetPos Z -10000
			"TIK_1_act_murinvi1"->SetPos Z -10000
		endif
	endif
endif

End

Bon, maintenant, je ne sais pas si ça servirait à grand monde, donc si un modo passe par là et trouve ce topic inutile il peut le mettre à la cave je pense  :)

Merci à Angora et Nenfëa.




0 utilisateur(s) li(sen)t ce sujet

0 membre(s), 0 invité(s), 0 utilisateur(s) anonyme(s)