Jump to content
  • We need you!

    You must register to discover all the features of our community!

  • 0

How read 2 loop simultaneously ( for in ) ?


Mustang

Question

Hello, 

 

I recently add new Jewel (permanent)

and I would like for example that on item 14500 we can add the 2 different accessories

 

I test these code :

 

JewelAccessoryInfos = [
		# jewel		wrist	neck	ear
		[ 50634,	14420,	16220,	17220 ],
		[ 50635,	14500,	16500,	17500 ],
		[ 50636,	14520,	16520,	17520 ],
		[ 50637,	14540,	16540,	17540 ],
		[ 50638,	14560,	16560,	17560 ],
		[ 50639,	14570,	16570,	0 ],

	]

JewelAccessoryInfos2 = [
		# jewel		wrist	neck	ear
		[ 951004,	14000,	16000,	17000 ],
		[ 951005,	14020,	16020,	17020 ],
		[ 951006,	14040,	16040,	17040 ],
		[ 951007,	14060,	16060,	17060 ],
		[ 951008,	14080,	16080,	17080 ],
		[ 951009,	14100,	16100,	176100 ],
		[ 951010,	14120,	16120,	17120 ],
		[ 951011,	14140,	16140,	17140 ],
		[ 951012,	14160,	16160,	17160 ],
		[ 951013,	14180,	16180,	17180 ],
		[ 951014,	14200,	16200,	17200 ],
		[ 951015,	14220,	16220,	17220 ], 
		[ 951016,	14500,	16500,	17500 ],
		[ 951017,	14520,	16520,	17520 ],
		[ 951018,	14540,	16540,	17540 ],
		[ 951019,	14560,	16560,	17560 ],
	]

def GET_ACCESSORY_MATERIAL_VNUM(vnum, subType):
	ret = vnum
	item_base = (vnum / 10) * 10

	for info in JewelAccessoryInfos:
		if item.ARMOR_WRIST == subType:
			if info[1] == item_base:
				return info[0]
		elif item.ARMOR_NECK == subType:
			if info[2] == item_base:
				return info[0]
		elif item.ARMOR_EAR == subType:
			if info[3] == item_base:
				return info[0]

	for info2 in JewelAccessoryInfos2:
		if item.ARMOR_WRIST == subType:
			if info2[1] == item_base:
				return info2[0]
		elif item.ARMOR_NECK == subType:
			if info2[2] == item_base:
				return info2[0]
		elif item.ARMOR_EAR == subType:
			if info2[3] == item_base:
				return info2[0]

In thise case only first loop works and it not read second loop

 

I test this too :

 

JewelAccessoryInfos = [
		# jewel		wrist	neck	ear
		[ 50634,	14420,	16220,	17220 ],
		[ 50635,	14500,	16500,	17500 ],
		[ 50636,	14520,	16520,	17520 ],
		[ 50637,	14540,	16540,	17540 ],
		[ 50638,	14560,	16560,	17560 ],
		[ 50639,	14570,	16570,	0 ],# 오광귀걸이는 없음(귀걸이는 수인관련)

	]

JewelAccessoryInfos2 = [
		# jewel		wrist	neck	ear
		[ 951004,	14000,	16000,	17000 ],
		[ 951005,	14020,	16020,	17020 ],
		[ 951006,	14040,	16040,	17040 ],
		[ 951007,	14060,	16060,	17060 ],
		[ 951008,	14080,	16080,	17080 ],
		[ 951009,	14100,	16100,	176100 ],
		[ 951010,	14120,	16120,	17120 ],
		[ 951011,	14140,	16140,	17140 ],
		[ 951012,	14160,	16160,	17160 ],
		[ 951013,	14180,	16180,	17180 ],
		[ 951014,	14200,	16200,	17200 ],
		[ 951015,	14220,	16220,	17220 ], 
		[ 951016,	14500,	16500,	17500 ],
		[ 951017,	14520,	16520,	17520 ],
		[ 951018,	14540,	16540,	17540 ],
		[ 951019,	14560,	16560,	17560 ],
	]

