#Lua Summation for BlackATM

1 messages · Page 1 of 1 (latest)

prisma solar
#

@celest badger

celest badger
#

ahoy hoy

prisma solar
#

so, here

#

this shows the sort of operation you're wanting to do

rugged hamlet
#

I mean the thing eremel sent works just fine

prisma solar
#

Presumably yes

#

but I couldn't read straight in there

#

too many topics at once

rugged hamlet
#

Unless the summation changes it's function at least

#

As long as it's always 1+2+3+...+x then (x/2)(x+1) is always right

prisma solar
#

anyway, I thought the post might be helpful for understanding the procedure, but I'm picky about actually understanding what I'm doing before I do it

abstract raven
#

there's always a simple calculation for linearly increasing sequences

celest badger
#

i was looking into how to use that, i presumed it was something like card.ability.extra.final_value = (card.ability.extra.chips/2) * (card.ability.extra.chips+1)

prisma solar
#

(autism ™️)

celest badger
#

mood af

abstract raven
#

you need the multiply symbol

prisma solar
#

So, if you want 1+2+3+4= 10, you can also use the equation

#

( N x ( N + 1 )) / 2

#

which, again, someone already probably posted.

celest badger
#

probably 😭

prisma solar
#

but if you don't need to iterate over every chip taken, this is the way to do it imo

#

iterating over 400 chips every time you score a hand sounds like hell

celest badger
#

it does, i would go and make it an actual scoring type but i had trouble with this 😭

#

thank you all for your help though mwah

#

i do need to learn loops, like badly

abstract raven
#

please never use a loop to do a summation of a linear sequence

celest badger
#

yeah no,, that sounds like a massive performance hit

prisma solar
#

the above formula will let you quickly do it, so you'd just sub in Chips for N and then reset chips to 0 afterwards I think.

celest badger
#

oh i dont even need to reset it, it works perfectly fine