The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.10 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Check if 4 local int variables all carry different values?
HappyMatt12345 Offline
Junior Member

Posts: 16
Threads: 6
Joined: Oct 2018
Reputation: 0
#1
Check if 4 local int variables all carry different values?

Well here I am again, yet again trying to make a puzzle and having troubles getting the script to do what I want it to. Basically, I'm attempting to make a puzzle where the player needs to put rocks on a pressure plate, and it was working until I had the bright idea to try to make the combination randomly generate when the map is loaded. I have tried everything I can think of, and I have everything working except when I try to leave it as it was when it was not giving me errors, it was entirely up to luck whether or not the code would be all different numbers(which is what I want as the player needs to leave 4 rocks on separate pressure plates) or a few numbers being the same. My thought here was to run it on a boolean that would return true if all numbers were unequal to any other. this is where I have been stuck for the last hour or so, and I have decided I'm tired of it so I'm posting here. I will copy NOT the entire code file, but all code that is involved in this particular puzzle, into a code block thing, take a look: 


void OnStart(){
    SetLocalVarInt("Area1Num", RandInt(1, 9));
    SetLocalVarInt("Area2Num", RandInt(1, 9));
    SetLocalVarInt("Area3Num", RandInt(1, 9));
    SetLocalVarInt("Area4Num", RandInt(1, 9));

       SetRockComboPuzzleActive();
}

void SetRockComboPuzzleActive(){
    if(CheckAreaValues() == true){
        SetLocalVarString("Area1", "CodeRockPlaceArea_"+GetLocalVarInt("Area1Num"));
        SetLocalVarString("Area2", "CodeRockPlaceArea_"+GetLocalVarInt("Area2Num"));
        SetLocalVarString("Area3", "CodeRockPlaceArea_"+GetLocalVarInt("Area3Num"));
        SetLocalVarString("Area4", "CodeRockPlaceArea_"+GetLocalVarInt("Area4Num"));
        AddDebugMessage("Combo is "+GetLocalVarInt("Area1Num")+", "+GetLocalVarInt("Area2Num")+", "+GetLocalVarInt("Area3Num")+", "+GetLocalVarInt("Area4Num"), false);
        for(int i = 1; i <= 4; i++){
            AddEntityCollideCallback("CodeRock1", GetLocalVarString("Area"+i), "PlaceRock", false, 0);
            AddEntityCollideCallback("CodeRock2", GetLocalVarString("Area"+i), "PlaceRock", false, 0);
            AddEntityCollideCallback("CodeRock3", GetLocalVarString("Area"+i), "PlaceRock", false, 0);
            AddEntityCollideCallback("CodeRock4", GetLocalVarString("Area"+i), "PlaceRock", false, 0);
        }
    }
    else{
        ResetAreaValues();
    }
}

bool CheckAreaValues(){
    // Im completely at a loss as to what to put here, as everything I have tried either creates an error or simply doesnt function as I want it to.
}

void ResetAreaValues(){
    SetLocalVarInt("Area1Num", RandInt(1, 9));
    SetLocalVarInt("Area2Num", RandInt(1, 9));
    SetLocalVarInt("Area3Num", RandInt(1, 9));
    SetLocalVarInt("Area4Num", RandInt(1, 9));
    if(CheckAreaValues() == true){
        SetRockComboPuzzleActive();
    }
}

void PlaceRock(string &in asParent, string &in asChild, int alState){
    if(alState == 1){
        for(int i = 1; i <= 4; i++){
            if(asChild == GetLocalVarString("Area"+i) && GetLocalVarBool("A"+i+"Occ") == false){
                SetLocalVarString("A"+i+"OccBy", asParent);
                SetLocalVarBool("A"+i+"Occ", true);
                AddLocalVarInt("RocksPlaced", 1);
                AddDebugMessage("LocalVarString 'A"+i+"OccBy' has been updated to "+GetLocalVarString("A"+i+"OccBy"), false);
                AddDebugMessage("LocalVarBool 'A"+i+"Occ' has been updated to "+GetLocalVarBool("A"+i+"Occ"), false);
                AddDebugMessage("LocalVarInt 'RocksPlaced' has been updated to "+GetLocalVarInt("RocksPlaced"), false);
            }
        }
    }
    else{
        for(int i = 1; i <= 4; i++){
            if(asChild == GetLocalVarString("Area"+i) && asParent == GetLocalVarString("A"+i+"OccBy")){
                SetLocalVarString("A"+i+"OccBy", "CurrentlyUnassigned");
                SetLocalVarBool("A"+i+"Occ", false);
                AddLocalVarInt("RocksPlaced", -1);
                AddDebugMessage("LocalVarString 'A"+i+"OccBy' has been updated to "+GetLocalVarString("A"+i+"OccBy"), false);
                AddDebugMessage("LocalVarBool 'A"+i+"Occ' has been updated to "+GetLocalVarBool("A"+i+"Occ"), false);
                AddDebugMessage("LocalVarInt 'RocksPlaced' has been updated to "+GetLocalVarInt("RocksPlaced"), false);
            }
        }
    }
}
 
Help is much appreciated as I have tried a bunch of things... Thank you...

Developer of Order of the Skull
11-19-2018, 07:17 PM
Find


Messages In This Thread
Check if 4 local int variables all carry different values? - by HappyMatt12345 - 11-19-2018, 07:17 PM



Users browsing this thread: 1 Guest(s)