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.17 (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:
  • 16 Vote(s) - 4.44 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripts Recollection
Arvaga Offline
Junior Member

Posts: 8
Threads: 1
Joined: Oct 2010
Reputation: 1
#1
Information  Scripts Recollection

Add an item to your inventory
Spoiler below!
GiveItem(name, type, subType, image, amount);
name: The name identifying your object.
type: The type of your object (not sure exactly for what, the game's inventory.hps always uses "Puzzle" as type).
subType: Here goes the name of your item in the .lang file (only what goes after the "ItemName_" part).
image: The name of the graphic to display in the menu, for default the graphics are in ".../redist/graphics/item/" (be sure to include the extension, .tga in this case)
amount: The amount to give? (in the game's inventory.hps the amount they used was always 0, dunno why)
Example:
GiveItem("handdrill", "Puzzle", "hand_drill", "hand_drill.tga", 0);
// To remove an item:
RemoveItem(name);
// To check if player has item (returns true or false)
HasItem(name);


Make a monster appear after a trigger (taken from this thread) by Kyle
Spoiler below!
void OnStart()
{
  AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
  SetEntityActive("servant_grunt" , true);
}
"ScriptArea_1" is the name of the script area where you collide which causes the monster to spawn.
"MonsterFunc1" is the name of the function used later on when you want to add to the script instead of it doing nothing.
"servant_grunt" is the name of the monster that spawns.
Remember to set the monster's entity to not active.

Make objects float by Frontcannon

Add entries to the Journal by mastersmith98

Force player to look somewhere by mastersmith98
Spoiler below!

StartPlayerLookAt(ScriptArea, viewacceleration, maxviewvelocity, onlook);
ScriptArea is the name of the area script you place in your map and where the player looks.
viewacceleration controls how fast the player looks.
maxviewvelocity controls the max speed the player looks.
onlook is a function you call when the player's view is centered on the target.
To stop the player from looking at a spot, call StopPlayerLookAt();
Example:
void TimerDoneLookAt(string &in asTimer)
{
  StopPlayerLookAt();
}

//When player starts the level, make him look at this spot.
void OnStart()
{
  // Function argument is empty since we don't want to call a function.
  StartPlayerLookAt("AreaLookAt", 2, 2, "");

  //Make the player look for 2.5 seconds
  AddTimer("donelook", 2.5f, "TimerDoneLookAt");
}


Make a locked door and a key to unlock it by Frontcannon
Spoiler below!

void OnStart()
{
    AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("mansion_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}
What it does:
AddUseItemCallback - calls a function when an item is used on an entity
R01_Key1 - the item used, in this case our key
mansion_1 - the entity the key is used on, the normal mansion door
KeyOnDoor - the function the callback calls (true means to remove it when called once)

SetSwingDoorLocked - locks/unlocks a door, false means to set it NOT locked, and the true is to wether use effects or not
PlaySoundAtEntity - plays a sound at an entity, in this case the "unlocked a door"- sound at mansion_1, our door, the float value is the time it takes to fade in and the true is some strange boolean


Teleport player when he touches an area by house
Spoiler below!

void CollidePlayerTeleport(string &in asParent, string &in asChild, int alState)
{
   TeleportPlayer(teleport_name);
   // Optional fading effects to make a better teleporting transition.
   FadeOut(0);
   FadeIn(20);
}
-teleport_name: Name of what to teleport to, I recommend making another PlayerStartArea and giving the name of the extra player spawn.


Make a reusable function to unlock doors by Arvaga
Spoiler below!

// This function is to be called from an AddUseItemCallback function:
// AddUseItemCallback(callback_name, item_name, door_name, function, auto_destroy);
// Usage example: AddUseItemCallback("", "my_key", "my_door", "UnlockDoor", true);
void UnlockDoor(string &in asItem, string &in asEntity)
{
  // Unlock the entity asEntity (since it's the door we targeted)
  SetSwingDoorLocked(asEntity, false, true);
  // Optional sound effect for when our door opens.
  PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
  // Optional removal of the item used in the door.
  RemoveItem(asItem);
}


Make player float by anzki
Spoiler below!

Also you can make player float by:
AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);
Where float afX,float afY and float afZ are forces to X,Y,Z directions, and bool abUseLocalCoords is true or false if it should use LocalCoords, which is based on where player looks; where X is nothing, Y is right/left and Z is forward/backward. Also force is required to be high for player to move; ie. 2000 makes him move about 1 m.


Play a sound by anzki
Spoiler below!

Also you can add sound by using:
PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);
-Where string& asSoundName is name of a sound.(Can be left blank, unless you want it to loop, and later stop.
-string& asSoundFile is sound file; the file you want to be played.
-string& asEntity is entity you want it to be played.(For example "player" makes it play at player, but if you want the sound to be heard from elsewhere; let's say a piano called "piano1", you put that("piano1") there.
-float afFadeTime is time it should fade, for example 1.0f would put 1 second fade time.
-bool abSaveSound. I am not sure what this is Just set it to false.

And you can stop it by using:
StopSound(string& asSoundName, float afFadeTime);
-Where string& asSoundName is name of a sound(see above.)
-float afFadeTime; fade time, see above.


Add message by anzki
Spoiler below!

1.Make category to language file with any name you want to! Let's say category named:"Example". (To easily add this use HPLangtool found in the same folder as the level editor.)
2.Inside the category ("Example", or anything you have put it's name.) create entry with any name you want. Example; "Entry1".
3.Use this script where you want the message to be showed:
SetMessage(string &asTextCategory, string &asTextEntry, float afTime);
-string &asTextCategory and string &asTextEntry will be the name of a category and entry.
-float afTime will be the time the message is on screen in form; 1.0f(=1 second.)

Example using category "Example" and entry "Entry1", showing the entry for 20 seconds:
SetMessage("Example", "Entry1", 20.0f);


Make a lever functional by Arvaga
Spoiler below!

// Callback function for when the lever's state changes
// EntityName is the name of the lever
// alState is the current state of the lever, -1 being low, 0 middle and 1 high *
void OnLeverStateChange(string &in EntityName, int alState)
{
    // Do something when the state changes
        // Optional debug message
    AddDebugMessage(EntityName + "'s current state: " + alState, false);

    if (alState == -1)
    {
        // Do something if the lever's state is low (or change it to 0 or 1)
    }
}
// * low, middle and high are relative to its rotation.
In the lever's entity properties write the function to "ConnectionStateChangeCallback", in this case you should write "OnLeverStateChange".

Functions List

Anything helps, even if it's just as basic as a single line of code (like adding an item to your inventory).
(This post was last modified: 11-11-2010, 05:30 PM by Arvaga.)
10-20-2010, 02:57 AM
Find


Messages In This Thread
Scripts Recollection - by Arvaga - 10-20-2010, 02:57 AM
RE: Scripts Recollection - by mastersmith98 - 10-20-2010, 05:59 AM
RE: Scripts Recollection - by Kyle - 10-20-2010, 12:01 PM
RE: Scripts Recollection - by Vincent - 10-20-2010, 01:05 PM
RE: Scripts Recollection - by Frontcannon - 10-20-2010, 02:20 PM
RE: Scripts Recollection - by mrscoomich - 03-18-2012, 05:58 PM
RE: Scripts Recollection - by mastersmith98 - 10-20-2010, 10:18 PM
RE: Scripts Recollection - by Arvaga - 10-20-2010, 11:03 PM
RE: Scripts Recollection - by Alex7754 - 10-20-2010, 11:54 PM
RE: Scripts Recollection - by Frontcannon - 10-21-2010, 01:35 AM
RE: Scripts Recollection - by The worst submarine - 10-21-2010, 02:54 AM
RE: Scripts Recollection - by mastersmith98 - 10-21-2010, 03:27 AM
RE: Scripts Recollection - by anzki - 10-21-2010, 09:23 AM
RE: Scripts Recollection - by house - 10-22-2010, 07:31 PM
RE: Scripts Recollection - by anzki - 10-23-2010, 11:07 AM
RE: Scripts Recollection - by anzki - 10-24-2010, 10:13 AM
RE: Scripts Recollection - by Everlone - 10-25-2010, 03:51 PM
RE: Scripts Recollection - by Frontcannon - 10-25-2010, 04:30 PM
RE: Scripts Recollection - by Everlone - 10-25-2010, 04:35 PM
RE: Scripts Recollection - by Frontcannon - 10-25-2010, 05:07 PM
RE: Scripts Recollection - by Everlone - 10-25-2010, 05:11 PM
RE: Scripts Recollection - by Frontcannon - 10-25-2010, 05:37 PM
RE: Scripts Recollection - by Everlone - 10-25-2010, 05:48 PM
RE: Scripts Recollection - by zlandael - 10-27-2010, 01:07 AM
RE: Scripts Recollection - by mastersmith98 - 10-27-2010, 01:55 AM
RE: Scripts Recollection - by anzki - 10-27-2010, 02:32 PM
RE: Scripts Recollection - by Arvaga - 11-11-2010, 05:29 PM
RE: Scripts Recollection - by Frontcannon - 11-11-2010, 06:05 PM
RE: Scripts Recollection - by Equil - 01-03-2011, 03:33 PM
RE: Scripts Recollection - by Frontcannon - 01-03-2011, 04:20 PM
RE: Scripts Recollection - by Equil - 01-03-2011, 04:25 PM
RE: Scripts Recollection - by Frontcannon - 01-03-2011, 04:36 PM
RE: Scripts Recollection - by Equil - 01-03-2011, 04:45 PM
RE: Scripts Recollection - by DIGI Byte - 01-04-2011, 03:28 PM
RE: Scripts Recollection - by Frontcannon - 01-04-2011, 04:35 PM
RE: Scripts Recollection - by DIGI Byte - 01-04-2011, 04:58 PM
RE: Scripts Recollection - by DIGI Byte - 01-05-2011, 02:53 AM
RE: Scripts Recollection - by DIGI Byte - 01-05-2011, 06:02 AM
RE: Scripts Recollection - by Frontcannon - 01-05-2011, 04:29 PM
RE: Scripts Recollection - by DIGI Byte - 01-05-2011, 09:30 PM
RE: Scripts Recollection - by Tony32 - 01-10-2011, 11:04 PM
RE: Scripts Recollection - by house - 01-10-2011, 11:59 PM
RE: Scripts Recollection - by Tony32 - 01-11-2011, 02:37 PM
RE: Scripts Recollection - by Frontcannon - 01-13-2011, 05:09 PM
RE: Scripts Recollection - by Tony32 - 01-13-2011, 04:21 PM
RE: Scripts Recollection - by Seragath - 01-13-2011, 04:32 PM
RE: Scripts Recollection - by Akumasama - 01-15-2011, 06:25 PM
RE: Scripts Recollection - by Frontcannon - 01-15-2011, 08:34 PM
RE: Scripts Recollection - by Akumasama - 01-18-2011, 05:51 PM
RE: Scripts Recollection - by Ianlis - 01-21-2011, 11:45 PM
RE: Scripts Recollection - by Akumasama - 01-22-2011, 01:20 AM
RE: Scripts Recollection - by Vradcly - 01-22-2011, 01:27 AM
RE: Scripts Recollection - by Ianlis - 01-22-2011, 05:42 AM
RE: Scripts Recollection - by Akumasama - 01-23-2011, 05:35 PM
RE: Scripts Recollection - by Tottel - 01-25-2011, 02:48 PM
RE: Scripts Recollection - by Beatlebattle - 01-27-2011, 07:04 PM
RE: Scripts Recollection - by Oscar House - 01-27-2011, 09:05 PM
RE: Scripts Recollection - by Beatlebattle - 01-29-2011, 12:19 AM
RE: Scripts Recollection - by adamhun - 02-07-2011, 04:47 PM
RE: Scripts Recollection - by kozek - 02-22-2011, 10:27 AM
RE: Scripts Recollection - by Nye - 02-25-2011, 01:38 AM
RE: Scripts Recollection - by kozek - 03-01-2011, 07:12 PM
RE: Scripts Recollection - by Zinnkio - 02-26-2011, 04:42 PM
RE: Scripts Recollection - by Ongka - 02-26-2011, 05:28 PM
RE: Scripts Recollection - by Zinnkio - 02-26-2011, 05:49 PM
RE: Scripts Recollection - by nkmol - 02-26-2011, 07:18 PM
RE: Scripts Recollection - by Zinnkio - 02-26-2011, 09:55 PM
RE: Scripts Recollection - by nkmol - 03-01-2011, 11:31 PM
RE: Scripts Recollection - by kozek - 03-04-2011, 05:45 PM
RE: Scripts Recollection - by Pandemoneus - 03-04-2011, 05:47 PM
RE: Scripts Recollection - by TheGreatCthulhu - 03-04-2011, 11:01 PM
RE: Scripts Recollection - by Pandemoneus - 03-05-2011, 12:16 AM
RE: Scripts Recollection - by Raymond - 03-05-2011, 08:14 AM
RE: Scripts Recollection - by Pandemoneus - 03-05-2011, 05:38 PM
RE: Scripts Recollection - by Raymond - 03-06-2011, 02:49 AM
RE: Scripts Recollection - by CrushedRaiD - 03-07-2011, 10:07 AM
RE: Scripts Recollection - by wisecow - 04-17-2011, 08:05 PM
RE: Scripts Recollection - by wisecow - 04-18-2011, 04:31 PM
RE: Scripts Recollection - by nkmol - 04-18-2011, 05:42 PM
RE: Scripts Recollection - by teddan50 - 12-12-2011, 10:40 PM
RE: Scripts Recollection - by Jahffax - 04-23-2011, 07:05 AM
RE: Scripts Recollection - by Kyle - 04-23-2011, 10:48 PM
RE: Scripts Recollection - by Jahffax - 04-24-2011, 11:36 AM
RE: Scripts Recollection - by Exostalker - 04-29-2011, 02:38 PM
RE: Scripts Recollection - by ufando - 04-24-2011, 09:56 AM
RE: Scripts Recollection - by wisecow - 06-08-2011, 02:38 PM
RE: Scripts Recollection - by laser50 - 06-17-2011, 10:25 PM
RE: Scripts Recollection - by Tanshaydar - 06-17-2011, 10:28 PM
RE: Scripts Recollection - by laser50 - 06-17-2011, 10:34 PM
RE: Scripts Recollection - by Fireintex - 11-09-2011, 12:09 AM
RE: Scripts Recollection - by Kyle - 11-09-2011, 12:52 AM
RE: Scripts Recollection - by Fireintex - 11-09-2011, 12:55 AM
RE: Scripts Recollection - by Kyle - 11-09-2011, 02:00 AM
RE: Scripts Recollection - by jessehmusic - 12-23-2011, 03:04 PM
RE: Scripts Recollection - by CorinthianMerchant - 01-12-2012, 05:26 PM
RE: Scripts Recollection - by Elven - 01-13-2012, 10:19 PM
RE: Scripts Recollection - by CorinthianMerchant - 01-15-2012, 01:09 PM
RE: Scripts Recollection - by Loveridge - 01-19-2012, 08:21 PM
RE: Scripts Recollection - by flamez3 - 01-20-2012, 02:32 AM
RE: Scripts Recollection - by Khyrpa - 01-19-2012, 08:35 PM
RE: Scripts Recollection - by CorinthianMerchant - 01-20-2012, 05:15 PM
RE: Scripts Recollection - by SilentStriker - 01-21-2012, 10:03 AM
RE: Scripts Recollection - by CorinthianMerchant - 01-21-2012, 02:29 PM
RE: Scripts Recollection - by SilentStriker - 01-21-2012, 03:20 PM
RE: Scripts Recollection - by CorinthianMerchant - 01-21-2012, 03:23 PM
RE: Scripts Recollection - by SilentStriker - 01-21-2012, 03:43 PM
RE: Scripts Recollection - by CorinthianMerchant - 01-21-2012, 04:21 PM
RE: Scripts Recollection - by jillis - 01-23-2012, 08:36 AM
RE: Scripts Recollection - by flamez3 - 01-23-2012, 10:14 AM
RE: Scripts Recollection - by jillis - 01-23-2012, 04:28 PM
RE: Scripts Recollection - by flamez3 - 01-24-2012, 03:27 AM
RE: Scripts Recollection - by jillis - 01-24-2012, 07:41 AM
RE: Scripts Recollection - by Stepper321 - 03-19-2012, 05:22 PM
RE: Scripts Recollection - by mrscoomich - 03-21-2012, 12:04 AM
RE: Scripts Recollection - by flamez3 - 03-21-2012, 12:47 PM
RE: Scripts Recollection - by mrscoomich - 03-25-2012, 01:41 AM



Users browsing this thread: 2 Guest(s)