YesNoOk
avatar

need help understanding coding language to apply ideas (Read 5020 times)

Started by txcrvnt, September 27, 2022, 07:02:28 pm
Share this topic:
need help understanding coding language to apply ideas
#1  September 27, 2022, 07:02:28 pm
    • Brazil
hi there.

i'm making a homing projectile and i can't figure out what is going on.

what does time%2 mean? if i use it as a trigger, are there any differences in these following examples?

Code:
trigger1 = time%2
trigger1 = time%2 = 0

another question: my sprpriority code is not working as intended. i used a ifelse + time <= 30 combo to change sprpriorities from action to helper spawning, but it does not seem to change at all.

Code:
sprpriority = ifelse(time <= 30,-10,10)
Re: need help understanding coding language to apply ideas
#2  September 28, 2022, 06:36:14 am
  • *****
  • Shame on you!
    • USA
the %2 =0 basically means if the time ends in an even number, activate.
%2 is going to do the exact same thing. It divides by the number, and if it comes out without a remainder, activate. If you put %2 = 1 then it would fire off ever odd number.
  %3 = 0 is any number divisible by 3, %3 = 1 is divisible by 3 plus one, so 4, 34 and 61 would be 3 of the infinite numbers to fire off. %3 = 3 would never happen.
 %4 = 2 would fire off at 6, 10, 14, 18, 22, on and on.

    sprpriority = ifelse(time <= 30,-10,10)
should probably be
    P1sprpriority = ifelse(time <= 30,-10,10)
But if you ever come across something in the hitdef that just isn't "doing the math" then create a var to do the math before the hitdef activates and it should work then.
You can use FF3 to find out all the old code you're using. It'll let you know that sprpriority is out dated and take you to each time you've used it.
vVv Ryuko718 Updated 10/31/22 vVv
Re: need help understanding coding language to apply ideas
#3  September 28, 2022, 07:05:51 pm
    • Brazil
thank you so much! I've corrected the sprite priority and understood greatly this time% thing.

I'll create another topic in a few days with more questions about this project. My homing projectile is not that smooth when changing directions, but I think this is something related to velset versus veladd. However, nice to know I've got a place to solve my problems! <3