Jump to content

How to access a stringmap with a string variable


movomo

Recommended Posts

So.. well this sounds stupid but I'm really not sure if I'm doing this right.

 

string_var key

Ext     ;this is a stringmap

 

I don't know exactly when I should or should not use $ operator.

 

Ext->$key     ;fails to compile

Ext->key      ;can be compiled but looks like it will accepts key as a literal string "key"

Ext->"%z" key     ;fail

Ext[key]    ;not fail but looks wrong

Ext[$key]     ;seems good but not sure

 

Which one is right? :huh:

 

+ and one more question,

if some function is expecting various type of variable as argument, like ar_Haskey, do I attach $ in front of the string variable?

Link to comment

It goes like this.

 

 

array_var dataArray
string_var strValue

let dataArray := ar_Construct StringMap
let dataArray["Key"] := ar_Construct Array

let dataArray["Key"][0] := "111111"
let dataArray["Key"][1] := "22222"
or 
let dataArray->Key[0] := "11111"
let dataArray->Key[1] := "222222"

let strValue := dataArray->Key[0]
let dataArray["Key"][1] := strValue

let dataArray["Key"] := ar_Null
let dataArray := ar_Null

 

 

Because it is serious, I may know that I misunderstand it, but write it.

Sequence of OBSE has three kinds of models.

Array

Map

StringMap

 

Any type of sequence is not different in the value that it can store.

Even character string can store away even numerical value.

 

The difference in three kinds of models is only different in the designated method of the element of the sequence.

The Array type appoints an element with an integer value of the plus.

The StringMap type appoints an element by character string.

The Map type appoints an element with an floating point value.

Link to comment

Thanks for the answer, but can you give me some more instructions?

 

What I want to do is,

"accessing a stringmap's element with specified key as form of a string variable"

 

I want to 'generate' the string variable dynamically inside of my function, then access the element with that key.

 

Is this possible?

Link to comment

I do not have experience with such use.

I was able to compile it normally in CS when I described it like the following cords.

However, I really start a game and do not check it.

You must check it.

 

 

 

let test := ar_Construct StringMap
let indexStr := "AA"
let test[$indexStr] := ar_Construct Array
let test[$indexStr][0] := 1

 

 

 

About the risk about using an element of the sequence that an author does not grasp.

When a user saved data, the sequence data are saved in .obse file.

If you do not cancel it intentionally unless you use it by a user definition function, it is accumulated.

This is in a very dangerous state.

When it makes stable MOD to manage the formed sequence data definitely, it is important.

I think that this thing understands it enough if it is you.

Link to comment

So.. well this sounds stupid but I'm really not sure if I'm doing this right.

 

string_var key

Ext     ;this is a stringmap

 

I don't know exactly when I should or should not use $ operator.

 

Ext[key]    ;not fail but looks wrong

 

Which one is right? :huh:

Ext[key] is right.

 

I use this method extensively in RaperS to keep track of which rapers are/aren't done with a gangrape victim. Since arrays can not take references as keys' date=' I build strings from the references and use those.

 

Example snippet:

let str0 := sv_Construct "%i" rGBangNext
if GetRandomPercent < gbangsatisfied && ( rGBangNext != Player || gbangplayerpref != 3 )
let arGBangDone[tmpk][str0] := tmpi + 1
printc "Unsatisfied gangrape by %n(%i)" rGBangNext rGBangNext
else
let arGBangDone[tmpk][str0] := -1 * ( tmpi + 1 )
printc "Satisfied gangrape by %n(%i)" rGBangNext rGBangNext
endif

 

 

+ and one more question,

if some function is expecting various type of variable as argument, like ar_Haskey, do I attach $ in front of the string variable?

 

Don't need to:

if ar_HasKey arGBangDone[tmpk] str0

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use