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
Need help fixing a bug in a script
Koopa Rs07 Offline
Member

Posts: 146
Threads: 30
Joined: Sep 2014
Reputation: 5
#1
Question  Need help fixing a bug in a script

(BUG IS FIXED)

I didn't make the script, it was copied from the main game and then tweaked by someone who has better knowledge than me. So I have no clue how to fix it. If anyone is willing to help me, pm me. I will put your name in the credits of my cs. Big Grin

(This post was last modified: 02-24-2016, 11:48 PM by Koopa Rs07.)
02-23-2016, 09:45 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Need help fixing a bug in a script

No offense, but you're better to just post the script to get the help required; we're a forum. On a forum, you openly contribute Wink If it's too much of a spoiler, then post the most relevant sections of code.

Does an error pop up or the game just continue like normal? If an error pops up, then you can use the information to determine the location of your code faults.

If the game continues as normal, the best way to check for errors is by using Script Debug codes.

Set up the Developer Environment here, if you have not already;
https://wiki.frictionalgames.com/hpl2/am...evenvguide

Then use to print messages to determine which voids functions are working in your game:
PHP Code: (Select All)
void AddDebugMessage(stringasStringbool abCheckForDuplicates); 

Moving to Development Support.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
02-23-2016, 11:53 PM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#3
RE: Need help fixing a bug in a script

Besides, many of the original scripts use optimization techniques to ease their job a little.

For example in order to not have to wright the same code multiple times, the might just create custom functions.

PHP Code: (Select All)
void OnStart()
{
    if(
areAllQuestsCompleted)
        
SpawnStuff("Enemy"true);
}

void SpawnStuff(string whatToSpawnbool effects)
{
    
SetEntityActive(whatToSpawntrue);
    if(
effects)
    {
        
PlayMusic("music.ogg"true1.0f1.0f1false);
        
GiveSanityDamage(10.0ftrue);
    }
}

bool areAllQuestsCompleted()
{
    if(
QuestIsCompleted("lastQuest"))
    {
        return 
true;
    }
    return 
false;


Some of those functions might be even used in a totally different part of the script and need to be declared only once. Therefore it is possible that you did not copy one of those functions.

But it's very difficult to know without seeing the code.
02-24-2016, 09:49 AM
Find
WALP Offline
Posting Freak

Posts: 1,221
Threads: 34
Joined: Aug 2012
Reputation: 45
#4
RE: Need help fixing a bug in a script

EDIT: SEEMS THREAD MIGHT BE GETTING CLOSED, SO PLEASE REPLY HERE INSTEAD
https://www.frictionalgames.com/forum/thread-40412.html

just letting you people know the issue has been fixed.

When reading frictionals code however, I discovered a piece of code I initially thought was retarded, but upon closer inspection seemed to be a workaround for a tricky code issue, and I was wondering what the ideal way to implement something like it would have been. You can take a look at the actual code yourself in the 03_archives.hps, but in short it goes like this:

PHP Code: (Select All)
void CollideSecretBook(string &in asBookstring &in asCollideAreaint BookState)
{
    
AddTimer(asBook,20,"PushBackBook1"); //name of the timer(asTimer) = name of the book being pulled out(asBook)
}

PushBackBook1(string &in asTimer)
{
    
SetPropObjectStuckState(asTimer, -1); //Pushes the book back
    
AddTimer("2"+asTimer0.25f"PushBackBook02"); //then just 0.25 seconds later the same book is put into the normal state. 
}

PushBackBook2(string &in asTimer)
{
    if(
asTimer == "2SecretBook_1"
    {
        
SetPropObjectStuckState("SecretBook_1"0);
    }
    else if(
asTimer == "2SecretBook_2"
    {
        
SetPropObjectStuckState("SecretBook_2"0);
     }
    else 
    {
        
SetPropObjectStuckState("SecretBook_3"0);
    }


Basically PushBackBook1 and PushBackBook2 do almost the same thing, but for some reason PushBackBook2 needs code for every single book while the other simply got the name of the book from the timer name.

The reason for this is that the timer that calls PushBackBook2, cant be named the same as the Book, since there's already a timer for PushBackBook1 with the very same name.
Hence the scripter had to rename the timer with the "2" in front, but the problem with doing this was that now he could not use the timer name anymore to pass on the name of the book, so instead of just writing:

SetPropObjectStuckState(asTimer, 0);

He had to go through and script for every single timer name

if(asTimer == "2SecretBook_1")
{
SetPropObjectStuckState("SecretBook_1", 0);
}
else if(asTimer == "2SecretBook_2")
{
SetPropObjectStuckState("SecretBook_2", 0);
}
else
{
SetPropObjectStuckState("SecretBook_3", 0);
}


This seems terribly messy, and I cant help but feel there has to be some way that the name of Book can be passed on directly from PushBackBook1 to PushBackBook2.

Any ideas?
(This post was last modified: 02-25-2016, 12:05 AM by WALP.)
02-24-2016, 11:43 PM
Find
Koopa Rs07 Offline
Member

Posts: 146
Threads: 30
Joined: Sep 2014
Reputation: 5
#5
RE: Need help fixing a bug in a script

(BUG IS FIXED)
Mods can tear this thread down now if they so please. Big Grin

(This post was last modified: 02-24-2016, 11:48 PM by Koopa Rs07.)
02-24-2016, 11:46 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: Need help fixing a bug in a script

I'll keep it for the moment because there's a bit of discussion proposed by WALP. After that, I'll consider closing it, since we don't usually delete Dev Support threads~

Oh! Never mind, WALP started a new thread on the issue. Closing Smile

If you want to discuss WALP's code above, please refer to here:
https://www.frictionalgames.com/forum/thread-40412.html

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 02-25-2016, 12:22 AM by Romulator.)
02-25-2016, 12:20 AM
Find




Users browsing this thread: 1 Guest(s)