GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Toggle a boolean value, using one Rule and one Change Attribute

Comments

  • BonepileGamesBonepileGames Posts: 194Member

    Great. I need to make one thing different from your tutorial - instead of when touch is clicked, when game.attribute%2=0. However, I do not know how to type game.attribute%2 in the first blank space (left one) in the expression editor or any other way.

  • tatiangtatiang Posts: 11,834Member, Sous Chef, PRO, Senior Sous-Chef
    edited September 2014

    @BonepileGames‌

    On the left side of the rule, instead of selecting attribute, select numeric expression.

    You can then use the expression editor on the left side of the rule. Note that the "%" symbol is being phased out and it's recommended that you use mod(game.attribute,2)=0 instead.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Posts: 12,822Member
    edited September 2014

    Another useful toggle switch is to have an integer attribute (set at its default 0) - let's call it 'switch' - and to use it like this:

    When touch is pressed: change switch to 1-switch

  • BonepileGamesBonepileGames Posts: 194Member

    @tatiang‌

    Thank you for your response. However, is that available in Gamesalad Windows Creator since I am using Windows-based laptop right now, my lovely MacBook broke :neutral_face:

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member

    I'd like to know where he found out the not could be used in an expression? Is this a LUA command?

  • ArmellineArmelline Posts: 4,771Member, PRO
    edited September 2014

    @The_Gamesalad_Guru said:
    I'd like to know where he found out the not could be used in an expression? Is this a LUA command?

    I've seen @tatiang mention it before, but I think it's just one of those things that people discover by experimentation. I know I tried a whole bunch of other potential functions without any success.

    I'd say you're right about it being because of the LUA roots though. It would also explain why you can do things like have a rule that says 10==10 = 1.

    Another thing I've not seen mentioned before that works is ^. Try 10^5 and see what result gets outputted.

    Would love to see access added for character classes (e.g. %a) to beef up the string functions. Just adding access to the classes built in to LUA would ramp up the power of GameSalad's string manipulation significantly. @dgackey @CodeWizard

    It's also worth noting that the expression editor doesn't give you "real" access to the LUA underpinnings, so you can't do things like string.lower("AAAA") or string.reverse("ABCD"), sadly. It also seems the expression editor doesn't hook directly into the C numerical library, as we don't have things like cbrt(x) or isinf(x). It seems the GS team pick what gets allowed but don't always tell us :D

  • RThurmanRThurman Posts: 2,824Member, Sous Chef, PRO

    @The_Gamesalad_Guru said:
    I'd like to know where he found out the not could be used in an expression? Is this a LUA command?

    If you are referring to the % operator, CodeMonkey mentioned it here:

    http://forums.gamesalad.com/discussion/comment/412742/#Comment_412742

  • jeezzcakejeezzcake Posts: 144Member

    @The_Gamesalad_Guru‌: I just typed it in to see if it works. And it did. Later i found out that this is a LUA function. That's the little story of "not".

  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,913Member

    Lol @Rthurman i just did a video on that. No i was talking about using "NOT" as part of an expression. Yeah @Armelline‌ I tried a bunch of stuff from the lua libary to no avail.

  • tatiangtatiang Posts: 11,834Member, Sous Chef, PRO, Senior Sous-Chef
    edited September 2014

    @BonepileGames said:
    tatiang‌

    Thank you for your response. However, is that available in Gamesalad Windows Creator since I am using Windows-based laptop right now, my lovely MacBook broke :neutral_face:

    @BonepileGames‌ I'm not terribly versed in Windows Creator (hoping to get VMWare running really soon though) and I assumed since this was in the Mac subforum that you were using Mac Creator. One thing you can do if there isn't a numerical expression choice is to create a constant by making a custom attribute game.ZERO equal to 0. Then make the rule If attribute game.ZERO = mod(game.attribute,2) then ... [behaviors]

    It's just flipping the equation around so it still works the same.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Posts: 2,824Member, Sous Chef, PRO
    edited September 2014

    @The_Gamesalad_Guru said:
    Lol Rthurman i just did a video on that. No i was talking about using "NOT" as part of an expression.

    I believe it was @Orbz who introduced the idea of negating booleans (and the idea of using Boolean logic in the expression editor). That was back in the "Timers Are For Chumps" thread.

This discussion has been closed.