[Thread Prev] [Thread Next]
A couple weeks ago there was a brief discussion of OKLs (One Key Logos) and
NKLs (No Key Logos). A part of this was my posting on 5/8 NKLbig.mw2, a small
project inspired by this discussion. Chuck wrote me off-list, asking some
questions about both a Project he wrote and also about the workings of
NKLbig.mw2.
It's been a star-crossed exchange, mainly, it turns out, because I was still
using EX v.1.0 (even though Shawn had previously sent me EX v.1.1), and
consequently couldn't open Chuck's Project, created in EX on a Mac. (It turns
out EX v.1.0, "isn't compatible with any other version of EX or any other LCSI
product.")
As if that weren't trouble enough, even after several attempts, my answers to
his questions re NKLbig.mw2 never get delivered to him, even though other
exchanges between us do. This mystery may involve some spam filter on his
school's system or somesuch.
So I am resorting to use of the Forum to get these answers to him. This seems
appropriate since these are questions about a MW project which has been posted
here.
1. "if (last mousepos) > -185 "
this ignores clicks that are too high, right?
Yes.
2 How do you prevent me from clicking under your row of menu items?
is there a xxx < -yyy somewhere?
I don't quite get the question. On my machine it displays with one line of
pixels below the row of menu items. Is that what you mean by "under"? I
suspect that's not what you mean. This program works mainly by using the
feature of MicroWorlds where clicks on a particular color causes an action.
The line in STARTUP, set "sky "mouseclick [DOIT] is what sets this up. It
says, "if the color under a mouseclick is "sky" run the procedure DOIT."
Since the image of the menu is drawn entirely in shades of "sky" (except the
borders, but including the letters of the words) and is a part of the frozen
background, there is no "under" for you to get to.
3. How did you build your "buttons" They aren't buttons. What are they? Just
"graphics?"
There are no "buttons" in the MicroWorlds sense. There are 2 methods being
used:
One method, a turtle, is used for the color-picker and for the pu/pd toggle.
Go to the Project Tab and open Page1. You'll see a total of 4 turtles. One,
"t1, is the turtle shown on the screen that the mouseclicks drive around. One
is "painter" which I'll get into below.
The other two are "pikcolor" and "pentoggle." Open their backpacks, and go to
their "Rules" tabs. Under "onclick" is a tiny window in which you can see a
portion of their Rules. It's a little hard to read the rules in that tiny
window, but when you manage it, here is what they say:
For "pentoggle, the Rule reads, "ifelse shape = 121 [setsh 122 t1, listen
PD] [setsh 121 t1, listen PU]" Go to the Shapes Tab, and find shapes 121 and
122, near the bottom. One is the image of the "Pen Up" highlight, the other
the "Pen Down."
How it works, is it looks at what shape it currently is (which is a sure
indicator of the status of the toggle), and whichever it is, it changes it to
the other, and changes the status of PenUp/PenDown at the same time.
The Rule for "Pikcolor reads: "PICKCOLOR mousepos t1, listen" Pickcolor is a
procedure, which takes the position of the mouse at the time of the click as
its input. It uses the xcor part of this (first mousepos) to determine which
color-band was clicked on, and does the appropriate setc on "t1.
Both of these contain "t1, listen" - which is necessary because by clicking on
these turtles you've just made them the "current tutle" and who needs to be
changed back to "t1. Otherwise, the mouseclicks on the "driving commands"
will drive around these turtles instead of "t1.
So, in the first case, the turtle is being used to do a simple job directly.
In the other case, it's being used to call a procedure to do a more complex
task.
OKAY, that's one of the two methods being used. The clue to the other method
can also be seen in the Page1 Project Tab: Both "white and "sky are
programmed colors. That is, anytime either of these colors is clicked on,
something under program control happens.
If you right-click on "sky" there in the Project Tab, and select "edit",
you'll see that clicking on the color sky triggers a call to DOIT. You can
also see this in the Startup Procedure. DOIT is the key functional procedure
of the Project. It figures out where on sky has been clicked, and takes the
appropriate action: clean, home, fd 30, etc.
The "white" instruction issues a code (make "now "true) that tells "Go to
Click" this is it, use this mousepos for the setpos. Note the waituntil
statement in DOIT, that needs :now = "true to proceed. Because this is the
very last instruction in DOIT, it can sit there waiting, and you can still use
the earlier parts of DOIT for more mouseclicks while it waits. (Note all the
other tests in DOIT stop the procedure before it gets down to the waituntil.)
4. Do the actual buttons I have in my file slow down the operation, because
buttons are slow? Or I have too many buttons on the page?
I don't think your program is sluggish at all. I don't see any way to
streamline its procedures.
There is one trick that will make it seem to run faster and also be a little
easier to use. Right now the key must be pressed followed by the <enter> key
to tell MW to execute the procedure. You may get rid of the necessity of
pressing the <enter> key in the following way:
to Startup
make "choices [F B L R U D S H]
s d cc
forever [GO]
end
to GO
make "key readchar
if member? :key :choices [run :key]
end
Readchar makes the program wait for a key to be pressed, and resumes execution
as soon as one is. In GO, "key is given the value of whatever key is pressed.
Then there is a test to see if :key is one of the one-key-commands. If it
is, [run :key] tells to execute.
This way, the users may press just the one key repeatedly to make the turtle
keep moving or turning.
5. How do you engage the PenUp and Pen down "buttons" in your file?
See above.
6. What is "painter?" Where is it???
"Painter is hiding underneath Go to Click (you can use "painter, st to find
it). Its job is to "paint" (fill) the Go to Click box a different color. This
does two things: first, it shows the user the status of Go to Click. It also
gives that square a color other than "sky", so further clicks on it won't
trigger more waituntils waiting around.
I hope this helps.
Regards, Jeff
Previous by thread:
a trip to SCANY
Next by thread:
MIA, Ask an Expert: space game
To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.
|