Toggle
Junior Member
Posts: 19
Threads: 5
Joined: Oct 2013
Reputation:
0
|
Assist me while I learn to script
This is pretty much just me asking how to do things at this point. So far, so good.
(This post was last modified: 01-29-2016, 08:21 PM by Toggle.)
|
|
01-26-2016, 10:59 PM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: Level Editor Crash
Could you post the LevelEditor.log instead from Documents\HPL2 ?
|
|
01-27-2016, 01:38 AM |
|
Toggle
Junior Member
Posts: 19
Threads: 5
Joined: Oct 2013
Reputation:
0
|
RE: Level Editor Crash
Thread has been recycled.
(This post was last modified: 01-28-2016, 11:42 PM by Toggle.)
|
|
01-27-2016, 03:01 AM |
|
Toggle
Junior Member
Posts: 19
Threads: 5
Joined: Oct 2013
Reputation:
0
|
RE: No Matching Signatures
Also, is there a way to write a code so that if a player breaks a certain item in the environment, one of those glass display cases for example, a message pops up?
|
|
01-29-2016, 02:56 AM |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: No Matching Signatures
Use GetPropHealth() to check the state of an entity. If that "health" == 0, then it has been broken. IIRC there is also an OnBreak callback for the normal SetEntityCallbackFunc function. That one is probably even better to use.
|
|
01-29-2016, 08:25 AM |
|
Spelos
Banned
Posts: 231
Threads: 19
Joined: Sep 2014
|
RE: No Matching Signatures
I'll just go ahead and put a more... newcomer-friendly version of what Mudbill posted earlier.
The events you're looking for are
void SetEntityCallbackFunc(string& asName, string& asCallback);
for the break callback
and
void SetMessage(string& asTextCategory, string& asTextEntry, float afTime);
OnStart() { SetEntityCallbackFunc("nameOfTheEntity", "functionToCall"); }
void functionToCall(string &in asEntity, int alState) //notice this function is called the same as referenced above. { SetMessage("categoryOfText", "entryInCategory", 0); //The last number is how long the message should be displayed, 0 = calculated depending on the length of the text. The text and category are in a different file called "extra_english.lang" in the custom story folder. }
Your extra_english.lang should contain something like this:
<LANGUAGE> <CATEGORY Name="CustomStoryMain"> <Entry Name="Description"> Description of your story</Entry> </CATEGORY>
<CATEGORY Name="categoryOfText"> //Notice the name of the category & entry are referenced in your .hps file. <Entry Name="entryInCategory">Text to appear on screen.</Entry> </CATEGORY> </LANGUAGE>
|
|
01-29-2016, 07:12 PM |
|
Toggle
Junior Member
Posts: 19
Threads: 5
Joined: Oct 2013
Reputation:
0
|
RE: No Matching Signatures
You are just so helpful, you kind and wonderful person, you. I am becoming a big fan.
(This post was last modified: 01-29-2016, 07:16 PM by Toggle.)
|
|
01-29-2016, 07:15 PM |
|
Toggle
Junior Member
Posts: 19
Threads: 5
Joined: Oct 2013
Reputation:
0
|
RE: Assist me while I learn to script
Okay, next question is.. Do I need to use timers to play a sound at regular intervals UNTIL the player goes over to interact with the script area? Or is there a different way to accomplish that? Not a loop, though. What I want is for the sound to play every 30 seconds or so, until the player gets in the proper place, at which time the sound should stop.
|
|
01-29-2016, 08:29 PM |
|
Radical Batz
Posting Freak
Posts: 953
Threads: 145
Joined: Dec 2013
Reputation:
25
|
RE: Assist me while I learn to script
(01-29-2016, 08:29 PM)Toggle Wrote: Okay, next question is.. Do I need to use timers to play a sound at regular intervals UNTIL the player goes over to interact with the script area? Or is there a different way to accomplish that? Not a loop, though. What I want is for the sound to play every 30 seconds or so, until the player gets in the proper place, at which time the sound should stop.
You can use an if statement but if you want to make it easier. You can like just when the player collides with an area to where you want him to go then you can use a StopSound{"name of the sound", 1); to stop the sound that's playing.
For that you need an addentitycollidecallback in void OnStart
(This post was last modified: 01-29-2016, 09:01 PM by Radical Batz.)
|
|
01-29-2016, 09:00 PM |
|
Spelos
Banned
Posts: 231
Threads: 19
Joined: Sep 2014
|
RE: Assist me while I learn to script
Final product:
A sound (GUI, that means it's not in 3D) plays Every 30 seconds or so... until the Player collides with an area.
What you will need:
- Level Editor
- Area in the map (remember the name! For this tutorial, it's "stopSoundArea")
- A sound to play (for this tutorial, it's in .ogg format, keep it at that. "rickroll.ogg". Keep it in the "sounds" folder of your custom story)
Script events
void AddTimer(string& asName, float afTime, string& asFunction); //Adding and working with timers
void PlayGuiSound(string& asSoundFile, float afVolume); //Play a sound, not using
3D
void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates); //Calls a function when two entities collide
int RandInt(int alMin, int alMax); //Selects a random integer between Min and Max value.
The actual script:
void OnStart() { AddEntityCollideCallback("Player", "stopSoundArea", "stopSoundFunction", true, 1); //Calls the "stopSoundFunction" when Player hits "stopSoundArea".
AddTimer("loop", RandInt(25, 35), "PlayLoopSound"); //Adds the timer to play the Loop sound. }
void PlayLoopSound(string &in asTimer) //The timer function. { PlayGuiSound("rickroll.ogg", 1.0f); //Plays the file one time and ends. AddTimer("loop", RandInt(25, 35), "PlayLoopSound"); //Waits 25 to 35 seconds and repeats the function. }
void stopSoundFunction(string &in asParent, string &in asChild, int alState) { RemoveTimer("loop"); //Removes the timer and breaks the loop. }
|
|
01-29-2016, 10:45 PM |
|
|