Username: Password:

Author Topic: [Help] how to add a list of coordinates to an array when using onChangeLocation  (Read 1071 times)

Offline conejo69

  • Bug
  • *
  • Posts: 2
  • Cookies 0
  • I love Mindee-BOT!
    • View Profile
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)
« Last Edit: August 16, 2023, 07:20:13 AM by conejo69 »



Offline MikeOwh

  • Administrator
  • Wolf
  • *****
  • Posts: 156
  • Cookies 10001
  • The DemonLord himself.
    • View Profile
    • OwhTool
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
« Last Edit: August 17, 2023, 02:17:42 PM by MikeOwh »

Offline conejo69

  • Bug
  • *
  • Posts: 2
  • Cookies 0
  • I love Mindee-BOT!
    • View Profile
 [likeasir]

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