There were some new items like makeBlock, FindBlock and checkAllBlocks that I was not familiar with and that helped out greatly.
I am now trying to understand locations on the board now and need to write if then statements. I'll try the other forum you mentioned Nevin. How do I sign up for it?
On Fri, Jul 22, 2011 at 3:03 PM,
<lua-l-request@lists.lua.org> wrote:
Send lua-l mailing list submissions to
lua-l@lists.lua.org
To subscribe or unsubscribe via the World Wide Web, visit
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/lua-l-lists.lua.org
or, via email, send a message with subject or body 'help' to
lua-l-request@lists.lua.org
You can reach the person managing the list at
lua-l-owner@lists.lua.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of lua-l digest..."
Today's Topics:
1. Re: Compress a sequence of ends (Michal Kolodziejczyk)
2. Re: Multidimensional Arrays (Nevin Flanagan)
3. Re: Multidimensional Arrays (Steve Litt)
4. Re: Mysterious crash in patchlistaux() / getjump() (David Given)
5. Re: Mysterious crash in patchlistaux() / getjump()
(Roberto Ierusalimschy)
6. scripting a telnet session in lua (Wade Guidry)
7. Re: Mysterious crash in patchlistaux() / getjump() (Mike Pall)
8. luaL_checkboolean() equivalent? (Martin Guy)
----------------------------------------------------------------------
Message: 1
Date: Fri, 22 Jul 2011 14:10:09 +0200
From: Michal Kolodziejczyk <miko@wp.pl>
Subject: Re: Compress a sequence of ends
To: lua-l@lists.lua.org
Message-ID: <4E2968A1.4080602@wp.pl">4E2968A1.4080602@wp.pl>
Content-Type: text/plain; charset=ISO-8859-2
On 22.07.2011 02:10, David Manura wrote:
> I also commonly do things like
>
> for k=1, 10 do
> for j=1, 10 do
> for i=1, 10 do
> f(i, j, k)
> end end end
IMHO that is the only "clean" solution. You try to "fix" the way your
code looks like without changing the parser (both lua parser and text
editor parser). In fact, such kind of "compressions" could be built into
some text editors for those who need it (and would work for any language
- except python of course).
> Replacing `end end end` with `ennnd` or (preferably) `end3` is not
> going to gain much.
It would be sad to complicate the parser just to "fix" the look of a
source code.
Regards,
miko
------------------------------
Message: 2
Date: Fri, 22 Jul 2011 11:54:25 -0400
From: Nevin Flanagan <Alestane@comcast.net>
Subject: Re: Multidimensional Arrays
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID: <23AC3B78-D6F2-4F49-9C4D-497C39C2BC04@comcast.net">23AC3B78-D6F2-4F49-9C4D-497C39C2BC04@comcast.net>
Content-Type: text/plain; charset=us-ascii
On Jul 21, 2011, at 9:16 PM, Michelle Jenkins wrote:
> Hello Everybody,
>
> I am very new to programming. Currently I am using Corona SDK which uses the Lua language. I am trying my hand at my first game and have ran into a problems with arrays/tables. My game game screen is a follows. I have a background, with a 360 x 216 pixel gameboard with 16 spaces, 16 gamepieces that are located to the left of the board and are draggable, and a back button.
>
> --
> Michelle Jenkins
> Ultra Luxury Life
You may also find it helpful to join the #corona IRC channel on freenode, where several people familiar with both Corona and Lua are accustomed to providing starter advice (including myself).
Nevin
------------------------------
Message: 3
Date: Fri, 22 Jul 2011 13:11:11 -0400
From: Steve Litt <slitt@troubleshooters.com>
Subject: Re: Multidimensional Arrays
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID: <201107221311.11176.slitt@troubleshooters.com">201107221311.11176.slitt@troubleshooters.com>
Content-Type: Text/Plain; charset="iso-8859-1"
On Friday, July 22, 2011 02:38:14 AM Dirk Laurie wrote:
> On Fri, Jul 22, 2011 at 03:16:25AM +0200, Michelle Jenkins wrote:
> > I was told I should use multidimensional arrays as well as
> > tables. I don't know how to use either.
Michelle,
Everything Dirk writes below is true, and I think it's vital to add
one thing. A table is an official Lua data type. An array is a computer
science concept that *can be implemented* with a Lua table. Tables can
also implement:
* Data dictionary/hash
* Data structures (like C struct)
* Database tables (in memory)
* OOP classes
* Stacks
* Queues
None of the preceding is actually a part of Lua, but all can be
implemented using tables. So can arrays.
If I understand the situation correctly, Lua has exactly two types for
complex data:
1) Tables
2) Metatables
All other complex data is built from those two and doesn't exist in
the language.
The reason I believe it's important to be continuously aware of this
distinction is forgetting it can break your heart. There was a long,
long thread here about a year ago discussing what the value of
#tablename should be. In a Lua table it's the highest consecutive
integer key where the numeric keys start at 1. Everyone who thought of
the construct as an "array" was horrified that it didn't bring up the
actual number of items with integer keys, and they were horrified that
there was no difference between mytable[5] = nil and simply not
assigning anything to mytable[5]. Those who thought of it as a table
used by the application programmer to implement an array had no
problem with it, because that's how Lua tables work.
SteveT
>
> All tables start like this:
>
> A={} -- make a new empty table, different from all other
> tables
>
> after which you can put anything in it (we say "assign a value")
> like this:
>
> A[1] = 10 -- a number
> A[2] = 'abc' -- a string
> A[3] = {} -- an empty table
> A['abc'] = 2 -- the key into the table can be anything
> except nil A[3][1] = 42 -- A[3] is a table, right? So you can
> put anything in it. A.cde = A.abc -- if the key is a name
> (letters and digits, starts -- with a letter, you may write it
> this way
>
> An array is a table in which you have decided to use all the
> indices 1,2,3,...,m up to some value m called the "length" of the
> table. If you haven't yet assigned a value to say A[7], its value
> is automatically `nil`. If you have actually assigned non-nil
> values to A[1], A[2], ..., A[n] and you have not been using any
> other numbers as keys in A, Lua can figure out what m is from the
> table itself, this way:
>
> print(#A) --> 3 (We've assigned up to A[3] and no more)
>
> Otherwise it can't, and you have to remember m some other way, e.g.
> by saying `A.m=3`. (Non-numeric keys don't spoil the array
> property.) It really can't, but it will try. It will give you
> some number when you say `#A`, but don't believe that answer. It
> may be wrong. (It may even be right, but don't bet on it.)
>
> A two-dimensional array is a table in which each of those A[1] etc
> is a one-dimensional array which we call a "row". Strictly
> speaking those arrays need not be the same length but most of the
> time it's convenient if they are, say n. In that case we speak of
> an m by n array, and say it has m rows and n columns (although
> extracting a column as an array by itself takes some work). Most
> of the time you want to assign something to every element of the
> array, e.g.
>
> function array1D (m,x)
> -- make a new one-dimensional array with m elements
> -- all equal to x
> if x==nil then error("You may not make an array1D of nils")
> end local A={}
> for i=1,m do A[i]=x end
> return A
> end
>
> function array2D (m,n,x)
> -- make a new two-dimensional array with m rows and n
> columns -- in which every element equals x
> if x==nil then error("You may not make an array2D of nils")
> end local A={}
> for i=1,m do A[i]=array1D(n,x) end
> return A
> end
>
> With a two-dimensional array, you must be careful that the rows are
> really different arrays. This code does not work:
>
> function buggy_array2D (m,n,x)
> -- tries make a new two-dimensional array with m rows and n
> columns -- in which every element equals x, but fails
> return array1D(m,array1D(n,x))
> end
>
> Only one array of length n is created and it is assigned to every
> element. See:
>
> A = array2D(2,3,'a')
> A[1][3] = 42
> print(A[2][3]) --> a
> B = buggy_array2D(2,3,'b')
> B[1][3] = 42
> print(B[2][3]) --> 42
>
> Well, that's it for a start. After this, better read the reference
> manual to find out where I have been economical with the truth.
>
> Dirk
--
Steve Litt
Author: The Key to Everyday Excellence
http://www.troubleshooters.com/bookstore/key_excellence.htm
Twitter: http://www.twitter.com/stevelitt
------------------------------
Message: 4
Date: Fri, 22 Jul 2011 18:28:34 +0100
From: David Given <dg@cowlark.com>
Subject: Re: Mysterious crash in patchlistaux() / getjump()
To: lua-l@lists.lua.org
Message-ID: <4E29B342.1010108@cowlark.com">4E29B342.1010108@cowlark.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
David Given wrote:
[...]
> That's a very interesting suggestion --- I'll try bumping the stack size
> and seeing what happens. Thanks!
Problem solved!
It wasn't the stack --- it was more surreptitious than that...
I'm compiling in C++ mode. The definition of INT_MAX that was being seen
was the C++ one in <climits>:
const int INT_MAX = 0x7ffffff;
But then, luaconf was doing this:
#if INT_MAX-20 < 32760
#define LUAI_BITSINT 16
This of course was failing, because INT_MAX was not a macro. So
LUAI_BITSINT was being set to 16. But then we get this:
#define LUAI_MAXINT32 INT_MAX
This sets LUAI_MAXINT32 to 32, because INT_MAX is a valid value...
I think this is all the fault of my non-standard and highly eccentric
libc, BTW.
--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup
------------------------------
Message: 5
Date: Fri, 22 Jul 2011 15:25:39 -0300
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Subject: Re: Mysterious crash in patchlistaux() / getjump()
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID: <20110722182539.GA15630@inf.puc-rio.br">20110722182539.GA15630@inf.puc-rio.br>
Content-Type: text/plain; charset=us-ascii
> I'm compiling in C++ mode. The definition of INT_MAX that was being
> seen was the C++ one in <climits>:
>
> const int INT_MAX = 0x7ffffff;
>
> But then, luaconf was doing this:
>
> #if INT_MAX-20 < 32760
> #define LUAI_BITSINT 16
>
> This of course was failing, because INT_MAX was not a macro.
What compiler/options were you using that did not warn you about
an undefined macro being evaluated?
-- Roberto
------------------------------
Message: 6
Date: Fri, 22 Jul 2011 11:27:09 -0700
From: Wade Guidry <WGUIDRY@pugetsound.edu>
Subject: scripting a telnet session in lua
To: "lua-l@lists.lua.org" <lua-l@lists.lua.org>
Message-ID:
<106EE5982F7D6541B081BA9E2B65758601971921FF91@EXCH07B.pugetsound.edu">106EE5982F7D6541B081BA9E2B65758601971921FF91@EXCH07B.pugetsound.edu>
Content-Type: text/plain; charset="us-ascii"
I'm new to lua.
I'm trying to script a session against a telnet server (login, run a few commands within a menu-driven interface, then close the session).
I'm using lua sockets. My code appears below.
I'm not getting the expected results, though the code seems to run OK.
I'm trying to figure out how I can "see" what's going on during the session.
Is there a way in lua to echo back the server responses, for example?
Thanks very much for any thoughts or suggestions.
require 'socket'
local port = 23
local host = "hostname"
local conn = socket.connect(host, port)
socket.sleep (3)
local assert (conn:send ("user\n"))
socket.sleep (1)
local assert (conn:send("password\n"))
socket.sleep (1)
local assert (conn:send("a\n"))
socket.sleep (1)
local assert (conn:send("p\n"))
socket.sleep (1)
local assert (conn:send(" \n"))
socket.sleep (1)
local assert (conn:send("y\n"))
socket.sleep (1)
local assert (conn:send("s\n"))
socket.sleep (1)
local assert (conn:send("email@address.edu\n"))
socket.sleep (1)
local assert (conn:send("lua test\n"))
socket.sleep (1)
local assert (conn:send("lua test message\n"))
socket.sleep (1)
local assert (conn:send("^E\n")) (ed. note: not sure if this is the correct way to send a ctrl-E. Also tried \005 )
socket.sleep (1)
local assert (conn:send("s\n"))
socket.sleep (1)
local assert (conn:send(" \n"))
socket.sleep (1)
local assert (conn:send("q\n"))
socket.sleep (1)
local assert (conn:send("q\n"))
socket.sleep (1)
local assert (conn:send("x\n"))
socket.sleep (1)
conn:close()
Wade
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://vlists.pepperfish.net/cgi-bin/mailman/private/lua-l-lists.lua.org/attachments/20110722/25f4c487/attachment-0001.html
------------------------------
Message: 7
Date: Fri, 22 Jul 2011 20:33:59 +0200
From: Mike Pall <mikelu-1107@mike.de>
Subject: Re: Mysterious crash in patchlistaux() / getjump()
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID: <20110722183359.GA5282@mike.de">20110722183359.GA5282@mike.de>
Content-Type: text/plain; charset=us-ascii
Roberto Ierusalimschy wrote:
> > const int INT_MAX = 0x7ffffff;
> >
> > But then, luaconf was doing this:
> >
> > #if INT_MAX-20 < 32760
> > #define LUAI_BITSINT 16
> >
> > This of course was failing, because INT_MAX was not a macro.
>
> What compiler/options were you using that did not warn you about
> an undefined macro being evaluated?
Undefined tokens in expressions for pre-processing directives are
replaced with 0 prior to evaluation. There's no reason to give a
warning here.
--Mike
------------------------------
Message: 8
Date: Fri, 22 Jul 2011 21:02:59 +0200
From: Martin Guy <martinwguy@gmail.com>
Subject: luaL_checkboolean() equivalent?
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID:
<CAL4-wQo7T8K68oMx291Z9aHKByH2r0Sqc-9VRMnvxgLxHXnAXg@mail.gmail.com">CAL4-wQo7T8K68oMx291Z9aHKByH2r0Sqc-9VRMnvxgLxHXnAXg@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi
I'm new to the Lua C interface and wonder if comeone can suggest
the best Lua idiom to receive a boolean parameter into a C function?
I was hoping for something like:
int self_destruct( lua_state *L )
{
bool are_you_sure = luaL_checkboolean( L, 1 );
but luaL_checkboolean doesn't exist. Of course, it couldn't fail with
a type error, because nil and false are false, while true and
everything else are true, but do I really have to check the type of
the parameter and check for nil and false explicitly, with some garply
like:
bool are_you_sure = ! ( lua_isnil( L, 1 ) || (lua_isboolean( L, 1 )
&& ! lua_toboolean( L, 1 ) );
or is there a cleaner way?
Cheers
M
------------------------------
_______________________________________________
lua-l mailing list
lua-l@lists.lua.org
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/lua-l-lists.lua.org
End of lua-l Digest, Vol 12, Issue 89
*************************************
--
Michelle Jenkins
Ultra Luxury Life