Q Repeat: Math formula from ini?

New releases and general discussions.

Post » Wed Oct 27, 2010 10:57 pm

I've asked this before, and just wondering if anyone had any new ideas, what with python and all: Is there a way I can have a math formula (For damage let's say) in a ini (That contains equipment) and use that in the game?

If not straight through Construct how about python? (Which I know nothing about)

Thanks for all.
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Wed Oct 27, 2010 11:44 pm

Yes, you can do this pretty easily with Python.

Basically you have a formula like 5+5 in your INI string. Then you just set the value of anything to Python(YourFormulaString).

With this you could also have formulas like DMG*3 and then run Python(replace(YourFormulaString,"DMG",object('damage')))

Or if you have multiple variables you'd want to use, you should probably have a list that you loop through that knows where to check for the values or stores the necessary values.
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Thu Oct 28, 2010 12:41 am

Hmm... I must be doing something wrong...

I put Python(INI.ItemString("1", "Formula")) as the expression of Set Text, but the text is just blank

What am I doing wrong?
P.S. Thanks!
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Thu Oct 28, 2010 12:42 am

he's right, and just because I wasn't sure exactly what he meant,
a simple example is:

set sprite private variable ('MyFormula') to string : "(sprite.x/100) + sprite.angle"

Set Sprite Angle : 10 * python(('MyFormula')) + sprite.y
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu Oct 28, 2010 1:23 pm

I'm sorry, But I've even tried Set GlobalValue to Python(2+2) and I still can't get it to work.

WHat am I doing wrong? Do I need to enable python?

Thanks
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Thu Oct 28, 2010 1:25 pm

I found it.I found "Enable Scripting"

Thanks!
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Thu Oct 28, 2010 2:37 pm

Also it'd be python("2+2")

Don't forget the quotation marks around the entire python expression
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu Oct 28, 2010 2:45 pm

Awesome! Thanks.
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 1 guest