def GET_ACCESSORY_MATERIAL_VNUM(vnum, subType):
	ret = vnum
	item_base = (vnum / 10) * 10

	for info, info2 in zip(JewelAccessoryInfos, JewelAccessoryInfos2):
		if item.ARMOR_WRIST == subType:
			if info[1] == item_base or info2[1] == item_base:
				return info[0] or info2[0]
		elif item.ARMOR_NECK == subType:
			if info[2] == item_base or info2[2] == item_base:
				return info[0] or info2[0]
		elif item.ARMOR_EAR == subType:
			if info[3] == item_base or info2[3] == itembase: 
				return info[0] or info2[0]

 

This code don't work too

I'm a fucking noob in python, someone have some advice ?

Edited by Mustang (see edit history)
Link to post

4 answers to this question

Recommended Posts

  • 0
  • VIP

You can't just return in the first loop, a return means that the function did the job, and has an result, anythink after return will not be used. One example about what can you do:

def GET_ACCESSORY_MATERIAL_VNUM(vnum, subType):
	ret = vnum
	item_base = (vnum / 10) * 10

	result = [None, None]

	for info in JewelAccessoryInfos:
		if item.ARMOR_WRIST == subType:
			if info[1] == item_base:
				result[0] = info[0]
		elif item.ARMOR_NECK == subType:
			if info[2] == item_base:
				result[0] = info[0]
		elif item.ARMOR_EAR == subType:
			if info[3] == item_base:
				result[0] = info[0]

	for info2 in JewelAccessoryInfos2:
		if item.ARMOR_WRIST == subType:
			if info2[1] == item_base:
				result[1] = info2[0]
		elif item.ARMOR_NECK == subType:
			if info2[2] == item_base:
				result[1] = info2[0]
		elif item.ARMOR_EAR == subType:
			if info2[3] == item_base:
				result[1] = info2[0]
    
	return result #will be [info[0], info2[0]]

 

Edited by IonutRO (see edit history)
Link to post
  • 0

Hi Ionut,

 

JewelAccessoryInfos = [
		# jewel		wrist	neck	ear
		[ 50634,	14420,	16220,	17220 ],
		[ 50635,	14500,	16500,	17500 ],
		[ 50636,	14520,	16520,	17520 ],
		[ 50637,	14540,	16540,	17540 ],
		[ 50638,	14560,	16560,	17560 ],
		[ 50639,	14570,	16570,	0 ],# 오광귀걸이는 없음(귀걸이는 수인관련)

	]

JewelAccessoryInfos2 = [
		# jewel		wrist	neck	ear
		[ 951004,	14000,	16000,	17000 ],
		[ 951005,	14020,	16020,	17020 ],
		[ 951006,	14040,	16040,	17040 ],
		[ 951007,	14060,	16060,	17060 ],
		[ 951008,	14080,	16080,	17080 ],
		[ 951009,	14100,	16100,	176100 ],
		[ 951010,	14120,	16120,	17120 ],
		[ 951011,	14140,	16140,	17140 ],
		[ 951012,	14160,	16160,	17160 ],
		[ 951013,	14180,	16180,	17180 ],
		[ 951014,	14200,	16200,	17200 ],
		[ 951015,	14220,	16220,	17220 ], 
		[ 951016,	14500,	16500,	17500 ],
		[ 951017,	14520,	16520,	17520 ],
		[ 951018,	14540,	16540,	17540 ],
		[ 951019,	14560,	16560,	17560 ],
	]

