1. Post #9881
    Gold Member
    Foxtrot200's Avatar
    August 2009
    848 Posts
    That's very clever. And I bet it runs faster than what I and some other devs whom I've been talking to have been putting together.

    I was testing this out, and it seems to match the behavior of my snippet above. I don't think I'm overlooking anything, but just so I'm not making a mistake here, your chained ternary snippet behaves or is written to behave the same way, correct?
    Pretty much. If a is nil or false, the first half of the condition is false, so it would return false. Otherwise, it has to pass the conditions in the second half in order to return true.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  2. Post #9882
    Gold Member
    Banandana's Avatar
    May 2013
    2,168 Posts
    um



    Edited:

    w0t
    Reply With Quote Edit / Delete Windows 7 United States Show Events Funny Funny x 25Agree Agree x 1 (list)

  3. Post #9883
    Quincy.'s Avatar
    January 2013
    72 Posts
    Game of Life!
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Artistic Artistic x 6Friendly Friendly x 1 (list)

  4. Post #9884
    Ott
    Gold Member
    Ott's Avatar
    June 2012
    6,627 Posts
    Game of Life!
    Make it like spore should've been
    Reply With Quote Edit / Delete Windows 8 United States Show Events Funny Funny x 10 (list)

  5. Post #9885
    Andrew McWatters
    Dennab
    March 2011
    3,878 Posts
    Pretty much. If a is nil or false, the first half of the condition is false, so it would return false. Otherwise, it has to pass the conditions in the second half in order to return true.
    Would you mind if we used that line in our base library extensions?
    Reply With Quote Edit / Delete Windows 8 United States Show Events Agree Agree x 1 (list)

  6. Post #9886
    Gold Member
    Foxtrot200's Avatar
    August 2009
    848 Posts
    Would you mind if we used that line in our base library extensions?
    Do whatever floats your boat, man!
    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 2 (list)

  7. Post #9887
    Andrew McWatters
    Dennab
    March 2011
    3,878 Posts
    Thanks! We'll credit you in the codebase.
    Reply With Quote Edit / Delete Windows 8 United States Show Events Friendly Friendly x 2 (list)

  8. Post #9888
    adnzzzzZ's Avatar
    September 2012
    1,082 Posts
    What's the problem with everything being true except false or nil, like it is by default?
    Reply With Quote Edit / Delete Windows 7 Brazil Show Events Agree Agree x 13 (list)

  9. Post #9889
    Gold Member
    Nomad's Avatar
    July 2010
    6,197 Posts
    Are mobile device emulators always shit? Tizen is running my donkey kong clone using webgl at 10 frames, while my ipod running canvas 2d (much slower then webgl) is running my game at 30 - 45 fps.

    Edit: Did I mention i'm using Intel HAXM? Wel I am and that is what the emulator gives me.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Agree Agree x 2 (list)

  10. Post #9890
    Ott
    Gold Member
    Ott's Avatar
    June 2012
    6,627 Posts
    Reply With Quote Edit / Delete Windows 8 United States Show Events Programming King Programming King x 4Funny Funny x 2 (list)

  11. Post #9891
    Gold Member
    cartman300's Avatar
    April 2011
    3,199 Posts
    Made some kind of particle system, there can be thousands on screen and you wouldn't notice lag.



    Also i got bored and did some graphs with them.
    Reply With Quote Edit / Delete Windows 8 Croatia Show Events Artistic Artistic x 1 (list)

  12. Post #9892
    Ott
    Gold Member
    Ott's Avatar
    June 2012
    6,627 Posts
    Made some kind of particle system, there can be thousands on screen and you wouldn't notice lag.



    Also i got bored and did some graphs with them.

    Thanks.
    Reply With Quote Edit / Delete Windows 8 United States Show Events Funny Funny x 10Friendly Friendly x 4Useful Useful x 1 (list)

  13. Post #9893
    Gold Member
    cartman300's Avatar
    April 2011
    3,199 Posts
    Thanks.
    What?
    Reply With Quote Edit / Delete Windows 8 Croatia Show Events Agree Agree x 1 (list)

  14. Post #9894
    Andrew McWatters
    Dennab
    March 2011
    3,878 Posts
    What's the problem with everything being true except false or nil, like it is by default?
    Simple. A datum like "false" shouldn't be interpreted as true in explicit conversions.
    Reply With Quote Edit / Delete Windows 8 United States Show Events Disagree Disagree x 2 (list)

  15. Post #9895
    adnzzzzZ's Avatar
    September 2012
    1,082 Posts
    Why would you use "false" anywhere as a string instead of the actual false?
    Reply With Quote Edit / Delete Windows 7 Brazil Show Events Agree Agree x 6Dumb Dumb x 1Funny Funny x 1 (list)

  16. Post #9896
    Gold Member
    Foxtrot200's Avatar
    August 2009
    848 Posts
    Why would you use "false" anywhere as a string instead of the actual false?
    User input/UI elements? Data formats like JSON and YAML?
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 6 (list)

  17. Post #9897
    Andrew McWatters
    Dennab
    March 2011
    3,878 Posts
    Why would you use "false" anywhere as a string instead of the actual false?
    Why would Lua's architect include tonumber() when developers could simply just use the actual number?
    Reply With Quote Edit / Delete Windows 8 United States Show Events Zing Zing x 5Optimistic Optimistic x 1 (list)

  18. Post #9898
    adnzzzzZ's Avatar
    September 2012
    1,082 Posts
    That makes an abundant amount of sense.
    Reply With Quote Edit / Delete Windows 7 Brazil Show Events

  19. Post #9899
    Andrew McWatters
    Dennab
    March 2011
    3,878 Posts
    It does! Though your logic is still very sound. It's much more difficult to interpret what should be true or false versus what is or isn't a number.

    Edited:

    Something can easily be either be a number or not a number and only a number or not a number, but something can't equally easily be true or false and only true or false.
    Reply With Quote Edit / Delete Windows 8 United States Show Events

  20. Post #9900
    Gold Member
    SamPerson123's Avatar
    September 2007
    3,730 Posts
    Oh man, had a real tough time on my assembly homework because parity isn't what I thought it was. In retrospect, it doesn't make sense for them to use a flag for something you can find out by just shifting right.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  21. Post #9901
    calzoneman's Avatar
    February 2008
    448 Posts
    User input/UI elements? Data formats like JSON and YAML?
    JSON actually allows boolean constants, not sure about YAML.

    In any case, I think it depends on what you're doing. A function called ParseBoolean() should clearly return false for the string "false", but casting (not parsing, just a typecast) "false" to a boolean should either return true because the string is nonempty, or throw an error, depending on the desired behavior.

    Having if("false") fail the condition statement is beyond even Javascript's level of "what the fuck are you doing with your type system".
    Reply With Quote Edit / Delete Linux United States Show Events Agree Agree x 7 (list)

  22. Post #9902
    Gold Member
    Foxtrot200's Avatar
    August 2009
    848 Posts
    JSON actually allows boolean constants, not sure about YAML.

    In any case, I think it depends on what you're doing. A function called ParseBoolean() should clearly return false for the string "false", but casting (not parsing, just a typecast) "false" to a boolean should either return true because the string is nonempty, or throw an error, depending on the desired behavior.

    Having if("false") fail the condition statement is beyond even Javascript's level of "what the fuck are you doing with your type system".
    While I agree, Lua doesn't really have a concept of casting (at least, not within the language itself.)
    Within the language, converting between numbers, strings, tables, and userdata is almost always a matter of parsing.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Disagree Disagree x 2 (list)

  23. Post #9903
    Source Engine Optometrist!
    Dennab
    June 2010
    2,298 Posts
    um



    Edited:

    w0t
    bahah wtf i thought that came up for me im trying to click cancel
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Funny Funny x 22 (list)

  24. Post #9904
    Gold Member

    December 2009
    1,295 Posts
    um



    Edited:

    w0t
    I had this happen. It actually did fix it for me.
    Reply With Quote Edit / Delete Windows 7 Australia Show Events Funny Funny x 6 (list)

  25. Post #9905
    Gold Member
    robmaister12's Avatar
    January 2008
    4,740 Posts
    So I just signed up for Y-Hack with a few of my friends. Will I see any other fpers there?
    Reply With Quote Edit / Delete Windows 7 United States Show Events Disagree Disagree x 2 (list)

  26. Post #9906
    King of the Oil Refinery
    Tobba's Avatar
    December 2008
    6,841 Posts
    Clever, but in Lua it's not feasible; I also need an absolute solution to all native types in Lua.
    I forgot Lua doesnt natively have a ! operator, in GLua !! works fine though
    However, this has the exact same output
    Code:
    not not v and v ~= "false" and v ~= "nil"
    Reply With Quote Edit / Delete Linux Sweden Show Events Friendly Friendly x 1 (list)

  27. Post #9907
    Dennab
    September 2013
    421 Posts
    Snipped. Um, I don't have any other content.

    Eh, I found this handy:
    http://vivekcek.wordpress.com/2009/1...y-usage-c-net/

    For getting total system RAM, this was useful
    Code:
    using Microsoft.VisualBasic;
    ...
    private static ulong GetTotalMemoryInBytes()
    {
           return new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory;
    }
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  28. Post #9908
    quincy18's Avatar
    September 2007
    1,096 Posts
    Here have some more mindfuck

    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events Artistic Artistic x 2 (list)

  29. Post #9909
    Gold Member
    Robber's Avatar
    January 2006
    6,829 Posts
    public class UnassPaymentButtAction

    I found this class name far too funny
    Reply With Quote Edit / Delete Linux Austria Show Events Funny Funny x 15 (list)

  30. Post #9910
    SupahVee's Avatar
    December 2007
    1,108 Posts
    new operation bloodshed video - new elements, multi-level sectors


    In the video:
    * Editing 32x speed timelapse
    * Playthrough of a multi-level sector
    * New elements (green/red doors, trapdoors, enemy spawners)
    * More aggressive enemies (tweaked bouncing)
    * Energy shard collection

    Devlog: http://forums.tigsource.com/index.php?topic=36131.0
    GitHub: https://github.com/SuperV1234/SSVBloodshed
    Reply With Quote Edit / Delete Linux Italy Show Events Programming King Programming King x 6Winner Winner x 4Agree Agree x 1 (list)

  31. Post #9911
    Gold Member
    Darwin226's Avatar
    January 2009
    5,177 Posts
    I'd say "false" converting to false is asking for trouble. Sooner than you know it you'll be doing 1336 + "one" - "elite" == false, and nobody needs another one of those.
    Reply With Quote Edit / Delete Croatia Show Events Funny Funny x 18Agree Agree x 4 (list)

  32. Post #9912

    August 2012
    144 Posts
    Why would Lua's architect include tonumber() when developers could simply just use the actual number?
    Because that actually makes sense. toboolean should only be written for a specific use-case. Trying to make it generic is insane.

    Also tonumber actually matches the language's handling of numbers, why the hell would you create a toboolean for which the sole purpose is to have _different_ handling than the rest of the language.
    Reply With Quote Edit / Delete Linux Australia Show Events Agree Agree x 5Artistic Artistic x 1 (list)

  33. Post #9913
    I hide under your bed
    Dennab
    July 2011
    1,906 Posts
    processing



    Reply With Quote Edit / Delete Canada Show Events Artistic Artistic x 15 (list)

  34. Post #9914
    adnzzzzZ's Avatar
    September 2012
    1,082 Posts
    Added some spikes + death. Getting death right (as in, deleting and recreating everything again properly) was hard for me in my last game, so I decided to get it done early now!

    Reply With Quote Edit / Delete Windows 7 Brazil Show Events Artistic x 15Winner x 2Programming King x 1Optimistic x 1Friendly x 1 (list)

  35. Post #9915
    Gold Member
    Darwin226's Avatar
    January 2009
    5,177 Posts
    Because that actually makes sense. toboolean should only be written for a specific use-case. Trying to make it generic is insane.

    Also tonumber actually matches the language's handling of numbers, why the hell would you create a toboolean for which the sole purpose is to have _different_ handling than the rest of the language.
    Adding to that, conversion and parsing are different things. "false" and "true" can be parsed to boolean with their corresponding values as the results. Anything other to that should be and exception anyways. When casting/converting, if you insist on string being castable to bool, everything but "" and null should be true. Including "false"
    Reply With Quote Edit / Delete Croatia Show Events Agree Agree x 6 (list)

  36. Post #9916
    Vietnow's Avatar
    February 2011
    854 Posts
    Reply With Quote Edit / Delete Windows 8 United Kingdom Show Events Funny Funny x 10Agree Agree x 1 (list)

  37. Post #9917
    Gold Member
    HubmaN's Avatar
    July 2007
    5,927 Posts
    Are mobile device emulators always shit? Tizen is running my donkey kong clone using webgl at 10 frames, while my ipod running canvas 2d (much slower then webgl) is running my game at 30 - 45 fps.

    Edit: Did I mention i'm using Intel HAXM? Wel I am and that is what the emulator gives me.
    Apple's done some library-fu to make the iOS simulator essentially just a hot code-loader that plugs within the same process as the simulator's chrome itself - which is yet another reason, mind you, why they wag their fingers at any use of a non-exposed function.
    Reply With Quote Edit / Delete Windows 8 Thailand Show Events Informative Informative x 1 (list)

  38. Post #9918
    Andrew McWatters
    Dennab
    March 2011
    3,878 Posts
    Because that actually makes sense. toboolean should only be written for a specific use-case. Trying to make it generic is insane.

    Also tonumber actually matches the language's handling of numbers, why the hell would you create a toboolean for which the sole purpose is to have _different_ handling than the rest of the language.
    okay that's cool
    Reply With Quote Edit / Delete Windows 8 United States Show Events Useful Useful x 1 (list)

  39. Post #9919
    Gold Member
    BlkDucky's Avatar
    May 2008
    6,162 Posts
    I still don't see why you'd ever need a toboolean. Is this really such a common enough issue to make a generic function for?

    Edited:

    I'm just a scrub programmer and all but seriously why
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 6 (list)

  40. Post #9920

    January 2011
    495 Posts
    So I've been working on a library called SharpNav for RCOS, a form of undergraduate research here that gives you either course credit or a stipend for working on open source software. You can also propose your own open source project to work on. The kicker is that you get to keep the copyright for the work you've done, it doesn't belong to the school.

    We have to give at least 2 presentations per semester, I'm giving my first this Tuesday. So far I can conservatively voxelize a level and convert it to open spans, I'm hoping I can get regions generated reliably by then.

    Here's a screenshot of the voxelized world:



    Also, I've got my powerpoint ready if anyone wants to take a look at them: http://slid.es/robertrouhani/sharpnav-10-8-13

    I go over the algorithm at a very high level in there (and slid.es is a really cool website!)
    the slides made me sea sick.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)