Commits

Philémon Gardet committed 6894072

Deuxieme salle en partie terminee (il reste la partie PNJ).

Comments (0)

Files changed (4)

 			(actionAnimation, actionPosition)
 		
 		method getOrientation = 
-			let value = pop direction in
-			begin if is_empty direction then 
-				push value direction
-			end; value
+			if is_empty direction then
+				0
+			else begin
+				let value = pop direction in
+				begin if is_empty direction then 
+					push value direction
+				end; value
+			end
 		method still =
 			is_empty positionUpdate
 		(* Get Data *)
 			| _ -> failwith "Invalid call in lua at set_global_int"
 	and getglobalint state =
 		let value = match (Lua.tostring state 1) with
-			| Some name -> getGlobalInt name
+			| Some name -> 
+				(try getGlobalInt name
+				with _ -> 0)
 			| _ -> failwith "Invalid call in lua at get_global_int"
 		in Lua.pushinteger state value
 	and removeglobalint state =
 			| _ -> failwith "Invalid call in lua at set_global_string"
 	and getglobalstring state =
 		let value = match (Lua.tostring state 1) with
-			| Some name -> getGlobalString name
+			| Some name -> 
+				(try getGlobalString name
+				with _ -> "")
 			| _ -> failwith "Invalid call in lua at get_global_string"
 		in Lua.pushstring state value
 	and removeglobalstring state =
 				let w = Jed.getWindow () in 
 				w#addItemToDisplay name (x,y)
 			| _ -> failwith "Invalid call in lua at place_item"
+	and setanimation state =
+		match (Lua.tostring state 1),(Lua.tostring state 2) with
+			| (Some obj,Some anim) -> 
+				let w = Jed.getWindow () in 
+				w#setAnimation obj anim
+			| _ -> failwith "Invalid call in lua at set_animation"
 	in 	
 	registerDynamicFunction "change_room" changeroom;
 	registerDynamicFunction "give_item" giveitem;
 	registerDynamicFunction "drop_item" dropitem;
 	registerDynamicFunction "add_character" addcharacter;
-	registerDynamicFunction "place_item" placeitem
+	registerDynamicFunction "place_item" placeitem;
+	registerDynamicFunction "set_animation" setanimation
 ;;
 
 let initLua () =

superGame/rooms/lightRoom/nodes.xml

 <graph>
 	<node id="begin" x="95" y="475" l="b1" swr="begin" swn="out"/>
 	
-	<node id="b1" x="263" y="465" l="begin,lampe,a1,c1"/>
+	<node id="b1" x="263" y="465" l="begin,lampe,a1"/>
 	
-	<node id="lampe" x="442" y="461" l="a1,b1,c1"/>
+	<node id="lampe" x="442" y="461" l="a1,b1"/>
 	
 	<node id="a1" x="442" y="408" l="b1,lampe,a2"/>
 	<node id="a2" x="685" y="408" l="a1,b2"/>
 	
-	<node id="c1" x="442" y="535" l="b1,lampe,c2"/>
-	<node id="c2" x="717" y="535" l="c1,b2"/>
-	
-	<node id="b2" x="837" y="470" l="out,a2,c2"/>
+	<node id="b2" x="837" y="470" l="out,a2"/>
 	
 	<node id="out" x="916" y="465" l="b2" swr="pistonRoom" swn="begin"/>
 </graph>

superGame/rooms/lightRoom/script.lua

-function active_interupteur ()
-	sayHello()
+function active_lampe ()
+	if(get_global_int ("lampe") == 0) then
+		set_animation ("lampe","actived")
+		set_global_int ("lampe",1)
+		set_global_int ("guy1s",1)
+	else
+		set_animation ("lampe","idle")
+		set_global_int ("lampe",0)
+	end
 	return
 end
 
 function main ()
-	place_item("interupteur",160,515)
+	place_item("lampe",560,500)
+	if(get_global_int ("lampe") == 1) then
+		set_animation ("lampe","idle")
+		set_animation ("lampe","actived")
+	end
 	return 
 end