Username: Password:

Author Topic: [Tutorial] How to link two or more scripts.  (Read 1643 times)

Offline MikeOwh

  • Administrator
  • Wolf
  • *****
  • Posts: 143
  • Cookies 10003
  • Little imp.
    • View Profile
    • Skyket
[Tutorial] How to link two or more scripts.
« on: October 24, 2020, 01:02:06 AM »
I will be brief and concise.
For example you have these two scripts:


Script 1:
Code: [Select]
Spot = Location(32003, 30293, 7)
BuyPots = True

Set_Hunt = 0
Set_To_Hunt = 1
Set_To_Shop = 2


def onScriptActivation():
     script.StatusMessage('Starting script...')
     script.PZChecksForDrop(1)


def onChangeLocation(x, y, z):
     xyz = Location(x, y, z)
     way = script.GetWay()
     if xyz == Spot:
          if way == Set_Hunt:
               if BuyPots == True:
                    script.SetWay(Set_To_Shop, 2)
               else:
                    onDoStuff()


def onDoStuff():
     script.IgnoreMonsters(0)



Script 2:
Code: [Select]
Coordinate = Location(32457, 31874, 8)
ItemId = 5498


def onScriptActivation():
      script.IgnoreMonsters(1)


def onChangeLocation(x, y, z):
     xyz = Location(x, y, z)
     way = script.GetWay()
     if xyz == Coordinate:
          script.StatusMessage('Dropping item...')
          script.DropItem(ItemId, 1)



To link it you will have to group each def in case the same is used in both scripts.
Result:
Code: [Select]
Spot = Location(32003, 30293, 7)
BuyPots = True
Coordinate = Location(32457, 31874, 8)
ItemId = 5498

Set_Hunt = 0
Set_To_Hunt = 1
Set_To_Shop = 2


def onScriptActivation():
     script.StatusMessage('Starting script...')
     script.PZChecksForDrop(1)
     script.IgnoreMonsters(1)


def onChangeLocation(x, y, z):
     xyz = Location(x, y, z)
     way = script.GetWay()
     if xyz == Spot:
          if way == Set_Hunt:
               if BuyPots == True:
                    script.SetWay(Set_To_Shop, 2)
               else:
                    onDoStuff()
     elif xyz == Coordinate:
          script.StatusMessage('Dropping item...')
          script.DropItem(ItemId, 1)


def onDoStuff():
     script.IgnoreMonsters(0)
« Last Edit: October 24, 2020, 10:01:38 AM by =Mindee= »