Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break actions when they need too many conditions #31

Open
MikeTaylor opened this issue Oct 27, 2017 · 2 comments
Open

Break actions when they need too many conditions #31

MikeTaylor opened this issue Oct 27, 2017 · 2 comments

Comments

@MikeTaylor
Copy link
Owner

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
Copy link

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
Copy link

jpcompton commented May 22, 2020

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!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants