Пример #1
0
 def f():
     s = script.Script()
     if pos is not None:
         Data.putItem(State.player, room, fetch(pos), node)
         if dir is not None:
             Data.items[State.player]['dir'] = dir
     s = script.Script()
     s.addAction(act.ChangeRoom(room=room))
     return s
Пример #2
0
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))
Пример #3
0
    def f():
        def g():
            State.variables[var] = 'closed'

        s = script.Script()
        s.addAction(act.Animate(anim='closed', tag=doorId))
        s.addAction(act.CallFunc(f=g))
        return s
Пример #4
0
 def f():
     sc = script.Script()
     for b in args:
         pos= characters[b[0]][0]
         col = characters[b[0]][1]
         print ('position = ' + str(pos[0]))
         for c in b[1:]:
             sc.addAction (actions.Msg(text = strings[c], font='monkey', pos = (pos[0], pos[1], 5), color = col))
     return sc
Пример #5
0
    def f():
        def g():
            setattr(State.md.doors, var, 'open')
            #State.variables[var] = 'open'

        s = script.Script()
        s.addAction(act.Animate(anim='open', tag=doorId))
        s.addAction(act.CallFunc(f=g))
        return s
Пример #6
0
 def f():
     sc = script.Script()
     for b in args:
         lines = []
         for c in b[1:]:
             lines.append(s[c])
         #print ('adding action ' + str(lines))
         sc.addAction(sa.Say(lines=lines, tag=b[0]))
     return sc
Пример #7
0
 def f():
     sc = script.Script(id = '_main2')
     if s.State.has(item):
         handler2_do (sc)
     else:
         # fail
         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)
Пример #8
0
 def f():
     # get the current player
     currentPlayer = State.player
     State.setDynamicItem(id=currentPlayer,
                          room=room,
                          pos=pos,
                          chardir=dir,
                          state='idle',
                          parent='walkarea')
     s = script.Script()
     s.addAction(act.ChangeRoom(room=room))
     return s
Пример #9
0
 def f():
     sc = script.Script()
     an = True
     for b in args:
         tag = b[0]
         print (tag)
         for c in b[1:]:
             if isinstance(c, tuple):
                 animate = True if c[0] == 'a' else False
                 l = [s[x] for x in list(c[1:])]
                 #print ('say ' + str(l))
                 sc.addAction (sa.Say (lines = l, tag = tag, animate = animate)) 
             elif isinstance(c, str):
                 # check if we have pending lines
                 i = c.find(':')
                 act = c[:i]
                 print ('adding ' + act)
                 sc.addAction (d3h[act](tag, c[i+1:]))
     print ('script has ' + str(len(sc.actions))  + ' acts.')
     return sc
Пример #10
0
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()
Пример #11
0
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)
Пример #12
0
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)
Пример #13
0
 def f():
     sc = script.Script()
     for b in args:
         sc.addAction(b)
     return sc
Пример #14
0
 def f():
     s = script.Script()
     s.addAction(sa.Say(lines=lines, tag=tag, font='monkey'))
     return s
Пример #15
0
 def f():
     s = script.Script()
     s.addAction(sa.StartDialogue(character))
     return s
Пример #16
0
 def f():
     s = script.Script()
     print('REMOVE ' + id)
     s.addAction(act.RemoveEntity(tag=id))
     s.addAction(sa.AddToInventory(id, 1))
     return s
Пример #17
0
 def f():
     s = script.Script()
     l = [gt(line) for line in lines]
     s.addAction(sa.Say(lines=l, tag=tag, font='monkey'))
     return s