x


CS0118 Error

//Sorry for posting so many errors, but I need these scripts for my game.

using UnityEngine;

using System.Collections;

namespace Stats {

public static class UpdateLists {

public static void UpdateInventory(Stats Stat)
{
    for (int i = 0; i < Stat.Inventory.Length; i++)
    {                                   
        if (Stat.Ability[i].name == "Potion")
        {
            Stat.Inventory[i].cost = 15;
            Stat.Inventory[i].type = "Medicine";
            Stat.Inventory[i].effect= "Heal";
            Stat.Inventory[i].modifier = 30;
            Stat.Inventory[i].description = "To restore health";               
        }

        if (Stat.Ability[i].name == "Bomb")
        {
            Stat.Inventory[i].cost = 35;
            Stat.Inventory[i].type = "Bomb";
            Stat.Inventory[i].effect= "Explode";
            Stat.Inventory[i].modifier = 50;
            Stat.Inventory[i].description = "Damage enemies within an area of effect";               
        }
    }
}

} }

// I am getting a CS0118 error at line 9 public static void UpdateInventory(Stats Stat)

'Stats is a namespace, but a 'type' was expected is what the error says.

more ▼

asked Apr 16 '12 at 03:48 PM

Marooca gravatar image

Marooca
1 2 3 3

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

It is just as it says. Stats is a namespace, that is a kind of "directory of classes".

In your code, you use Stats as a class. To do so, you need to create a class called Stats.

You should also learn a bit more about the basics of C#.

more ▼

answered Apr 17 '12 at 09:54 AM

dnjata gravatar image

dnjata
241 3 4 7

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5081
x4157
x3738
x1951
x180

asked: Apr 16 '12 at 03:48 PM

Seen: 622 times

Last Updated: Apr 17 '12 at 09:54 AM