def walkto(x, y, obj=None): #ds = example.getDeviceSize() #print('device size is ' + str(ds)) s = script.Script(id='_main') s.addAction(sa.Walk(pos=[x, y], tag='player')) example.play(s) print('clicked on ' + str(x) + ', ' + str(y))
def handler2_do(sc : script.Script): item2 : s.Item = s.Data.items[s.Config.item2] # s.State.items[s.Config.item1] walkto = helper.gdd(item2, 'walkto', None) wdir = helper.gdd (item2, 'wdir', None) if walkto is not None: sc.addAction( sa.Walk(pos = walkto, tag = 'player')) if wdir is not None: sc.addAction( sa.Turn(dir = wdir, tag = 'player')) asc = get_action_script (s.Config.verb + '_' + s.Config.item1 + '_' + s.Config.item2, s.Config.verb +'_') if asc: sc.addAction (actions.RunScript (s = asc))
def cook(): def setCookInKitchen(): var.cook_in_kitchen = True # if coming from kitchen, cook should be added to the scene! cook_pos = [125, 17] if engine.previous_room == 'kitchen': var.cook_in_kitchen = False s = Script() # make the cook cook = makeCook(cook_pos, 'n') s.addAction(actions.AddEntity(cook, 'walkarea')) s.addAction(actions.Delay(sec=5)) s.addAction(act.Walk(tag='cook', pos=var.scummbar_kitchen_door_pos)) s.addAction(actions.RemoveEntity(tag='cook')) s.addAction(actions.CallFunc(f=setCookInKitchen)) example.play(s) else: var.cook_in_kitchen = True cook = makeCook(var.scummbar_kitchen_door_pos, 'w') s = Script() s.addAction(action=actions.Delay(sec=10), id=0) s.addAction( actions.RunScript(s=scr.openDoor(doorId='scummbar.door.kitchen', var='scummbar_kitchen')())) s.addAction(actions.AddEntity(cook, 'walkarea')) s.addAction(act.Walk(tag='cook', pos=cook_pos)) s.addAction(act.Turn(tag='cook', dir='n')) s.addAction(actions.Delay(sec=5)) s.addAction(act.Walk(tag='cook', pos=var.scummbar_kitchen_door_pos)) s.addAction(actions.RemoveEntity(tag='cook')) s.addAction( actions.RunScript(s=scr.closeDoor(doorId='scummbar.door.kitchen', var='scummbar_kitchen')())) s.loop = 0 example.play(s)
def handler2(): # the rule is. Walk to item 2, but you need to HAVE item 1. # so if you print ('A') sc = script.Script(id = '_main') if s.Config.item2: print ('B') item1 : s.Item = s.Data.items[s.Config.item1] # s.State.items[s.Config.item1] if s.State.has(s.Config.item1): handler2_do(sc) else: # try to pick up item1 print ('try to pick up ' + s.Config.item1) walkto = helper.gdd(item1, 'walkto', None) wdir = helper.gdd (item1, 'wdir', None) if walkto is not None: sc.addAction( sa.Walk(pos = walkto, tag = 'player')) if wdir is not None: sc.addAction( sa.Turn(dir = wdir, tag = 'player')) # ok, now check if pickup action is available func = 'pickup_'+s.Config.item1 if hasattr(engine.scripts.actions, func): a = getattr(engine.scripts.actions, func)() sc.addAction (actions.RunScript(s=a)) # now go to item 2 ONLY IF item is in inventory sc.addAction (actions.CallFunc (f = handler2_sub)) else: # no pick up action, then do nothing. func = s.Config.verb + '_' if hasattr(engine.scripts.actions, func): a = getattr(engine.scripts.actions, func)() sc.addAction (actions.RunScript(s=a)) example.play(sc) else: s.Config.wait_for_second_item = True print ('QUI') from lib_py.scumm.entity import update_current_action update_current_action()
def handler1(): item : s.Item = s.Data.items[s.Config.item1] # s.State.items[s.Config.item1] sc = script.Script(id = '_main') # if item has a walk-to attribute, walk to it # only if item is not owned if not s.State.has(s.Config.item1): walkto = engine.read (item, 'walkto', default_value=None) wdir = engine.read (item, 'wdir', default_value=None) if walkto is not None: sc.addAction( sa.Walk(pos = walkto, tag = 'player')) if wdir is not None: sc.addAction( sa.Turn(dir = wdir, tag = 'player')) # check if we have a custom script for this action func = s.Config.verb+'_'+s.Config.item1 if hasattr(engine.scripts.actions, func): a = getattr(engine.scripts.actions, func)() if a: sc.addAction (actions.RunScript(s=a)) else: # look for default action func = s.Config.verb + '_' if hasattr(engine.scripts.actions, func): a = getattr(engine.scripts.actions, func)() if a: sc.addAction (actions.RunScript(s=a)) print ('not found') # print ('ciao ' + s.Config.verb) # if s.Config.verb in item.actions: # a = item.actions[s.Config.verb]() # if a: # sc.addAction (actions.RunScript(s = a)) # else: # v = s.Config.getVerb(s.Config.verb) # if v.default_action: # a = v.default_action() # sc.addAction (actions.RunScript(s = a)) sc.addAction (sa.ResetVerb()) example.play(sc)
def handler1(): item: s.Item = s.State.items[s.Config.item1] sc = script.Script(id='_main') # if item has a walk-to attribute, walk to it if item.walkto: x = item.walkto[0] y = item.walkto[1] print('walking to ' + str(x) + ', ' + str(y)) sc.addAction(sa.Walk(pos=[x, y], tag='player')) if item.dir: sc.addAction(sa.Turn(dir=item.dir, tag='player')) # check if we have a custom script for this action print('ciao ' + s.Config.verb) if s.Config.verb in item.actions: a = item.actions[s.Config.verb]() if a: sc.addAction(actions.RunScript(s=a)) else: v = s.Config.getVerb(s.Config.verb) if v.default_action: a = v.default_action() sc.addAction(actions.RunScript(s=a)) sc.addAction(sa.ResetVerb()) example.play(sc)
def init(): if engine.previous_room == 'lookout': sc = Script(id='_main') sc.addAction(act.Walk(pos=[280, 10], tag='player')) example.play(sc)