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?
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:
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:
Here's a screenshot of the table in case you need to look at that too:
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
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)
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.
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.
Comments
There are a lot of videos out there . . . Start with this one:
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?
Can you post a screenshot of your rules?
Here's a screenshot of the table in case you need to look at that too:
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?
So rather than:
If X then do Y*(random 1,10)
Try:
Make A = (random 1,10)
If X then do Y*(A)