Pretty newbie scripting question, but invovles Yanfly's script so I posted here instead. What am I doing wrong?
▼ Yanfly Engine Ace - Extra Param Formulas v1.00
(also using
# This adjusts the formula for PDR. PDR is the Physical Damage Reduce Rate.
# This provided formula uses the user's flat total amount of DEF as a
# bonus contributing factor to increasing the user's PDR. If you do not
# wish to use this formula, change it to "base_pdr" to have it use
# whatever the original PDR rate is.
# :pdr_n_value => "self.def",
# :pdr_formula => "base_pdr - (n / (256.0 + n)) * 0.500 - 0.000",
:pdr_n_value => "self.xstat.Might", #this part is okay
:pdr_formula => "if n == 0 then 1 else if n==1 then 0.75 else if n==2 then 0.5 else if n==3 then 0.25",
I get an error message for the last line, saying Script '(eval)' line 6: SyntaxError occured. unexpected $end, expecting key word_end ,,,then 0.5 else if n==3 then 0.25
Putting in the word 'end' at the end of the string doesn't seem to work. What am I doing wrong?
------------
I'm using N.A.S.T.Y. Extra Stats together with ▼ Yanfly Engine Ace - Ace Status Menu v1.02. I want the to show the new stats instead of the original parameters (att, def, agi, luk, etc), of course, but that is turning out to be quite involved.
http://forums.rpgmakerweb.com/index.php?/topic/998-nasty-extra-stats/
PARAM_COLOUR ={
# ParamID => [:stat, Colour1, Colour2 ],
2 => [ :Might, Color.new(225, 100, 100), Color.new(240, 150, 150)],
3 => [ :Finesse, Color.new( 60, 180, 80), Color.new(120, 200, 120)],
4 => [ :Will, Color.new( 70, 140, 200), Color.new(135, 180, 230)],
5 => [ :mdf, Color.new(135, 130, 190), Color.new(170, 160, 220)],
6 => [ :agi, Color.new( 60, 180, 80), Color.new(120, 200, 120)],
7 => [ :luk, Color.new(255, 240, 100), Color.new(255, 250, 200)],
}
Of course, it reports atk, def and matk instead of my custom parameters of Might, Finesse and Will from Nasty's Extra stats. I'm at a loss how to insert the new stats instead. I suspect I have to edit the following line somewhere, but I'm rally not sure how:
#--------------------------------------------------------------------------
# draw_param_gauge
#--------------------------------------------------------------------------
def draw_param_gauge(param_id, dy, rate)
dw = contents.width - 48
colour1 = param_gauge1(param_id)
colour2 = param_gauge2(param_id)
draw_gauge(24, dy, dw, rate, colour1, colour2)
end
---------
This is what it looks like in NASTY extra stats
module Z26
STATS = [:Might,:Finesse,:Will]
#Default xstat formulas for ACTORS
DEFAULT_LEVEL_FORMULA =
{
:Might => 0,
:Finese => 0,
:Will => 0
}
Help with Yanfly Extra parameters
● ARCHIVED · READ-ONLY
-
-
Please also include a link to yanfly's script.
"unexpected $end" is one of the errors that is usually NOT in the line mentioned, but can be somewhere before as well - and it does not always require a $end, it can be about any code that closes a structure - it can also be a ] or ) too many.
Please post a screenshot of the error message (in these cases, even a missing space from retyping can change the meaning of the message), and check the area before your new line for other possible mistakes. -
Yanfly's extra parameters!
http://yanflychannel.wordpress.com/rmvxa/core-scripts/extra-param-formulas/
...aaaaand an image.

-
Try to use () for structuring the sequence:
Code:While adding them, I also realised that you have no default - what happens if xstat.Might is something other than 0, 1, 2 or 3?:pdr_formula => "if n == 0 then 1 else (if n==1 then 0.75 else (if n==2 then 0.5 else (if n==3 then 0.25)))", -
Your pdr formula is certainly the cause of your error:
:pdr_formula => "if n == 0 then 1 else if n==1 then 0.75 else if n==2 then 0.5 else if n==3 then 0.25",Rearrange it into multiple lines:
:pdr_formula => "if n == 0 then 1 else if n==1 then 0.75 else if n==2 then 0.5 else if n==3 then 0.25",Whereas san end is needed to end these if then else clauses and using semicolons to indicate the end of the lines may be better:
:pdr_formula => "if n == 0; then 1; else if n==1; then 0.75; else if n==2; then 0.5; else if n==3; then 0.25; end",Rearrange them into a single line:
:pdr_formula => "if n == 0; then 1; else if n == 1; then 0.75; else if n==2; then 0.5; else if n==3; then 0.25; end",I think this should solve your problem :)
Off topic: I'd prefer not using then at all and use elsif instead of else if:
:pdr_formula => "if n == 0; 1; elsif n == 1; 0.75; elsif n==2; 0.5; elsif n==3; 0.25; end",Also I'd use ternary operators instead of if then else clauses here to make things simpler, i.e.:
:pdr_formula => "n == 0 ? 1 : n == 1 ? 0.75 : n==2 ? 0.5 : n==3 ? 0.25 : value",# value is the return value to handle all the other casesYou may want to return a value in case n didn't fall into any of your values to prevent any possible crashes due to pdr being nil :)
Technically speaking, due to the implementation part of that script:
Ternary operators should be better than if then else clauses as the whole pdr formula is evaluated as a return value of pdr.Spoileralias_xparam = ["hit", "eva", "cri", "cev", "mev", "mrf", "cnt", "hrg", "mrg", "trg", "tgr", "grd", "rec", "pha", "mcr", "tcr", "pdr", "mdr", "fdr", "exr"] alias_xparam.each { |xparam| aStr = %Q( alias game_battlerbase_#{xparam}_epf #{xparam} def #{xparam} base_#{xparam} = game_battlerbase_#{xparam}_epf n = eval(YEA::XPARAM::FORMULA[:#{xparam}_n_value]) return eval(YEA::XPARAM::FORMULA[:#{xparam}_formula]) end ) module_eval(aStr) } -
Andar: Will try that as I'm curious if that will solve it as well. Got to learn!
(update: Hrm, error message again. Thank you anyway!)
DoubleX: Thank you! I was almost sure there was something wrong with the way I was writing the formula, and your thorough explanation pretty much covers all the issues. Since I'm still learning, I tried each formula you gave to see what happens.
Looks like your preference was on target. This one gives almost the same error message as before
:pdr_formula => "if n == 0; then 1; else if n == 1; then 0.75; else if n==2; then 0.5; else if n==3; then 0.25; end",
but this one works:
:pdr_formula => "if n == 0; 1; elsif n == 1; 0.75; elsif n==2; 0.5; elsif n==3; 0.25; end",
Seems like you were right about that. I'm still trying to puzzle out how to understand that bit of script you put int the spoiler."Ternary operators should be better than if then else clauses as the whole pdr formula is evaluated as a return value of pdr." -
Meanwhile, trying to fiddle with ▼ Yanfly Engine Ace - Ace Status Menu v1.02. Think I've got it, will try to use the custom status menu to display my new stats.