-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add a new enum type (maybe called options?) #755
Comments
Two more thoughts:
|
@jdanish We could use some more examples of enumerated variables. Other than color, can you provide three different examples of enumerated variables and how they might be used? |
Organism type: producer,consumer, decomposer Energy level low (1), medium (5), high (10) Fish state: hungry, content, full, dead |
Sorry ... how to use: For type, it might be that these are just labels that get applied and the enum is just to help guarantee consistent spelling. Alternatively, if a character is type "producer" then it gains energy from touching the sun. If it is type "consumer" it won't, but gains energy from touching a plant. Etc. For energy level, this might be a way to start the characters out at one of 3 levels using a drop-down with a label rather than having to guess good numbers. Fish, uses the state to determine how it looks (if hungry show the hungry thought balloon, if content, do not, if dead, do not interact). Etc. |
Thinking this through some more, we might have to implement an I suppose we could add a way to specify the value type with out a new keyword. But kind of depends on how expressions will be handled. |
Would it be possible to do a setOptions similar to setMin? Otherwise that makes sense. Thanks!
|
@jdanish working through the design of enums...I want to run this by you and @dsriseah to make sure that this makes sense. I think you're wanting to do multiple things:
But the GEMSCRIPT limitations around being able to assign GVar values to properties and feature properties are still active. e.g. we still can't do something like We did look into trying to implement After conferring with Sri, we think the appropriate solution is to introduce the concept of Constants. (This design doc will turn into the wiki writeup) This mostly works now, but there is a ton of cleanup that we still have to do to get it to a demo-able state. And if we want color support for the Costume feature, we would also need to add some new methods. Does this sound like it would address your needs? ConstantsConstants can be defined for any agent, including the global agent. Use the
|
I feel like I'm missing something here, and apologize. The main goal is to simplify the selection of values by a student. This feels like it is a) no different from using an all caps property, and b) requires advanced scripting anyhow (e.g., Exp). So while the color setting is cool, this doesn't really help simplify kid's lives and I am actually not sure I am seeing the advantage of using a constant over a prop that is well named? I apologize if I am missing something key. |
Yeah, the fundamental problem is that we cannot assign a GVar value to another property without resorting to stack operations. So any implementation is going to look like this. We can hack together a code-only version that only supports options for local agents (not global), but as soon as we try to implement a wizard for this, it all falls apart. The wizard can't access the options list. e.g. we can write this in GEMSCRIPT. and it works great...
..but if we use the wizard to select the line It occurs to me one possible terribly hacky workaround is to add something similar to the comment-bookmark widget (779a95f) where we bypass the standard wizard UI and inject a selection popup UI to access the list of options. The question is can we read the agent property options to construct the list. This would be hacky and probably setting a bad precedent. |
Pardon my ignorant question but thinking about how the Boolean wizard works, what if we had another gVar type that functioned like a Boolean but you could add key / value pairs and they all appear in the wizard as a drop-down? We could assume they are all strings or have an enumString and enumNumber (maybe called optionsString and optionsNumber)? I think that’d work like a mega Boolean from a user’s perspective and would make it so you don’t need to set to arbitrary values but a set list.Or if we have a setToOption instead of setTo which pulls the list? I like the first idea better but either would be better than the stack operations which I think only I understand…Or would that have the same problem? I love getting colors to be easier but I fear I’d never use constants because I can more easily have a comment above:// change this to ‘producer’ or ‘consumer’prop Animal.type setTo ‘producer’Kids could make mistakes but it’s far more intuitive than the stack functions for them I think.
|
Yeah, stack operations are not at all intuitive. And the questions aren't ignorant. It's a complex system that I definitely have trouble getting my head around. Creating another GVar type was essentially what I did with the That said, I'm playing with a workaround hack ala comment styles, where we essentially add another compile pass to first pull out constant definitions, and then hack an interface that allows you to select one of the defined constants. This works because we don't fundamentally change the script engine, but instead just shim in a UI to support selection. We'll see if it works. |
OK, cool. I’ll wait on the hack before offering more rambling then :)
|
The idea is that if you declare a variable, you could then set options (rather than min and max) that would then be made available in the wizard. So, something like:
addProp color options
prop color addOption red
prop color addOption blue
prop color addOption green
And then if you need to test or set it, the wizard would give a list of the options so that you knew that you were picking a valid choice.
I could imagine these ultimately being part of a number or string (or both)?
Something like:
addProp color string 'gray'
prop color addOption 'red'
prop color addOption 'green'
Then instead of setTo you could use setToOption and it'd give you a list of options?
The text was updated successfully, but these errors were encountered: