PlayMaker Feedback > Action Requests

int compare between [ solved ]

(1/2) > >>

allo888:
 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"

Sjones:
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:
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.

allo888:

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:
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: ---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();
}
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version