playMaker

Author Topic: int compare between [ solved ]  (Read 5174 times)

allo888

  • Playmaker Newbie
  • *
  • Posts: 24
int compare between [ solved ]
« on: November 01, 2012, 04:00:08 PM »
 i need an action that is basically the int compare action but i need it to compare  between 2 numbers so e.g 1 to 10 and if the numbers between them is  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, it will send an event  


my example first 1 is the vairable second is the first number and third one is the 2nd number
"not real photo"
« Last Edit: November 02, 2012, 08:22:22 AM by allo888 »

Sjones

  • Full Member
  • ***
  • Posts: 203
Re: int compare between
« Reply #1 on: November 01, 2012, 04:35:04 PM »
have 2 int compares, make one go to the second, so if its more than number 1, send to the next and compare and see if its less than number 2, if its more than 1 and less than 2 then do nothing (or send back to the beginning etc.

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: int compare between
« Reply #2 on: November 01, 2012, 04:37:54 PM »
You can compose that with some (I guess 2 will do) Int Compare actions, although it might be useful using a custom range function. I'm quite busy for now, I'll try to get it quickly, but if someone else does it before, this shouldn't be that difficult.

Greetings.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

allo888

  • Playmaker Newbie
  • *
  • Posts: 24
Re: int compare between
« Reply #3 on: November 01, 2012, 04:57:09 PM »

i use interge 1 as the vairable and interge 2 and number

 Sjones i have a big fsm full of numbers being compaired in the same state so i cant realy do that becouse it will get confusing

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: int compare between [still need help ]
« Reply #4 on: November 01, 2012, 05:58:28 PM »
This is it. Guess it still lacks of error checks and such, but you should be able to do whatever you intend to with this. Just remember to have the value 1 be lesser than value 2

Code: [Select]
using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;

[ActionCategory(ActionCategory.Math)]
[Tooltip("Compares if a given int value is in a range of values")]

public class IntRangedCompare : FsmStateAction {

[Tooltip("Number to search in range")]
public FsmInt valueToCompare;

[Tooltip("Range min value")]
public FsmInt rangeValue1;

[Tooltip("Range max value")]
public FsmInt rangeValue2;

public FsmEvent valueInRangeEvent;
public FsmEvent valueOutOfRangeEvent;

public override void OnEnter(){

if(rangeValue1.Value > rangeValue2.Value){
LogError("Lower range value can't be greater than upper range value");
}

else{

if(rangeValue1.Value <= valueToCompare.Value && valueToCompare.Value <= rangeValue2.Value){
Debug.Log("Number in range");
Fsm.Event(valueInRangeEvent);
}

else{
Debug.Log("Number out of range");
Fsm.Event(valueOutOfRangeEvent);
}
}

Finish();
}
}
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

allo888

  • Playmaker Newbie
  • *
  • Posts: 24
Re: int compare between [ solved ]
« Reply #5 on: November 02, 2012, 08:23:30 AM »
thank you so mutch this works fine and is amazing thanks  ;D ;D ;D ;D