[TIB] Re: data type issue


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

[TIB] Re: data type issue




Yes! That did it, as in-elegant as it may seem, the sub() function did the 
trick. Thankyou :]

Checking success is easy enough, inside the for loop place an if statement 
that tests if the rolled number is >= the value needed to succeed and 
increment a variable that gets displayed at the end.

Hmm.. next problem - it seems that I can only get 10 results per line 
(single digit with space inbetween) per line.. now I just need to break it 
up so I can actually see them all instead of just getting a ... and then a 
# of successes.




On Mon, 3 Feb 2003, CJ Wallace wrote:

> Well, you could always just save every roll to a list, and just display 
> the list - the OS formats the output for you. Simply:
> 
> :A->L1(B)
> 
> Where A is the number that was rolled, L1 is the list, and B is the 
> list's index. This would be the option to choose to accomlplish your 
> 'sucess checking.' Comparisons on a list are done like so:
> 
> :A>L1(B)
> :A=L1(B)
> etc.
> 
> I think you can take it from there.
> 
> But if you must have string output, it can be done. There really isn't a 
> simple way to enter numerical data into a string from a variable though. 
> Try this code [note, I'm using TI-83 tokens]:
> 
> :Str1+sub("123456",A,1)->Str1
> 
> Where A is your roll and Str1 is your string. Formatting the string is 
> an exercise left up to the reader.
> 
> -c.j.w.
> 
> Tib wrote:
> > I'm working on a die rolling program for when I play warhammer 40k and 
> > need to roll obnoxious amounts of dice all at once and count the results. 
> > Found my old TI-86 and figured it wouldn't be too hard. And it hasn't been 
> > much of a challenge up till now. Here's what I've got so far:
> > 
> > 
> > ClLCD
> > Input "# of dice? ",D
> > ClLCD
> > For(R,1,D)
> > randInt(1,6)->ROLL
> > End
> > 
> > Now this is all fine and dandy.. for rolling a bunch of dice individually. 
> > What I'd like to do is as follows:
> > 
> > ClLCD
> > " "->ALL
> > Input "# of dice? ",D
> > ClLCD
> > For(R,1,D)
> > randInt(1,6)->ROLL
> > ALL+" "+ROLL->ALL
> > End
> > Disp ALL
> > 
> > 
> > 
> > There's a little bit more to it than this, but you see my problem right 
> > now I hope.. variable ALL is going to be used to store all the die rolls 
> > so they can be output at the end in one lump rather than line by line. 
> > Unfortunately the only way I can figure to do this so far is by the method 
> > above ('ALL+" "+ROLL->ALL'), but this makes ALL a string and not an 
> > integer, and as soon as I try to add each roll onto the end it complains 
> > about data type problems. Is there a way to switch an integer into a 
> > string and then tack it onto the end? Or maybe I am going about it wrong 
> > and doing things in some sort of array format would work better (if that's 
> > possible on a TI-86.. i'm working with no programming manual right now so 
> > i've got no clue what the possibilities are). 
> > 
> > Additionally, I'd like to add the option of it checking the results of 
> > each die roll and if it's above a certain number it increments a 'success' 
> > variable. In the end, I'd like something that ouputs similar to below:
> > 
> > 40k-roller:
> > 
> > # of dice?: (input 6)
> > # to succeed?: (input 4)
> > 
> > [clears screen]
> > 
> > Rolled:
> > 2,5,3,3,6,1
> > 
> > Successes:
> > 2
> > 
> > Done.
> > 
> > 
> > 
> 
> 
> 




Follow-Ups: References: