lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Lee Shallis once stated:
> On Tue, 25 Feb 2020 at 08:55, Lee Shallis <gb2985@gmail.com> wrote:
> >
> > This is where I think the problem lies:
> > if v.list then
> >         for j,x in pairs(v.list) do
> >             k = {}
> >             k.desc = x.desc
> >             k.offset = x.offset
> >             if x.offset then
> >                 k.addr = v.addr + x.offset
> >             else
> >                 k.addr = x.addr
> >             end
> >             k.Type = x.Type
> >             k.size = x.size
> >             k.list = x.list
> >             k.count = x.count
> >             k.split = x.split
> >             k.generated = x.generated
> >             GUI.keep_cheat = nil
> >             GUI.draw_cheat(ctx,font,k)
> >             k = GUI.keep_cheat
> >             v.list[j] = k
> >         end
> >         GUI.keep_cheat = v
> >         return
> >     end
> > ...
> > local function draw_cheat(ctx,font,v)
> >     local prv, now, nxt, text, j, k, x, tmp, bytes, test
> >
> >     if v.desc == nil then
> >         v.desc = "???"
> >     end
> >
> >     GUI.keep_cheat = nil
> >
> >     if v.prev or v.list or v.count or v.split then
> >         GUI.draw_cheats( ctx, font, v )
> >         v = GUI.keep_cheat
> >         return
> >     end
> >
> > Though if you think the problem lies elsewhere feel free to look
> > through the source at https://github.com/awsdert/gasp, I'm just about
> > to upload the recent changes just in case you do
> 
> Never mind, I managed to fix it somehow, seems lua does not treat
> booleans as a type, had to manually check against nil, true and false
> to finally get the expected result :|

  Booleans are a type, but false and nil are the only values that are
treated as false:

Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> x = true y = false z = nil
> print(type(x),type(y),type(z))
boolean	boolean	nil
> if x then print "yes" end
yes
> if y then print "yes" end
> if z then print "yes" end

Everything else, even nan, are true:

Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> x = 0/0
> print(type(x))
number
> if x then print "yes" end
yes
> print(x)
nan
> 

  -spc