Psi

Psi

45M Downloads

[Feature Request] Booleans/Conditions

eslachance opened this issue ยท 8 comments

commented

Loopcast spells currently run non-stop and unless I'm gravely failing at math, I don't know of any way to trigger it every X cast. I was thinking of using Modulo to set the power of a spell, but since that gives the remainder, it doesn't help that much - 0 1 2 3 4 as a power is kind of awkward.

Having a way to condition things with booleans (tricks especially) or to control number values using a boolean expression (Operator: Equal ?) would be awesome. No more loopcast suicide!

commented

Most trick powers require a number constant.

commented

modulo and then integer division might be what you want, say you want to run it every 5th step
(1 mod 5) / 4 = 0
(4 mod 5) / 4 = 1
(5 mod 5) / 4 = 0
(6 mod 5) / 4 = 0
etc
(fixed because apparently i do not understand 10th grade math)

Also motion to not make tricks require constants
Or maybe have a piece that doesn't pass further down it's path if it doesn't receive a number > 0 or another type != null?
(I don't actually know how spells evaluate in this)

commented

tricks need constants because that's how cost is determined

commented

yeah but tricks have other inputs apart from the constant. There's probably very hacky ways to make conditionals work.
Also some tricks take a constant max for cost determination and a variable parameter for level of actual performance.

commented

It's totally doable. I've found a few "hacky" ways to do conditionals, but the easiest way is one you're already on track for. After using modulo to make the value 1 only when you want it to run, put the result through an inverse function. 1^-1 is 1, but 0^-1 is a divide by zero error. Then just feed that inverse function into the spell somewhere to crash it. The easiest way is just to multiply something by it, like a vector or other number that the spell uses. The error will follow down the line to the trick, and crash the spell.

As an added bonus, you can crash one trick in a spell, while making another trick still work. The spell compiler reads left to right, top to bottom, so as long as the trick you're crashing comes after the trick you want to work, the spell will cast the first part.

If you want to see an example of some of this stuff in action, check out my flight spell on /r/psispellcompendium. [link]

commented

Booleans and conditionals are not in the plans, as I don't want to make Psi a fully fledged "visual programming" system, but rather a simple sequence of actions. What I have in mind is a "Trick: Die" of sorts, which will take a Number parameter and stop the spell execution if it's between 0 and 1 (exclusive).

If that sounds finicky, that's because it is. I like throwing wrenches into your plans.

commented

image

commented

this is not flow control, it's just flow stoppage