- Home /
Slicing not allowed? Unityscript question
Hi everyone, I'm trying to sort out this bit of code but it has me a bit stumped and i'm not sure how to fix it.
I'm trying to work from a C code to rewrite it in unityscript (since it's something i'm more familiar with, but the original code went
for (i = 0; i < number_of_systems; i++)
{
rotate_some();
coords[i].z = (systemParam_0 & 0xff0000) >> 16;
coords[i].y = (systemParam_0 >> 8);
coords[i].y /= 2;
coords[i].x = (systemParam_0 & 0x0001fe) >> 1;
coords[i].x /= 2;
coords[i].multiple = starChanceMultiples[systemParam_1 & 0x1f];
coords[i].stardesc = starChanceType[(systemParam_1 >> 16) & 0x1f];
}
Now rewriting it in unityscript, i'd already declared the variables in the previous section of code, but came up with the error "Type 'int' does not support slicing" and no matter what I use it comes up with the same error. So a bit of digging around said to use the "GetRange" keyword, so this is the rewritten code.
public function GetRange (
coordx : uint, coordy : uint, number_of_systems : int, coords : float, i : int
)
{
rotate_some();
coords[i].z = (systemParam_0 & 0xff0000) >> 16;
coords[i].y = (systemParam_0 >> 8);
coords[i].y /= 2;
coords[i].x = (systemParam_0 & 0x0001fe) >> 1;
coords[i].x /= 2;
coords[i].multiple = starChanceMultiples[systemParam_1 & 0x1f];
coords[i].stardesc = starChanceType[(systemParam_1 >> 16) & 0x1f];
}
Yet the same error comes up and as I said, i'm stumped, ref BCE0048
I realise it says 'float' in the second part of the code, but that was me trying to fix the problem :)
Also "systemParam_0" has already been declared earlier in the code and "starChance$$anonymous$$ultiples" and "starChanceType" are arrays that have also been written earlier in the code
I'm not sure what coords should be, but the way you're using it it's definitely not a float. Perhaps a list of some class or struct you've defined elsewhere, with variables z, y, x, multiple, and stardesc defined?
Your answer
Follow this Question
Related Questions
BCE0048: Type 'Object' does not support slicing 1 Answer
BCE0048 type Object does not support slicing 1 Answer
How to create a UnityScript array and access the data in each cell. 1 Answer
NullReferenceException: Object reference not set to an instance of an object - MonoBehaviour 2 Answers
Is it possible to loop through the variables of a custom object? 1 Answer