Results 1 to 5 of 5

Thread: Syntax help appreciated

  1. Default Syntax help appreciated

    I'm getting a comparison error fixnum to nil on '<' from this line

    Code:
    (CharSetting['cast_count_4'] += 1 and CharSettings['infuse_count_4'] += 1) if (130 < end_roll < 141)
    My best guess is the previous line isn't capturing the end_roll and is still using the nil value. Or my syntax is wrong because I'm not overly familiar with ruby

    Code:
    end_roll = Integer($1) if line =~ /.* \=\= \+(\d+)/i
    Help would be appreciated

  2. #2

    Default

    Have it echo the value of end_roll before the comparison to make sure the value isn't nil.

  3. Default

    It's looking like you can't use end_roll until after you have broken from the 'while line = get'

    Fortunately, I think I have found a creative way to bypass that - should have an answer soon

    edit: it seems no matter what I do - it refuses to pull the endroll properly, or allow me to use it
    Last edited by masterdtwin; 02-27-2014 at 10:06 PM.

  4. Default

    You probably shouldn't be using an inline "if" statement here. Your regex will certainly match the end roll when one appears, but you are presumably testing every line for an end roll. Obviously not every game line contains an end roll. When it doesn't, end_roll is going to be nil, and your code is going to try to use it anyway. Try something more like this:
    Code:
    if line =~ /^\s*CS.*== ([\+\-]\d+)/
    	end_roll = $1.to_i
    	(CharSetting['cast_count_4'] += 1 and CharSettings['infuse_count_4'] += 1) if (end_roll > 130) and (end_roll < 141)
    end
    For no particular reason, Integer($1) annoys me, so I changed it to $1.to_i

    I tweaked the regex to avoid matching chats (and thoughts/whispers/etc even though those are less likely), and to give you a negative number if the end roll is actually negative.

    (130 < end_roll < 141) does not do what you think it does.
    end_roll = 9001
    (130 < end_roll < 141)
    ((130 < end_roll) < 141)
    ((130 < 9001) < 141)
    ((true) < 141)
    true < 141
    true.<(141) # this line is equivalent to the previous. It's attempting to call the < method of an object with 141 as a parameter
    true.method_missing(:<, 141) # < is not defined for TrueClass
    true # method_missing is defined for TrueClass (in Lich), and it always returns true
    Get Lich - Vote for Gemstone (topmudsites.com)

  5. Default

    Okay, after a few hints from Tillmen I got things working properly

    I've made some major changes to infuseme, once I get some good stats I'll post it up

Similar Threads

  1. VBulletin Table Syntax
    By Luxelle in forum Forum Concerns and Discussion
    Replies: 10
    Last Post: 07-12-2017, 05:52 PM
  2. 950 - What is the Syntax?
    By Askip in forum Wizard
    Replies: 6
    Last Post: 09-19-2016, 08:34 PM
  3. Nitty Gritty syntax
    By Suhami in forum The Lich Project
    Replies: 3
    Last Post: 05-27-2016, 02:21 PM
  4. Help, Ideas, Anything Appreciated
    By Dayof13 in forum Warrior
    Replies: 2
    Last Post: 11-15-2011, 07:03 PM
  5. Gem Cutter Syntax
    By kgolfer in forum General Gemstone
    Replies: 1
    Last Post: 01-15-2010, 04:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •