Thank you for that explanation, that was a really clearly written example.
I have one more follow up question: is there an equivalent for this in RFTC?
var = {}
def setvec():
var[2] = []
var[2] = var[2] + [10]
var[2] = var[2] + [15]
def testvec():
setvec()
#store desired indexes in variables
var[0] = 0
var[1] = 1
#use variables as indexes in vector
print( var[2][ var[0] ] )
print( var[2][ var[1] ] )
Output:
>> testvec()
10
15
ADDENDUM:
The time where I have attempted to make this work was in SF3, and I just attempted it in a new installation of the RFTools Control mod via Forge, and I had no issues. Perhaps the version they have in SF3 is sub-par. Thank you for your assistance.
I’m having a hard time figuring out how vectors work. I can seem to index them using manually provided values (say I want to retrieve the value stored in index 0, I provide the constant 0 as the index like so, vector[0]), but when I try to index using a value stored in a variable, it tells me “Bad index value for vector” or something of the sort. (Say, I know the value stored in variable V:0 is set to 1, and I want to get the value stored in a vector at index 1. Indexing like so, vector[V:0], causes this issue.)
Is this by design? Or could it be that I am doing it wrong?
Note: trying to first evaluate the variable V:0 so it is stored in the temporary “last” variable has the same effect. I would think since you are provided the option to index a vector using things other than constants, the design would be to allow this. Correct me if I’m wrong.
1
Smart! Good thinking to get in the habit of saving space when it is so limited.
I got it going, I think I was trying to overcomplicate it. I will definitely check out those spotlights.
Thank you for your assistance. Sorry I’m not much help with the NBT code values. That would be a nice feature to implement.
0
@Tcll
Thank you for that explanation, that was a really clearly written example.
I have one more follow up question: is there an equivalent for this in RFTC?
var = {}
def setvec():
var[2] = []
var[2] = var[2] + [10]
var[2] = var[2] + [15]
def testvec():
setvec()
#store desired indexes in variables
var[0] = 0
var[1] = 1
#use variables as indexes in vector
print( var[2][ var[0] ] )
print( var[2][ var[1] ] )
Output:
>> testvec()
10
15
ADDENDUM:
The time where I have attempted to make this work was in SF3, and I just attempted it in a new installation of the RFTools Control mod via Forge, and I had no issues. Perhaps the version they have in SF3 is sub-par. Thank you for your assistance.
0
I’m having a hard time figuring out how vectors work. I can seem to index them using manually provided values (say I want to retrieve the value stored in index 0, I provide the constant 0 as the index like so, vector[0]), but when I try to index using a value stored in a variable, it tells me “Bad index value for vector” or something of the sort. (Say, I know the value stored in variable V:0 is set to 1, and I want to get the value stored in a vector at index 1. Indexing like so, vector[V:0], causes this issue.)
Is this by design? Or could it be that I am doing it wrong?
Note: trying to first evaluate the variable V:0 so it is stored in the temporary “last” variable has the same effect. I would think since you are provided the option to index a vector using things other than constants, the design would be to allow this. Correct me if I’m wrong.