Skip to content

Counters

MacMonkeyMacMonkey Member Posts: 6
Good evening/morning,
Coding Question - Is there a way to code in a counter?
For example, if I have a global variable "NumTimeTalk" with an initial value of 0, is there a way code so that each time the NPC is talked to the counter will advance? (Basically, I want n=n+1.)
(I apologize if this is mentioned elsewhere.)
MM

Comments

  • GrammarsaladGrammarsalad Member Posts: 2,582
    You want IncrementGlobal(S:Name*,S:Area*,I:Value*) my friend!

    Here is an example given in iesdp:
    IF
    See([EVILCUTOFF]
    !Specifics(LastSeenBy(),4000)
    !Inparty(LastSeenBy())
    !Allegiance(LastSeenBy([GOODCUTOFF])
    THEN
    RESPONSE #100
    ChangeSpecifics(LastSeenBy(),4000)
    IncrementGlobal("KR_MONSTER_COUNTER_ALIVE","GLOBAL",1)
    END
    http://gibberlings3.net/iesdp/scripting/actions/bgeeactions.htm
  • GrammarsaladGrammarsalad Member Posts: 2,582
    Here is the description:

    109 IncrementGlobal(S:Name*,S:Area*,I:Value*)
    This action alters the specified variable, in the specified scope, by the amount indicated. The amount can be positive or negative. Variables in the local scope cannot be changed with this action
  • MacMonkeyMacMonkey Member Posts: 6
    Thank you very much!

    Another question: Would the following code work?
    (I am sorry if it is just a mess...Although, I hope it isn't.)

    IF ~ Global ("M2NPCMeet", "GLOBAL", 0) ~ THEN BEGIN FirstIntro
    SAY ~Hi~
    IncrementGlobal ("M2NPCMeet", "GLOBAL", 1)
    ++ ~Hello~ Do ~ JoinParty () ~
    ++ ~Goodbye ~ EXIT
    END
    IF ~ Global ("M2NPCMeet", "GLOBAL", 1,5) ~ THEN BEGIN SecIntro //not sure how to write a range...
    SAY ~Hello Again~
    IncrementGlobal ("M2NPCMeet", "GLOBAL", 1)
    ++ ~Hello. Now come with me.~ Do ~ JoinParty () ~
    ++ ~Goodbye Still ~ EXIT
    END
    IF ~ Global ("M2NPCMeet", "GLOBAL", 6) ~ THEN BEGIN LastIntro
    SAY ~Nope, you had your chance!~ EXIT
    END

    Thank you again for your help.

    MM
  • GrammarsaladGrammarsalad Member Posts: 2,582
    edited March 2016
    I do it the 'old way' but that looks pretty good eyeing it.

    For the second block, you can start with this:

    ...GlobalLT("M2NPCMeet", "GLOBAL", 6) ...
    Yes, a value of 0 is less than 6.

    But. It will only fire if the first one doesn't fire. So, you effectively get your 1-5 range

  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    You want IncrementGlobal(S:Name*,S:Area*,I:Value*) my friend!

    Here is an example given in iesdp:
    IF
    See([EVILCUTOFF]
    !Specifics(LastSeenBy(),4000)
    !Inparty(LastSeenBy())
    !Allegiance(LastSeenBy([GOODCUTOFF])
    THEN
    RESPONSE #100
    ChangeSpecifics(LastSeenBy(),4000)
    IncrementGlobal("KR_MONSTER_COUNTER_ALIVE","GLOBAL",1)
    END
    http://gibberlings3.net/iesdp/scripting/actions/bgeeactions.htm

    Huh, iesdp is slightly wrong then. Specific can only be a byte (0-255).
  • MacMonkeyMacMonkey Member Posts: 6
    Great! Thank you so very much for your help!

    MM
Sign In or Register to comment.