GameSalad

Howdy, Stranger!

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

different types of numbers

Is there a way you can make it so an a value of something can be several different types of numbers? As in lets say I wanted an attribute to be either equal to 1, 5, 20, 14, or 23. How could I do that?

Having trouble with your game? Sounds like a personal problem.

Comments

  • SocksSocks London, UK.Posts: 12,822Member
    Stick the numbers in a table and select them from that.
  • ADSentertainmentADSentertainment Posts: 397Member
    Socks said:

    Stick the numbers in a table and select them from that.

    I'm a bit new with tables, would it be possible for you to give me an example or video on how to do this?

    Having trouble with your game? Sounds like a personal problem.

  • SocksSocks London, UK.Posts: 12,822Member
    edited March 2013
    Google / Youtube: 'GameSalad tabels'

    There are a lot of videos out there . . . Start with this one:

  • ADSentertainmentADSentertainment Posts: 397Member
    edited March 2013
    Socks said:

    Google / Youtube: 'GameSalad tabels'

    There are a lot of videos out there . . . Start with this one:

    Alright, thank you! :)

    Having trouble with your game? Sounds like a personal problem.

  • ADSentertainmentADSentertainment Posts: 397Member
    edited March 2013
    Socks said:

    Google / Youtube: 'GameSalad tabels'

    There are a lot of videos out there . . . Start with this one:

    I watched the video, and I think I did what it said, but I keep getting the number zero. I'm trying to get an object to move in different directions, the angle of each direction I want is on a table. here's the code:

    tableCellValue( game.TB angles ,random(1,tableRowCount( game.TB angles )),1)

    the numbers I have in the table are:

    160
    20
    30
    40
    150
    140
    130

    all of them are in one column. Do you know what I'm doing wrong?

    Having trouble with your game? Sounds like a personal problem.

  • tatiangtatiang Posts: 11,867Member, Sous Chef, PRO, Senior Sous-Chef
    You have it set up correctly. Did you select the table name from the menu in both cases rather than typing it in?

    Can you post a screenshot of your rules?

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

  • ADSentertainmentADSentertainment Posts: 397Member
    tatiang said:

    You have it set up correctly. Did you select the table name from the menu in both cases rather than typing it in?

    Can you post a screenshot of your rules?

    I did not type it in, although I think it would be useful if you could. Here's a screenshot of what I did:

    photo ScreenShot2013-03-30at12149PM_zpsaf368178.png

    Here's a screenshot of the table in case you need to look at that too:

    photo ScreenShot2013-03-30at12655PM_zps684e4c9d.png

    Having trouble with your game? Sounds like a personal problem.

  • tatiangtatiang Posts: 11,867Member, Sous Chef, PRO, Senior Sous-Chef
    Yep, still looks right. If I had to guess I'd say that using a random number function and a row count function inside of a tableCellValue function is your problem. I know other people have said that can work, but I'd recommend (at least for debugging statements) that you separate everything out:

    Change Attribute self.Rows to tableRowCount(tableName)
    Change Attribute self.Random to random(1,self.Rows)
    Change Attribute self.Direction to tableCellValue(tableName,self.Random,1)

    Does that work?

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

  • SocksSocks London, UK.Posts: 12,822Member
    tatiang said:

    Yep, still looks right. If I had to guess I'd say that using a random number function and a row count function inside of a tableCellValue function is your problem.

    Yep, you are often better off generating the random number outside of an expression.

    So rather than:

    If X then do Y*(random 1,10)

    Try:

    Make A = (random 1,10)
    If X then do Y*(A)
  • lewisonelewisone Posts: 36Member, PRO
    tables are a great way, I might even do it dumbed up a bit and in a rule say when attribute is equal to a number , and add as many or conditions as you like to be equal to other things as well... Just a thought.
This discussion has been closed.