UnityScript: Chest system for RPG game

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 3527 Views - Last Post: 12 March 2013 - 03:47 PM Rate Topic: -----

#16 TrewSx  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 50
  • Joined: 07-June 12

Re: UnityScript: Chest system for RPG game

Posted 12 March 2013 - 02:08 PM

after modifing my if statement i do have this error

Expressions in statements must only be executed for their side-effects

function onmouseup() {
	Debug.Log("Up");
	if(currentChestStatus == ChestState.Open) {			
		Open();	
		
	} else {
	    (currentChestStatus == ChestState.Close);
		Close();
				
			
	}
}


This post has been edited by TrewSx: 12 March 2013 - 02:15 PM

Was This Post Helpful? 0
  • +
  • -

#17 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2884
  • View blog
  • Posts: 9,566
  • Joined: 12-December 12

Re: UnityScript: Chest system for RPG game

Posted 12 March 2013 - 02:14 PM

If your else clause needs to test for the .Close status then, in Javascript, it would be:

} else if (currentChestStatus == ChestState.Close) {

BTW .Closed would be a better status-name IMO, and avoid confusion with the Close() method.
Was This Post Helpful? 0
  • +
  • -

#18 TrewSx  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 50
  • Joined: 07-June 12

Re: UnityScript: Chest system for RPG game

Posted 12 March 2013 - 02:37 PM

The only output in the Console is "Chest is now closed"

function onmouseup() {
	Debug.Log("Up");
	if(currentChestStatus == ChestState.Open) {				
		Open();	
			
	} else if (currentChestStatus == ChestState.Closed) {
	    Close();
			
	}
}



and even in the Unity Inspector currentChestStatus is not changing from Close to Open. It remains Close all the time

This post has been edited by TrewSx: 12 March 2013 - 02:39 PM

Was This Post Helpful? 0
  • +
  • -

#19 TrewSx  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 50
  • Joined: 07-June 12

Re: UnityScript: Chest system for RPG game

Posted 12 March 2013 - 02:45 PM

function onmouseup() {
	Debug.Log("Up");
	if(currentChestStatus == ChestState.Closed) {			
		Open();	
			
	} else if (currentChestStatus == ChestState.Open) {
	    Close();
			
	}
}


it's working now, You are a genius man thanks a lot
Was This Post Helpful? 0
  • +
  • -

#20 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2884
  • View blog
  • Posts: 9,566
  • Joined: 12-December 12

Re: UnityScript: Chest system for RPG game

Posted 12 March 2013 - 02:46 PM

Your logic seems upside down: if the status is .Open then surely you want to Close() ..? That is, to toggle the status. (I haven't examined your code in detail.)

View PostTrewSx, on 12 March 2013 - 02:45 PM, said:

function onmouseup() {
	Debug.Log("Up");
	if(currentChestStatus == ChestState.Closed) {			
		Open();	
			
	} else if (currentChestStatus == ChestState.Open) {
	    Close();
			
	}
}


it's working now, You are a genius man thanks a lot

Okay, then ignore my statement above :)

This post has been edited by andrewsw: 12 March 2013 - 02:47 PM

Was This Post Helpful? 0
  • +
  • -

#21 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,217
  • Joined: 23-August 08

Re: UnityScript: Chest system for RPG game

Posted 12 March 2013 - 03:47 PM

Seeing as this is not actually Javascript, we'll move this to the Other Languages forum.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2