| 
		
	
		| The chaser   Posting Freak
 
 Posts: 2,486
 Threads: 76
 Joined: Jun 2012
 Reputation: 
113
 | 
			| Combinating problems 
 
				So, I have been trying to get a chemical script to work, but for unknown reasons it says "The combination doesn't work". 
My inventory.hps: (The hammer part works perfectly)
 //COMBINE HAMMER//////////////////////
 
 void hammer_chipper(string &in asItemA, string &in asItemB)
 {
 PlayGuiSound("15_make_hammer", 1.0f);
 RemoveItem(asItemA); RemoveItem(asItemB);
 GiveItem("stone_hammer_chipper", "Puzzle", "stone_hammer_chipper", "stone_hammer_chipper.tga", 0);
 }
 
 //COMBINE EXPLOSIVE CHEMICALS////
 void make_explosive(string &in asItemA, string &in asItemB)
 {
 if (GetLocalVarInt("chemical_dynamite") == 0)
 {
 GiveItem("chemical_container_half", "Puzzle", "chemical_container_half", "chemical_container_half.tga", 1);
 AddLocalVarInt("chemical_dynamite", 1);
 RemoveItem(asItemA); RemoveItem(asItemB);
 RemoveCombineCallback("Add_var_explosive");
 }
 if (GetLocalVarInt("chemical_dynamite") == 1)
 {
 RemoveCombineCallback("Add_var_explosive_1");
 AddLocalVarInt("chemical_dynamite", 1);
 }
 if (GetLocalVarInt("chemical_dynamite") == 2)
 {
 RemoveCombineCallback("Add_var_explosive_2");
 AddLocalVarInt("chemical_dynamite", 1);
 }
 }
 ////////////////////////////
 // Run at the start of the game.
 void OnGameStart()
 {
 SetLocalVarInt("chemical_dynamite", 0);
 /////HAMMER & CHIPPER COMBO/////
 AddCombineCallback("hammer_chipper", "stone_hammer_1", "stone_chipper_1", "hammer_chipper", false);
 ////Before Hall chemicals before mixed
 AddCombineCallback("Add_var_explosive", "ingredient_complement_Hexanitrate mannitol", "chemical_container_1", "make_explosive", true);
 AddCombineCallback("Add_var_explosive", "ingredient_complement_Silver_acetylide", "chemical_container_1", "make_explosive", true);
 AddCombineCallback("Add_var_explosive", "ingredient_complement_plumb_Styphnate", "chemical_container_1", "make_explosive", true);
 ////Before Hall chemicals after one has been mixed
 AddCombineCallback("Add_var_explosive_1", "ingredient_complement_Hexanitrate mannitol", "chemical_container_half", "make_explosive", true);
 AddCombineCallback("Add_var_explosive_1", "ingredient_complement_Silver_acetylide", "chemical_container_half", "make_explosive", true);
 AddCombineCallback("Add_var_explosive_1", "ingredient_complement_plumb_Styphnate", "chemical_container_half", "make_explosive", true);
 ////Before Hall chemicals after two have been mixed
 AddCombineCallback("Add_var_explosive_2", "ingredient_complement_Hexanitrate mannitol", "chemical_container_half", "make_explosive", true);
 AddCombineCallback("Add_var_explosive_2", "ingredient_complement_Silver_acetylide", "chemical_container_half", "make_explosive", true);
 AddCombineCallback("Add_var_explosive_2", "ingredient_complement_plumb_Styphnate", "chemical_container_half", "make_explosive", true);
 
 
 }
I have checked names, they are all the same, and there isn't any .map_cache.
 
