I have my items in inventory, now if I could only use them...

EDIT:

It’s dawned on me that I’ve really been overcomplicating this. It also dawns on me that because of my lack of experience, I’m having a dickens of a time figuring out what to do next. The long and the short of my issue: I have inventory, I’d like to use it. For instance, a health potion. If I have a health potion, and I drink it, I’d like it to add 15 hp. The major problem I found was that my PlayerHealth script is in C#, while my inventory script is in js. As a noob I’ve just been finding tutorials, and writing (or editing) scripts based on what I learned that particular day, never thinking there would be an issue what language I coded them in. (go ahead, laugh) And so, for the last couple of days I’ve been trying to pull code from the PlayerHealth C# script to make the +hp function work, with no success. Today I found an online converter, which I didn’t expect to solve all of my issues, and converted the js Inventory script to C#, thinking that might be a start in helping to simplify this. Here’s the converted script:

// Converted from UnityScript to C# at http://www.M2H.nl/files/js_to_c.php - by Mike Hergaarden
// Do test the code! You usually need to change a few small bits.

using UnityEngine;
using System.Collections;

public class MYCLASSNAME : MonoBehaviour {

//inventory
static int[] inventoryArray = [1,2,0,0,0];
GameObject inventoryText;
GameObject PauseCamera;


void  Update (){

inventoryText.guiText.text = "Health Potion " + "[" + inventoryArray[0] + "]" + "

" + "Mana Potion " + “[” + inventoryArray1 + “]”;

if(Input.GetKeyDown("g")) {

if(inventoryArray[0] > 0) {

healthPotion();
}

}

//inventoryArray[0]++;
//inventoryArray[1] += 2;


}


void  healthPotion (){

PlayerHealth.curHealth += 15;
inventoryArray[0] -=1;
}
}

I’ve gotten a compile error at 10:31
that states “Assets/Inv2.cs(10,31):
error CS1519: Unexpected symbol `[’ in
class, struct, or interface member
declaration”

And a parsing error at line 41 (it’s actually an empty line following the final bracket. Added a bracket, and the compiler didn’t like that, so left it out for now. Definitely expected there to be work after the conversion, just am in need of a nudge in the right direction. Thanks, and God bless. Original thread is below.(since that script still exists in the event that this wasn’t the route I should take)

I did search, plus fiddled with several things before resorting to asking this. I don’t think I’m far from the answer, but maybe I’m wrong. Here’s what’s going on:

Am working on learning a basic inventory script. Have gotten the inventory attached to my pause menu, am able to add items to it, and to have a GuiText display said items. Now comes the part where I actually use them. Let’s take, for instance, a health potion. The instructions I’m following in a tutorial are really straight forward, but they’re assuming that I’m scripting from js to js. In other word, the PlayerHealth script (which the health potion regenerates, PlayerHealth.curHealth) is in js, as is the pickupitem script. Unfortunately that’s not my case, my PlayerHealth is in C#. Now, I’ve found some resources online namely here, and came up with the following based on it:

//inventory
static var inventoryArray : int[] = [1,2,0,0,0];
var inventoryText : GameObject;


function Update () {

inventoryText.guiText.text = "Health Potion " + "[" + inventoryArray[0] + "]" + "

" + "Mana Potion " + “[” + inventoryArray1 + “]”;

if(Input.GetKeyDown("g")) {

if(inventoryArray[0] > 0) {

healthPotion();
}

}

//inventoryArray[0]++;
//inventoryArray[1] += 2;


}


function healthPotion ()  {

//create a variable to access the C# script
}  
private var PlayerHealth : PlayerHealth;  
   
function Awake()  
{  
    //Get the CSharp Script  
    csScript = this.GetComponent("PlayerHealth"); //Don't forget to place the 'CSharp1' file inside the 'Standard Assets' folder  
}  
   
//... 
PlayerHealth.curHealth += 15;
inventoryArray[0] -=1;

which from the appearance I’d say is missing something, but I’m just not sure what. In addition (or possibly because of this) I’m getting some compiler errors, specifically:

“UnassignedReferenceException: The
variable inventoryText of ‘Inventory’
has not been assigned. You probably
need to assign the inventoryText
variable of the Inventory script in
the inspector. Inventory.Update () (at
Assets/scripts/Inventory.js:8)” (also
39)

Sorry for REALLY being a noob here, but this confuses me, as I’ve assigned the inventory text to the Inventory script as evidenced in the lower right corner of this photo:

pic

with this being the (current) intended result, which was successful:

pic 2

So I’ve got errors showing at lines 8 and 39 saying that the text isn’t assigned, but to my untrained eyes it appears to be, and an inventory that I can add to, but not subtract from, that looks to be caused by me not quite fully pulling my PlayerHealth curHealth variable from the C# script into the js script. Am I correct to say those are my issues, and is there anyone who might be able to suggest my next step? Thanks, and God bless. =)

well, sometimes we have to go back to Occam’s Razor, which states that the best solution is usually the simplest one, and the simplest solution in this case was just to go back to all js. Thank you everyone for your help, I don’t intend to abandon the lessons learned from this.