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
Weird coding errors?
goalreadymc
Unregistered

 
#1
Weird coding errors?

Hi,

I'm trying to script my HPS file and I keep getting weird crashes when I open my custom story, so I was wondering if anybody can check my code. Thank you!

void OnStart()
//
SetPlayerActive(false);
FadeOut(0);
AddTimer("", 1.4, "CoughTimer");
SetEntityPlayerInteractCallback("", "IntroCreditsDoor1", true);
AddEntityCollideCallback("LanternVeriMessage", "Player", "LanternVeriMessage", false, 1);

void CoughTimer(string &in asTimer)
//
PlaySoundAtEntity("", "player_cough.snt", "Player", 0.1f, false);
AddTimer("", 2.6, "WakeTimer");

void WakeTimer(string &in asTimer)
//
PlaySoundAtEntity("", "player_crouch.snt", "PLayer", 0.1f, false);
FadeOut(0.7);

void IntroCreditsDoor1(string &in asEntity)
//
SetMessage("IntroCredits", "Door1", 1.7);

void LanternVerification(string &in asItem, string &in asEntity)
//
SetEntityActive("LanternVeriBarrier", false);
SetEntityActive("LanternVeriMessage", false);

void LanternVeriMessage(string &in asParent, string &in asChild, int alState)
//
SetMessage("IntroCredits", "LanternVeriMessage", 1.7);
09-07-2015, 03:37 AM
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Weird coding errors?

You're using double-slash instead of brackets? What?

No, a function looks like this:

PHP Code: (Select All)
void MyFunc()
{



Not this:

PHP Code: (Select All)
void MyFunc()
// 

Not sure where you got this from but that's your crash at least.

(This post was last modified: 09-07-2015, 07:10 AM by Mudbill.)
09-07-2015, 07:10 AM
Find
7heDubz Offline
Posting Freak

Posts: 1,329
Threads: 40
Joined: Feb 2013
Reputation: 41
#3
RE: Weird coding errors?

For debugging your own code you can take the error code and find the corresponding (12,36) (line, character) is you get a line and a 0 for example, (12,0), try checking the line of code before it the one it returned with.

But yeah, you were way mistaken, the double forward slash is used for commenting lines of code. Brackets contain groupings of code such as the kind you find in a function.

(This post was last modified: 09-07-2015, 09:33 AM by 7heDubz.)
09-07-2015, 09:32 AM
Find
SwingsDarkCreeps Offline
Junior Member

Posts: 26
Threads: 3
Joined: Jun 2015
Reputation: 0
#4
RE: Weird coding errors?

hi, so this: //(double slash)- corresponds at commentaries inside the script(like 7he Dubz
said before);
{}(brackets)-corresponds at function branch or
offshoot (like Mugbill said before);
A functions usually start with a bracket and end with another bracket(exceptions if you don't use break function) like this:
void TheSpecificCallbackFunction(...)
{
here you write the code;
}
Wink
that is the general structure of a function;
(This post was last modified: 09-07-2015, 10:24 AM by SwingsDarkCreeps.)
09-07-2015, 10:15 AM
Find




Users browsing this thread: 3 Guest(s)