Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

  • 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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.