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
"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.
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:
//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
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
// 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);
}
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.
-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.
-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:
-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:
// 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".
The problem is that with most of these things you can pretty easily understand how to do them if you look at the wiki pages and frictional's own work. Things like playing music or sounds are fairly simple. But I'd agree that we could use some more general purpose tutorials, like tutorials on how to make keys unlock doors, to help people completely unfamiliar with any of this get ahead.
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
This is great, thanks.
Keep 'em coming, I'll keep this thread updated.
BTW should I change the subject? To something like: "How to... Compilation" or something more descriptive.
And what would be a good way to organize scripts? Alphabetically? (Somewhat weak).
I say lets categorize each script.
I dont know... something like:
Item Related
Monster Related
Player Related
I need to know how to make it so when you enter an area a sound or song starts playing, Im also trying to figure out how to make it so you can examine the environment "example- clicking on a bookshelf would display a description, something like "Its a bookshelf, It seems to be very old". Like in the penumbra games. Thanks
(10-20-2010, 11:54 PM)Alex7754 Wrote: I need to know how to make it so when you enter an area a sound or song starts playing, Im also trying to figure out how to make it so you can examine the environment "example- clicking on a bookshelf would display a description, something like "Its a bookshelf, It seems to be very old". Like in the penumbra games. Thanks
Look for MulleDK19's area trigger tutorial on the Wiki, you should be able to change the necessary lines of codes yourself.
The Penumbra Examine feature is great, you just have to make an examine area and create a fitting entry for it in the extra_eng.lang file. A tutorial on that is in the workings..