Barathrums Scripting Problems

Post Reply
Barathrum
Posts: 2
Joined: Thu Sep 13, 2012 12:16 am

Barathrums Scripting Problems

Post by Barathrum »

Vauge subject I know. But I've been in the process of building a system for Midkemia Online for ages now. And have come up against a few things that I can't do and will use this one thread for all of them to save spamming threads.

Todays challenge is working out how to get ' y = 7E-08x3 - 1E-05x2 - 0.0045x + 2.5223 ' incorporated into a script.
I want to work out how to put an 'x' value into it to give me a 'y' value. And then if theres any clever math people about I'd love the reversed formula ( 'y = longformula' ) as its been years since I've done Algebra and it slips my mind ;) .

Thanks in advance everyone who reads/helps!

Barathrum
Posts: 2
Joined: Thu Sep 13, 2012 12:16 am

Re: Barathrums Scripting Problems

Post by Barathrum »

Ok think I've worked most of it out. My current problem is making the formula capable of running multiple variables through it. EG
Y = math.exp(7-08*X^3) - math.exp(1-05*X^2) - 0.0045*X+2.5223
X = 70, therefore Y = math.exp(7-08*70^3) - math.exp(1-05*70^2) - 0.0045*70+2.5223
X = 110, therefore Y = math.exp(7-08*110^3) - math.exp(1-05*110^2) - 0.0045*110+2.5223
X = 200, therefore Y = math.exp(7-08*200^3) - math.exp(1-05*200^2) - 0.0045*200+2.5223

How can I put that formula in a table, and run it with a random variable with a function.
When I put the formula in a table ' math.exp(7-08*bara.speed^3) - math.exp(1-05*bara.speed^2) - 0.0045*bara.speed+2.5223 ' it saves that 'bara.speed' variable into the table so when bara.speed changes, it doesn't change the value in the table.

Anyone know a way around this?

EDITED: Ok so the table works out all the formulas the moment its saved, so the table doesn't actually contain the formula, it instead contains the answers to the formulas. I'm playing around with storing it as a string instead, but can't work out how to change it back afterwards. Any thoughts?

Lezard
Posts: 36
Joined: Wed Aug 29, 2012 6:47 pm

Re: Barathrums Scripting Problems

Post by Lezard »

This should be in the Help Forum. Perhaps you'll get more help if you post there.

Post Reply