Any ideas?
			
                               THE OTHERWORLD (WIP) ![[Image: k6vbdhu]](http://tinyurl.com/k6vbdhu)  
Aculy iz dolan. |  |  
	| 08-02-2013, 01:15 PM |  |  
	
		| PutraenusAlivius   Posting Freak
 
 Posts: 4,713
 Threads: 75
 Joined: Dec 2012
 Reputation: 
119
 | 
			| RE: Combinating problems 
 
				I don't think if-else statements are compatible. I mean I don't think it can be used.
			 
 "Veni, vidi, vici.""I came, I saw, I conquered."
 |  |  
	| 08-02-2013, 01:31 PM |  |  
	
		| The chaser   Posting Freak
 
 Posts: 2,486
 Threads: 76
 Joined: Jun 2012
 Reputation: 
113
 | 
			| RE: Combinating problems 
 
				Well, I removed the if's and it didn't work either...
			 
                               THE OTHERWORLD (WIP) ![[Image: k6vbdhu]](http://tinyurl.com/k6vbdhu)  
Aculy iz dolan. |  |  
	| 08-02-2013, 03:19 PM |  |  
	
		| Rapture   Posting Freak
 
 Posts: 1,078
 Threads: 79
 Joined: May 2011
 Reputation: 
30
 | 
			| RE: Combinating problems 
 
				Change the last two "if"s to "else". //COMBINE EXPLOSIVE CHEMICALS////void make_explosive(string &in asItemA, string &in asItemB)
 {
 if (GetLocalVarInt("chemical_dynamite") == 0)
 {
 GiveItem("chemical_container_half", "Puzzle", "chemical_container_half", "chemical_container_half.tga", 1);
 AddLocalVarInt("chemical_dynamite", 1);
 RemoveItem(asItemA); RemoveItem(asItemB);
 RemoveCombineCallback("Add_var_explosive");
 }
 else (GetLocalVarInt("chemical_dynamite") == 1)
 {
 RemoveCombineCallback("Add_var_explosive_1");
 AddLocalVarInt("chemical_dynamite", 1);
 }
 else (GetLocalVarInt("chemical_dynamite") == 2)
 {
 RemoveCombineCallback("Add_var_explosive_2");
 AddLocalVarInt("chemical_dynamite", 1);
 }
 }
 |  |  
	| 08-02-2013, 03:38 PM |  |  
	
		| The chaser   Posting Freak
 
 Posts: 2,486
 Threads: 76
 Joined: Jun 2012
 Reputation: 
113
 | 
			| RE: Combinating problems 
 
				That doesn't work either... thanks anyway for the try   
                               THE OTHERWORLD (WIP) ![[Image: k6vbdhu]](http://tinyurl.com/k6vbdhu)  
Aculy iz dolan.
				
(This post was last modified: 08-02-2013, 04:21 PM by The chaser.)
 |  |  
	| 08-02-2013, 04:21 PM |  |  
	
		| Tomato Cat   Senior Member
 
 Posts: 287
 Threads: 2
 Joined: Sep 2012
 Reputation: 
20
 | 
			| RE: Combinating problems 
 
				void make_explosive(string &in asItemA, string &in asItemB){
 if (GetLocalVarInt("chemical_dynamite") == 0)
 {
 GiveItem("chemical_container_half", "Puzzle", "chemical_container_half", "chemical_container_half.tga", 1);
 AddLocalVarInt("chemical_dynamite", 1);
 RemoveItem(asItemA); RemoveItem(asItemB);
 RemoveCombineCallback("Add_var_explosive");
 }
 else if(GetLocalVarInt("chemical_dynamite") == 1)
 {
 RemoveCombineCallback("Add_var_explosive_1");
 AddLocalVarInt("chemical_dynamite", 1);
 }
 else if(GetLocalVarInt("chemical_dynamite") == 2)
 {
 RemoveCombineCallback("Add_var_explosive_2");
 AddLocalVarInt("chemical_dynamite", 1);
 }
 }
 
"else" statements do not check if a condition is met. They are executed of none if the other conditions are met. i.e, if "chemical_dynamite" was neither 0, 1 or 2. 
 
I believe  several "if" statements will work, but it's generally only used when 2 separate conditions are being checked.
			 
				
(This post was last modified: 08-02-2013, 11:06 PM by Tomato Cat.)
 |  |  
	| 08-02-2013, 06:43 PM |  |  
	
		| Rapture   Posting Freak
 
 Posts: 1,078
 Threads: 79
 Joined: May 2011
 Reputation: 
30
 | 
			| RE: Combinating problems 
 
				Tomato Cat is right, that was my Error. I'm guessing the compiler doesn't mine a bunch of "if"'s because I have a old working one. void Timer_IntroFade(string &in asTimer){
 if(asTimer == "IntroFade_0")
 {
 FadeIn(1);
 StartPlayerLookAt("Area_Look_1", 0.75f, 0.75f, "");
 }
 
 if(asTimer == "IntroFade_1")
 {
 StopPlayerLookAt();
 StartPlayerLookAt("Area_Look_2", 1, 1, "");
 }
 
 if(asTimer == "IntroFade_2")
 {
 SetPlayerActive(true);
 }
 
 if(asTimer == "IntroFade_3")
 {
 SetMessage("Message", "001_Sally01", 0);
 }
 
 if(asTimer == "IntroFade_4")
 {
 SetMessage("Message", "001_Michael01", 0);
 }
 
 if(asTimer == "IntroFade_5")
 {
 SetMessage("Message", "001_Sally02", 0);
 }
 
 if(asTimer == "IntroFade_6")
 {
 StopPlayerLookAt();
 SetPlayerMoveSpeedMul(1);
 SetPlayerRunSpeedMul(1);
 SetPlayerLookSpeedMul(1);
 SetPlayerJumpDisabled(false);
 SetPlayerCrouchDisabled(false);
 SetInventoryDisabled(false);
 }
 }
Like Tomato Cat said, if I place another one of the "if(asTimer == "IntroFade_7) and replace the "if" with "else". The timer will default to "IntroFade_7" if none of the other above conditions match.
			
				
(This post was last modified: 08-02-2013, 10:45 PM by Rapture.)
 |  |  
	| 08-02-2013, 10:45 PM |  |  
	
		| SilentStriker   Posting Freak
 
 Posts: 950
 Threads: 26
 Joined: Jul 2011
 Reputation: 
43
 | 
			| RE: Combinating problems 
 
				 (08-02-2013, 10:45 PM)Rapture Wrote:  Tomato Cat is right, that was my Error. I'm guessing the compiler doesn't mine a bunch of "if"'s because I have a old working one.
 
 Like Tomato Cat said, if I place another one of the "if(asTimer == "IntroFade_7) and replace the "if" with "else". The timer will default to "IntroFade_7" if none of the other above conditions match.void Timer_IntroFade(string &in asTimer){
 if(asTimer == "IntroFade_0")
 {
 FadeIn(1);
 StartPlayerLookAt("Area_Look_1", 0.75f, 0.75f, "");
 }
 
 if(asTimer == "IntroFade_1")
 {
 StopPlayerLookAt();
 StartPlayerLookAt("Area_Look_2", 1, 1, "");
 }
 
 if(asTimer == "IntroFade_2")
 {
 SetPlayerActive(true);
 }
 
 if(asTimer == "IntroFade_3")
 {
 SetMessage("Message", "001_Sally01", 0);
 }
 
 if(asTimer == "IntroFade_4")
 {
 SetMessage("Message", "001_Michael01", 0);
 }
 
 if(asTimer == "IntroFade_5")
 {
 SetMessage("Message", "001_Sally02", 0);
 }
 
 if(asTimer == "IntroFade_6")
 {
 StopPlayerLookAt();
 SetPlayerMoveSpeedMul(1);
 SetPlayerRunSpeedMul(1);
 SetPlayerLookSpeedMul(1);
 SetPlayerJumpDisabled(false);
 SetPlayerCrouchDisabled(false);
 SetInventoryDisabled(false);
 }
 }
 
