[Plugin] Hash table

Post your completed addons to share with the community

Post » Mon Feb 04, 2013 10:52 pm

Ah sorry got it.. had my hash names wrong. :)
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
5
G
5
Posts: 391
Reputation: 5,567

Post » Sat Feb 16, 2013 5:26 am

I'm trying to figure out something I'm using the new websocket plugin to communicate with a C# websocket server (which only communicates in JSON)

so I'm using a Hashtable to load the JSON so I can work with it

and example of what the server sends would be:

{"Command":0,"Data":{"Value":somevalue,"anotherValue":anothervalue}}

Hashtable is named MessageQue
now if I use MessageQue.At("Data.Value") I get somevalue returned

but if I try to do MessageQue.At("Data") I get 0 returned.

how can I get the full "{Value":somevalue,"anotherValue":anothervalue}"

reason I need this is because I have JSON formatted for the array load function in the Data section and I need to pull the entire string or the array load fails.

eg {"Command":3,"Data":{"c2array":true,"size":[1,1,2],"data":[[[2,7]]]}}

I need to pull out just the {"c2array":true,"size":[1,1,2],"data":[[[2,7]]]} part

Thanks in advance
B
6
S
1
G
1
Posts: 19
Reputation: 664

Post » Sat Feb 16, 2013 1:54 pm

Update
Expression:At, expression:AtKeys will return a JSON string if the item is an object.

@briermay
Download this plugin, and try MessageQue.At("Data") again, you could get "{"Value":somevalue,"anotherValue":anothervalue}"
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Sat Feb 16, 2013 10:32 pm

Thank you works perfectly was pulling my hair out how to get the array data out of the message.

loads a 900x900x20 array in 14 seconds so not bad :)
B
6
S
1
G
1
Posts: 19
Reputation: 664

Post » Sun Feb 17, 2013 12:01 am

@briermay

Call event 900x900x20 times in "1" tick is very crazy.
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Sun Feb 17, 2013 1:37 am

I'm not I'm simply loading a JSON array into a construct 2 array via the load function so that I can deal with the data later.

its basically a map grid
B
6
S
1
G
1
Posts: 19
Reputation: 664

Post » Tue Mar 05, 2013 8:50 pm

How do I iterate through the following JSON using this plugin?

[{id:"ab", name:"cd"}, {id:"fh", name:"ef"}, {id:"nm", name:"gh"}]

B
7
S
1
Posts: 7
Reputation: 839

Post » Wed Mar 06, 2013 4:12 am

@RedDragon

I need to add expression:"length" into this plugin, to iterate array structure.
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Wed Mar 06, 2013 4:21 am

@RedDragon

I make another solution by my function ext plugin.

It could iterate any kind of object by using javascript programming.rexrainbow2013-03-06 04:30:34
B
97
S
22
G
176
Posts: 4,108
Reputation: 103,019

Post » Wed Mar 06, 2013 12:11 pm

I have similar problem like @RedDragon, my data looks like this:

{"Question": [{"Sentence": "It is over there.","RightWord": "there"},{"Sentence": "Mr. Smith went to Washington.","RightWord": "Mr. Smith"},{"Sentence": "Hi my name is Jake.","RightWord": "hi"},{"Sentence": "We celebrate Christmas.","RightWord": "Christmas"},{"Sentence": "He wanted to climb Mt. Everest.","RightWord": "Mt. Everest"},{"Sentence": "I'm hungry.","RightWord": "I'm"}]}

But I am not able to iterate through it as I do not know the length. Only way I can think about is to use Hash.AtKeys("Question", i, "Sentence") and loop through i and check for null.

Do you think there is a better way ?

-Thanks
B
10
S
3
Posts: 69
Reputation: 1,590

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests