Mindee-BOT

Mindee-BOT Community => Scripting => Request => Topic started by: conejo69 on August 14, 2023, 06:46:08 pm

Title: [Help] how to add a list of coordinates to an array when using onChangeLocation
Post by: conejo69 on August 14, 2023, 06:46:08 pm
for example I have
iceone = (31874, 32477, 7)
icedos = (31866, 32483, 7)
icethree = (31862, 32484, 7)
icefour = (31848, 32478, 7)
icefive = (31895, 32487, 7)
icesix = (31913, 32484, 7)
iceseven = (31926, 32475, 7)
iceeight = (31905, 32480, 7)
icenine = (31905, 32480, 7)
not to make 9 lines of ....
only one example
as coordinates are added to an arreglp
for example I have
placeA = (31874, 32477, 7)
PlaceB = (31848, 32478, 7)
as
places = [placeA,PlaceB]
xxxxxxxx
if x == places[0] and y == places[1] and z == places[2]:
How can I use only 1 line where all the information of the coordinates is
if x == iceuno[0] and y == iceuno[1] and z == iceuno[2]:

script.UseItemId(6404)


if x == icedos[0] and y == icedos[1] and z == icedos[2]:
script.UseItemId(6404)

if x == icetres[0] and y == icetres[1] and z == icetres[2]:
script.UseItemId(6404)

if x == icefour[0] and y == icefour[1] and z == icefour[2]:
script.UseItemId(6404)

elif x == fiveice[0] and y == fivefive[1] and z == fivefive[2]:
script.UseItemId(6404)

if x == iceseis[0] and y == iceseis[1] and z == iceseis[2]:
script.UseItemId(6404)

if x == iceseven[0] and y == iceseven[1] and z == iceseven[2]:
script.UseItemId(6404)

if x == iceocho[0] and y == iceocho[1] and z == iceocho[2]:
script.UseItemId(6404)

if x == icenine[0] and y == icenine[1] and z == icenine[2]:
script.UseItemId(6404)
Title: Re: [Help] how to add a list of coordinates to an array when using onChangeLocation
Post by: MikeOwh on August 17, 2023, 02:13:18 pm
Single check:
Code: [Select]
locations = [(11111, 22222, 3), (11111, 22222, 3)]

def onChangeLocation(x, y, z):
    loc = (x, y, z)

    if (loc == locations[0]):
        pass

    elif (loc == locations[1]):
        pass


Multiple check:
Code: [Select]
locations = [(11111, 22222, 3), (11111, 22222, 3)]

def onChangeLocation(x, y, z):
    loc = (x, y, z)

    if (loc in locations):
        pass
Title: Re: [Help] how to add a list of coordinates to an array when using onChangeLocation
Post by: conejo69 on August 17, 2023, 06:29:19 pm
 [likeasir]

excellent this optimizes my code in less lines for the same action thank you