0
sendnpc = (npc2alive,Orinpc3,Posnpc3) 
Data = dumps((PosYou,OriYou,Shoot,txtt,Posnpc,Orinpc,npcalive,Posnpc2,Orinpc2,sendnpc))

I'm sending this material to another computer, the problem is when I'm unpacking it.

The unpacking part of the script looks like this:

Data, SRIP = GameLogic.sClient.recvfrom(1024)
UPData = loads(Data)
PosServer = [UPData[0][0],UPData[0][1],UPData[0][2]]
OriServer = [UPData[1][0],UPData[1][1],UPData[1][2]]
Server.setPosition(PosServer)
Server.setOrientation(OriServer)
Server.KeySens = UPData[2]
Pump1Shoot = UPData[2]
txt1.Text = UPData[3]
text = text + UPData[3]
Posnpc = [UPData[4][0],UPData[4][1],UPData[4][2]]
Orinpc = [UPData[5][0],UPData[5][1],UPData[5][2]]
npc.setPosition(Posnpc)
npc.setOrientation(Orinpc)
npcalives = UPData[6]
Posnpc2 = [UPData[7][0],UPData[7][1],UPData[7][2]]
Orinpc2 = [UPData[8][0],UPData[8][1],UPData[8][2]]
npc2.setPosition(Posnpc2)
npc2.setOrientation(Orinpc2)
npc2alives = UPData[9][0]
Posnpc3 = [UPData[9][1][0],UPData[9][1][1],UPData[9][1][2]]
Orinpc3 = [UPData[9][2][0],UPData[9][2][1],UPData[9][2][2]]
npc3.setPosition(Posnpc3)
npc3.setOrientation(Orinpc3)

The unpacking part works till I get to the 9th variable from the recived data (that is inside a tuple). The problem is that because I send an tuple nested in another tuple, when I'm unpacking it it looks like this:

PosYou,OriYou,Shoot,txtt,Posnpc,Orinpc,npcalive,Posnpc2,Orinpc2(npc2alive,Orinpc3,Posnpc3)

Now my question is simple, how can I unpack this correctly?

detly
30.6k20 gold badges101 silver badges161 bronze badges
asked May 26, 2011 at 5:59
1
  • Patched it up a bit, hope I didn't change any information :) Commented May 26, 2011 at 6:16

2 Answers 2

1

Nest the LHS tuples.

>>> a, b, (c, d, e) = [1, 2, [3, 4, 5]]
>>> a
1
>>> b
2
>>> c
3
>>> d
4
>>> e
5
answered May 26, 2011 at 6:01
Sign up to request clarification or add additional context in comments.

1 Comment

I now im being rly nob now, and kinda anoying and all thet stuf, but that answere dinden't make totaly sens for me.. what do LHS stand for?
1

I notice that in most cases, the position comes before the orientation. But, in that last tuple, you have the orientation before the position: (npc2alive,Orinpc3,Posnpc3). When you unpack it, you're inadvertantly swapping the two.

answered May 26, 2011 at 6:16

1 Comment

ahh!, some times the brain don't work that well!, that is it! thx for the help!!!

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.