The code you got there is easier to do as a switch instead of a bunch of ifs    
 |  |  
	| 08-03-2013, 09:45 PM |  |  
	
		| Rapture   Posting Freak
 
 Posts: 1,078
 Threads: 79
 Joined: May 2011
 Reputation: 
30
 | 
			| RE: Combinating problems 
 
				^Can I see a example?
 
 I do it that way because I find it easier to keep it neater and more open to understanding at a quick glance. 1000 ways to skin a cat.
 |  |  
	| 08-03-2013, 10:44 PM |  |  
	
		| SilentStriker   Posting Freak
 
 Posts: 950
 Threads: 26
 Joined: Jul 2011
 Reputation: 
43
 | 
			| RE: Combinating problems 
 
				 (08-03-2013, 10:44 PM)Rapture Wrote:  ^Can I see a example?
 
 I do it that way because I find it easier to keep it neater and more open to understanding at a quick glance. 1000 ways to skin a cat.
 
Here's an example:
 
Let's see if I remember correctly
 void Timer_IntroFade(string &in asTimer){
 AddLocalVarInt("IntroFade", 1
 switch(GetLocalVarInt("IntroFade")){
 case 1:
 FadeIn(1);
 StartPlayerLookAt("Area_Look_1", 0.75f, 0.75f, "");
 break;
 case 2:
 StopPlayerLookAt();
 StartPlayerLookAt("Area_Look_2", 1, 1, "");
 break;
 case 3:
 SetPlayerActive(true);
 break;
 case 4:
 SetMessage("Message", "001_Sally01", 0);
 break;
 case 5;
 SetMessage("Message", "001_Michael01", 0);
 break;
 case 6:
 SetMessage("Message", "001_Sally02", 0);
 case 7:
 StopPlayerLookAt();
 SetPlayerMoveSpeedMul(1);
 SetPlayerRunSpeedMul(1);
 SetPlayerLookSpeedMul(1);
 SetPlayerJumpDisabled(false);
 SetPlayerCrouchDisabled(false);
 SetInventoryDisabled(false);
 break;
 
 if(GetLocalVarInt("IntroFade") < 7) AddTimer("IntroFade", 1, "Timer_IntroFade");
 }
 }
 
 
				
(This post was last modified: 08-04-2013, 01:34 AM by SilentStriker.)
 |  |  
	| 08-04-2013, 01:33 AM |  |  |