MikeTaylor / scottkit

Scott Adams adventure toolkit: compile, decompile and play 80s-style adventure games
30 stars 10 forks source link

Break actions when they need too many conditions #31

Open MikeTaylor opened 6 years ago

MikeTaylor commented 6 years ago

At present, if an action or occurrence has too many instructions associated with it, the ScottKit compiler will automatically break it into a sequence of actions, all but the last finishing with an inserted continue.

We also need to do something analogous when we have an action or occurrence with too many conditions. If we use something like

action TO RAIL when carried rope and flag 3 and at balcony
    clear_flag 3
    destroy rope
    drop ropetied
    print "OK."
    look

saying:

scottkit/lib/scottkit/compile.rb:463:in `block in generate_code': condition has 6 conditions (RuntimeError)

But you can work around that by inserting continue occur 0% between the second and third actions.

The compiler should do this for you.

jpcompton commented 4 years ago

This workaround isn't effective for me.

This code:

action give script when here players and flag 5 and carried script
    print "We can play the MURDER OF GONZAGO!"
    print "They exit to the throne room"
    print "The play is ABOUT to begin!"
    destroy script
    put players throneroom
    continue occur 0%
    put claudius throneroom
    put gertrude throneroom

only puts the players in the throneroom, it doesn't move claudius or gertrude.

With the continue commented out, I get

jcompton$ scottkit -p rotten/rotten.sck
/Library/Ruby/Gems/2.3.0/gems/scottkit-1.6.0/lib/scottkit/compile.rb:463:in `block in generate_code': condition has 7 conditions (RuntimeError)
    from /Library/Ruby/Gems/2.3.0/gems/scottkit-1.6.0/lib/scottkit/compile.rb:457:in `each'
    from /Library/Ruby/Gems/2.3.0/gems/scottkit-1.6.0/lib/scottkit/compile.rb:457:in `generate_code'
    from /Library/Ruby/Gems/2.3.0/gems/scottkit-1.6.0/lib/scottkit/compile.rb:38:in `compile_to_stdout'
    from /Library/Ruby/Gems/2.3.0/gems/scottkit-1.6.0/lib/scottkit/game.rb:287:in `compile_to_stdout'
    from /Library/Ruby/Gems/2.3.0/gems/scottkit-1.6.0/bin/scottkit:115:in `block in <top (required)>'
    from /Library/Ruby/Gems/2.3.0/gems/scottkit-1.6.0/lib/scottkit/withio.rb:11:in `withIO'
    from /Library/Ruby/Gems/2.3.0/gems/scottkit-1.6.0/bin/scottkit:114:in `<top (required)>'
    from /usr/local/bin/scottkit:22:in `load'
    from /usr/local/bin/scottkit:22:in `<main>'
jpcompton commented 4 years ago

Another possible clue?

Replacing continue occur 0% with set_counter 1 produces the same behavior: the game compiles but the full list of actions doesn't take place.

(in any event, more informative error messages would also be appreciated here. It's not always clear at all where the problematic condition is!)