Posted April 2, 201411 yr How would I create an arithmetic sequence (fn = fn-1 + f) and implement it? To explain more fully. I'm wanting an item to do something ever 10,000 ticks. I can make it do something at 10,000 and I can make it do it every number after that by manually entering the numbers in, but doing that for an infinite amount of time would... well... be impossible. So, is there a way for me to use a fn = fn-1 + f sequence and then tell my if statement that if the ticks equal anything in that sequence then it should proceed? I thought about for statements and arrays but I can't work out how it would work. Any help?
April 2, 201411 yr Author What if you can't reset the counter? I thought about doing it that way but the tick counter is needed for other things as well, so resetting it would screw that up.
April 2, 201411 yr Do you just want to do something "every 10,000 ticks". To do something every 10,000 ticks you just need a variable that is incremented every tick and then just check if it is evenly divisible by 10,000 (or whatever number you want). Most programming languages have a "modululs" operator, sometimes called the "remainder" operator. It tells you if something is evenly divisible if the remainder = 0. In Java this operator uses the percent sign "%". You can find out more here: http://www.cafeaulait.org/course/week2/15.html So if you had an int variable called tick_count, you would know you're on a 10,000 x n tick with something like the following logical expression: if (tick_count % 10000 == 0) { // do your stuff here } Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.