A present to you!

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

A present to you!

rob cranfill
-- M8B.lua
-- [hidden email]

sW,sH = ui.mode()
sW2,sH2 = sW/2, sH/2

ui.font(1)
--  background
ui.clear(ui.rgb(206,71,32))

-- the 8-ball
ui.disc(sW2, sH2 , sW2, sH2, ui.rgb(0,0,0))

while(1) do

-- the window
ui.disc(sW2, sH2, sW2 /2, sH2 /2, ui.rgb(50,50,50))

os.sleep(0.5)

-- the triangle
ui.color(ui.rgb(0,0,255))

p1x,p1y = sW2, sW2*0.5
p2x,p2y = sW2*1.4, sW2*1.2
p3x,p3y = sW2*0.6, sW2*1.2

ui.line(p1x,p1y,p2x,p2y)
ui.line(p2x,p2y,p3x,p3y)
ui.line(p3x,p3y,p1x,p1y)

-- doesn't work!
--ui.fill(sW2,sW2)

m={"Yes", "No", "Maybe", "Ask again", "Not now", "Perhaps", "We shall
see", "I think so", "Definitely not", "Absolutely","Heck,
yeah!","Absotively!"}

ui.color(ui.rgb(0,0,255),ui.rgb(50,50,50))
m1=m[math.random(12)]

ui.moveto(sW2-2*ui.textwidth(m1)/2,sW2)
print(m1)

e = ui.event()
if e == ui.keyDown then break end

end -- while 1






------------------------ Yahoo! Groups Sponsor --------------------~-->
Get to your groups with one click. Know instantly when new email arrives
http://us.click.yahoo.com/.7bhrC/MGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: A present to you!

Mike Higgins-2
    I un-commented the ui.fill line in this program and  the triangle was correctly filled in on my Treo 650. But the fonts  displayed in the wrong place, usually hanging out the let side of the  triangle. Long text lines leave pieces of fonts out there that are not  over-written by shorter lines.

rob cranfill <[hidden email]> wrote:        -- M8B.lua
  -- [hidden email]
 

  -- doesn't work!
  --ui.fill(sW2,sW2)
 

 

                       
---------------------------------
Yahoo! Mail goes everywhere you do.  Get it on your phone.

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~-->
You can search right from your browser? It's easy and it's free.  See how.
http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply | Threaded
Open this post in threaded view
|

Re: A present to you!

Pal-3
In reply to this post by rob cranfill
Why is this statement in your Magic 8 Ball application?

> m1=m[math.random(12)]




cheers!


--- In [hidden email], "rob cranfill" <robcranfill@...> wrote:

>
> -- M8B.lua
> -- robcranfill@...
>
> sW,sH = ui.mode()
> sW2,sH2 = sW/2, sH/2
>
> ui.font(1)
> --  background
> ui.clear(ui.rgb(206,71,32))
>
> -- the 8-ball
> ui.disc(sW2, sH2 , sW2, sH2, ui.rgb(0,0,0))
>
> while(1) do
>
> -- the window
> ui.disc(sW2, sH2, sW2 /2, sH2 /2, ui.rgb(50,50,50))
>
> os.sleep(0.5)
>
> -- the triangle
> ui.color(ui.rgb(0,0,255))
>
> p1x,p1y = sW2, sW2*0.5
> p2x,p2y = sW2*1.4, sW2*1.2
> p3x,p3y = sW2*0.6, sW2*1.2
>
> ui.line(p1x,p1y,p2x,p2y)
> ui.line(p2x,p2y,p3x,p3y)
> ui.line(p3x,p3y,p1x,p1y)
>
> -- doesn't work!
> --ui.fill(sW2,sW2)
>
> m={"Yes", "No", "Maybe", "Ask again", "Not now", "Perhaps", "We shall
> see", "I think so", "Definitely not", "Absolutely","Heck,
> yeah!","Absotively!"}
>
> ui.color(ui.rgb(0,0,255),ui.rgb(50,50,50))
> m1=m[math.random(12)]
>
> ui.moveto(sW2-2*ui.textwidth(m1)/2,sW2)
> print(m1)
>
> e = ui.event()
> if e == ui.keyDown then break end
>
> end -- while 1





------------------------ Yahoo! Groups Sponsor --------------------~-->
Protect your PC from spy ware with award winning anti spy technology. It's free.
http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: A present to you!

rob cranfill
--- In [hidden email], "Pal" <greenchile505@...> wrote:
>
> Why is this statement in your Magic 8 Ball application?
>
> > m1=m[math.random(12)]
>

That's just about the most important statement in the whole program! :)
That's the statement that picks a random string from the "m" array, to
be printed to the screen just a few lines later.

I must confess that it's a bit icky that I had to hard-code that "12"
in there; that's the size of the "m" array, and it would be a lot
nicer if I could have just done something like I would have in Java,
 
  m1=m[math.random(m.size())]

but I couldn't figure out how to do that in Plua. Anyone?

 - rob






------------------------ Yahoo! Groups Sponsor --------------------~-->
Home is just a click away.  Make Yahoo! your home page now.
http://us.click.yahoo.com/DHchtC/3FxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: Re: A present to you!

Stefan Vorkoetter
rob cranfill wrote:
> I must confess that it's a bit icky that I had to hard-code that "12"
> in there; that's the size of the "m" array, and it would be a lot
> nicer if I could have just done something like I would have in Java,
>  
>   m1=m[math.random(m.size())]
>
> but I couldn't figure out how to do that in Plua. Anyone?
>
>  - rob

getn(m) ?


--
Stefan Vorkoetter
Capable Computing, Inc.


------------------------ Yahoo! Groups Sponsor --------------------~-->
Get to your groups with one click. Know instantly when new email arrives
http://us.click.yahoo.com/.7bhrC/MGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: A present to you!

rob cranfill
--- In [hidden email], Stefan Vorkoetter <stefan@...> wrote:
>
> getn(m) ?
>

No joy.

I saw that construct listed in the Plua docs, but I can't figure out
how to make it work. If I add

  n = getm(m)

I get

  Attempt to call global 'getn' (a nil value)

which I assume means I should prefix that call with something like
"os." or "ui.", but neither of those works and can't find the right thing.

  - rob









------------------------ Yahoo! Groups Sponsor --------------------~-->
You can search right from your browser? It's easy and it's free.  See how.
http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: Re: A present to you!

bh77a-2
Hi Rob,

Try "table.getn" and see if it works for you.  Works fine for me in
Plua 2.0b4.

Brian

On May 14, 2006, at 9:41 AM, rob cranfill wrote:

> --- In [hidden email], Stefan Vorkoetter <stefan@...> wrote:
>>
>> getn(m) ?
>>
>
> No joy.
>
> I saw that construct listed in the Plua docs, but I can't figure out
> how to make it work. If I add
>
>   n = getm(m)
>
> I get
>
>   Attempt to call global 'getn' (a nil value)
>
> which I assume means I should prefix that call with something like
> "os." or "ui.", but neither of those works and can't find the right
> thing.
>
>   - rob
>
>
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>



------------------------ Yahoo! Groups Sponsor --------------------~-->
Get to your groups with one click. Know instantly when new email arrives
http://us.click.yahoo.com/.7bhrC/MGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply | Threaded
Open this post in threaded view
|

Re: A present to you!

Pal-3
In reply to this post by rob cranfill
> > Why is this statement in your Magic 8 Ball application?
> >
> > > m1=m[math.random(12)]
> >
>
> That's just about the most important statement in the whole program! :)
> That's the statement that picks a random string from the "m" array, to
> be printed to the screen just a few lines later.

My post was just a joke. I love the irony of that a "random" function may decide what a
user may do next in life.

"Magic 8 Ball, should I marry Suzie or not?"

"No."

...

At least it started a brief and interesting conversation about Lua tables.



Cheers,
greenchile505






------------------------ Yahoo! Groups Sponsor --------------------~-->
Protect your PC from spy ware with award winning anti spy technology. It's free.
http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: A present to you!

Grey Knight
In reply to this post by rob cranfill
--- In [hidden email], "rob cranfill" <robcranfill@...> wrote:

> --- In [hidden email], Stefan Vorkoetter <stefan@> wrote:
> >
> > getn(m) ?
> >
>
> No joy.
>
> I saw that construct listed in the Plua docs, but I can't figure out
> how to make it work. If I add
>
>   n = getm(m)
>
> I get
>
>   Attempt to call global 'getn' (a nil value)
>
> which I assume means I should prefix that call with something like
> "os." or "ui.", but neither of those works and can't find the right
thing.
>


As I recall, getn() is the function name in Lua 4, and hence Plua 1.
In Lua 5 (Plua 2), we use table.getn() instead.






------------------------ Yahoo! Groups Sponsor --------------------~-->
Everything you need is one click away.  Make Yahoo! your home page now.
http://us.click.yahoo.com/AHchtC/4FxNAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/