Complete Math-Rework

Exportforce

  • *
  • Posts: 90
Hello,

as already as a minor suggestion I suggested to exchange math.round, math.floor and math.ceil with their floating alternatives, as stencyl else kills the float to an integer. Also on other parts of the math engine there are lots of functions that reset the float to an integer, which is very bad.

Also it is an extreme pain to do math with stencyl.
For example, I wanted to do a very simple: (X*Y)^Z but with the given possibilities that is totally not doable, at least not as simple as it could be. So I had to break it up and first save X*Y in a variable and than pow that in a second function. For such a short thing it is... okayish... but if I have bigger things where I need to do my math on, which will come soon (I fear that moment) this will get a real serious problem.

Alternatively make an "Advanced" Mathmode where you click yourself a custom code-box together.
Meaning I have all my variables at hand and a calculator and click everything as I need it and the editor puts that one after another into the codebox. So I could for example click
Variable1 + Variable2 +(5*Variable3)^5
And the automated codeblock reads

setValueForScene("SceneEvents_0", "_value1") + setValueForScene("SceneEvents_0", "_value2") + pow(( 5*Engine.engine.getGameAttribute("value3")),5);

Also we need definitly a possibility to select positions after a comma. Like 5.9999995 gets rounded to 5.99 instead of 6

Thank you !

merrak

  • *
  • Posts: 2423
Are you talking about running something like the shunting-yard algorithm at compile time or at run-time? If you need the latter's functionality right now, I can send you an extension.

As for the former, couldn't you just use a custom code block with the variable internal names? I don't think you need setValueForScene, etc.

Code: [Select]
_value1 + _value2 + 5 * Math.pow(_value3,5)

Exportforce

  • *
  • Posts: 90
Well, sure... But if we have such a nice tool, why only use a minimum of possible capacity ?

About algorythm stuff. I don't know stuff is called, I just need to do a lot of math for my upcoming Idle-, Clicker- and RPG Games and just a simple thing like x*y^z already to be needed to be in seperate steps is bad...
And well... as said, a custom codebuilder for math as in my example would be a veeeery nice thing too, and definitly, at least for the devs, not that hard to do.

About custom extensions, I wish I knew how I could do small simple blocks like math.fround as new block next to the standard math.round block etc.

letmethink

  • *
  • Posts: 2547
Mind me askinghow you came to the conclusion it needed to be in separate steps?
~Letmethink

Justin

  • *
  • Posts: 4310
Quote
About custom extensions, I wish I knew how I could do small simple blocks like math.fround as new block next to the standard math.round block etc.
Pretty simple.

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<blocks>

<block
tag="float-round"
spec="fround %0"
code='Math.fround(~)'
type="normal"
color="green"
returns="number">
<fields>
<number order="0"></number>
</fields>
</block>

</blocks>

You can find a nice extensive guide on the blocks.xml file here.

For Live Support: Join our discord server and ping me @justin.
I'm most often available between 8am and midnight Japan time. (GMT+9)

Exportforce

  • *
  • Posts: 90
Mind me askinghow you came to the conclusion it needed to be in separate steps?
This does not work. I tested with a pal together. This gives... weird results.

@Justin
That seems pretty simple gonna try that, thanks !

Exportforce

  • *
  • Posts: 90
I did create a new extension and tried to activate it but it won't let me. As a test I tried to activate ANY other extension, but not one will be active after reloading the game. They turn off themself.

Justin

  • *
  • Posts: 4310
Are you saving the game after enabling the extension or do you just close and reload?

For Live Support: Join our discord server and ping me @justin.
I'm most often available between 8am and midnight Japan time. (GMT+9)

Exportforce

  • *
  • Posts: 90
Are you saving the game after enabling the extension or do you just close and reload?
Just closing it, as the tool says but from the question I think I'll try with saving the game first ^^

edit: Yup now it's activated, but can't find my new block.
Can I send you my test extension so you can tell me if I did something wrong ?

Justin

  • *
  • Posts: 4310

For Live Support: Join our discord server and ping me @justin.
I'm most often available between 8am and midnight Japan time. (GMT+9)