def GET_ACCESSORY_MATERIAL_VNUM(vnum, subType):
	ret = vnum
	item_base = (vnum / 10) * 10

	result = [None, None]

	for info in JewelAccessoryInfos:
		if item.ARMOR_WRIST == subType:
			if info[1] == item_base:
				result[0] = info[0]
		elif item.ARMOR_NECK == subType:
			if info[2] == item_base:
				result[0] = info[0]
		elif item.ARMOR_EAR == subType:
			if info[3] == item_base:
				result[0] = info[0]

	for info2 in JewelAccessoryInfos2:
		if item.ARMOR_WRIST == subType:
			if info2[1] == item_base:
				result[1] = info2[0]
		elif item.ARMOR_NECK == subType:
			if info2[2] == item_base:
				result[1] = info2[0]
		elif item.ARMOR_EAR == subType:
			if info2[3] == item_base:
				result[1] = info2[0]
    
	return result #will be [info[0], info2[0]]

	if item.ARMOR_WRIST == subType:
		WRIST_ITEM_VNUM_BASE = 14000
		ret -= WRIST_ITEM_VNUM_BASE
	elif item.ARMOR_NECK == subType:
		NECK_ITEM_VNUM_BASE = 16000
		ret -= NECK_ITEM_VNUM_BASE
	elif item.ARMOR_EAR == subType:
		EAR_ITEM_VNUM_BASE = 17000
		ret -= EAR_ITEM_VNUM_BASE

	type = ret/20

	if type<0 or type>=len(ACCESSORY_MATERIAL_LIST):
		type = (ret-170) / 20
		if type<0 or type>=len(ACCESSORY_MATERIAL_LIST):
			return 0

	return ACCESSORY_MATERIAL_LIST[type]

 

in your code " return result it generates a syserr

 

1016 10:14:05861 :: TypeError 1016 10:14:05861 :: : 1016 10:14:05861 :: an integer is required

 

maybe in this way, he can't return 2 values ?

Link to post
  • 0
  • VIP
6 minutes ago, Mustang said:

Hi Ionut,

 

 

in your code " return result it generates a syserr

 

1016 10:14:05861 :: TypeError 1016 10:14:05861 :: : 1016 10:14:05861 :: an integer is required

 

maybe in this way, he can't return 2 values ?

You also need to rewrite the code where you call GET_ACCESSORY_MATERIAL_VNUM(), in this moment is expected only one int number. In the new function, will return an array with 2 int numbers.

Link to post
  • 0
  • VIP
JewelAccessoryPermaInfo = [
		# PermaJewel		wrist	neck	ear
		[ 50640,	14020,	16020,	17020 ],
		[ 50641,	14040,	16040,	17040 ],
		[ 50642,	14060,	16060,	17060 ],
		[ 50643,	14080,	16080,	17080 ],
		[ 50644,	14100,	16100,	17100 ],
		[ 50645,	14120,	16120,	17120 ],
		[ 50646,	14140,	16140,	17140 ],
		[ 50647,	14160,	16160,	17160 ],
		[ 50648,	14180,	16180,	17180 ],
		[ 50649,	14200,	16200,	17200 ],
		[ 50650,	14220,	16220,	17220 ],
		[ 50651,	14500,	16500,	17500 ],
		[ 50652,	14520,	16520,	17520 ],
		[ 50653,	14540,	16540,	17540 ],
		[ 50654,	14560,	16560,	17560 ],
		[ 50655,	14570,	16570,	17230 ],

	]

def GET_ACCESSORY_MATERIAL_PERMANENT(vnum, subType):
	ret = vnum
	item_base = (vnum / 10) * 10
	for info in JewelAccessoryPermaInfo:
		if item.ARMOR_WRIST == subType:
			if info[1] == item_base:
				return info[0]
		elif item.ARMOR_NECK == subType:
			if info[2] == item_base:
				return info[0]
		elif item.ARMOR_EAR == subType:
			if info[3] == item_base:
				return info[0]

 

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Current Donation Goals

  • Activity

    1. 11

      Mysql56 to Mysql8

    2. 0

      Does anyone have Kami-Sama's Contact?

    3. 1

      [Trailer][1/3]NerviL2 The return of the Legend

    4. 0

      Won " price" change

    5. 10

      Inferna - The new "metin3"?

    6. 6

      We need you!

    7. 2

      Highlight system bug

  • Recently Browsing

    No registered users viewing this page.

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.