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]Variable not declared
Yare Offline
Junior Member

Posts: 22
Threads: 2
Joined: Mar 2013
Reputation: 0
#1
[SCRIPT]Variable not declared

Really weird issue... I hope it's not my derp moment again. In the second map of my Custom Story, I got an error informing, that a certain variable is not declared. I had no clue what's wrong, so I opened hps file of another level I made a few days ago, as it contains a function similar to the one I was just going to make. I was comparing these two functions with eachother for minutes... and couldn't see a difference. I decided to change starting map to see if that previous script still works. And here the weird part begins. It doesn't work! And displays the same error! How in the hell is that possible? It used to work properly just a few days ago! I didn't change anything in that file during this time.
Maybe someone has a clue what the heck is going on. Here are necessary parts of the script (that one from the first map):

Callback:

AddEntityCollideCallback("Player", "ScriptArea_11", "VaseEvent", false, 1);

Function:

void VaseEvent(string &in asParent, string &in asChild, int alState)
{
    SetLocalVarInt("EventChance", RandInt(1,4));
    if (GetLocalVarInt("EventChance")==1)
    {
        SetLocalVarInt("TimeRandomize", RandInt(0,3));
        AddTimer("", TimeRandomize, "VaseEventDelay");
    }
}
void VaseEventDelay(string &in asTimer)
{
    AddPropImpulse("vase01_1", 0, 0, 20, "");
    GiveSanityDamage(10, true);
    SetEntityActive("ScriptArea_11", false);
    SetEntityActive("ScriptArea_12", false);
}

The variable is firstly declared just after OnStart() and OnEnter() (I am not sure if it's necessary after all).
04-08-2013, 10:57 PM
Find
Yare Offline
Junior Member

Posts: 22
Threads: 2
Joined: Mar 2013
Reputation: 0
#2
RE: [SCRIPT]Variable not declared

Now it's even more weird, because in my case RandInt was refusing to work without declared variable...

And I use timer, because I want the script to activate in random second.
04-08-2013, 11:14 PM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#3
RE: [SCRIPT]Variable not declared

Try this:

PHP Code: (Select All)
void VaseEvent(string &in asParentstring &in asChildint alState)
{
    
SetLocalVarInt("EventChance"RandInt(1,4));
    if (
GetLocalVarInt("EventChance")==1)
    {
        
AddTimer(""RandFloat(03), "VaseEventDelay");
    }
}
void VaseEventDelay(string &in asTimer)
{
    
AddPropImpulse("vase01_1"0020"");
    
GiveSanityDamage(10true);
    
SetEntityActive("ScriptArea_11"false);
    
SetEntityActive("ScriptArea_12"false);


In Ruins [WIP]
04-08-2013, 11:29 PM
Find
Yare Offline
Junior Member

Posts: 22
Threads: 2
Joined: Mar 2013
Reputation: 0
#4
RE: [SCRIPT]Variable not declared

@NaxEla

Hm, suddenly that works. But still...
Does anyone know why that way with variable doesn't work while it really DID work earlier? It's indeed more complicated but doesn't seem wrong. I am just bloody curious.
04-08-2013, 11:40 PM
Find
VillainousPotato Offline
Member

Posts: 50
Threads: 13
Joined: Mar 2013
Reputation: 1
#5
RE: [SCRIPT]Variable not declared

(04-08-2013, 11:40 PM)Yare Wrote: @NaxEla

Hm, suddenly that works. But still...
Does anyone know why that way with variable doesn't work while it really DID work earlier? It's indeed more complicated but doesn't seem wrong. I am just bloody curious.

I had the same problem, but I just deleted that part of the script and rewrote it and it worked.
it also says some stuff about variables not being declared her
http://www.frictionalgames.com/forum/thread-19868.html

04-09-2013, 01:39 AM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#6
RE: [SCRIPT]Variable not declared

If you're going to use a variable that you set by using SetLocalVarInt, then you need to use GetLocalVarInt to use it's value. What I did in the script was just delete that variable entirely because it wasn't really necessary.

In Ruins [WIP]
04-09-2013, 01:53 AM
Find




Users browsing this thread: 4 Guest(s)