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
Spawning entity by pressing a key?
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#1
Spawning entity by pressing a key?

Hey guys.

I was wondering if there is a way to spawn entity in Area by pressing a key, for example T

Thanks in advance.
01-20-2014, 10:03 PM
Find
DreamScripters Offline
Junior Member

Posts: 25
Threads: 4
Joined: Dec 2013
Reputation: 0
#2
RE: Spawning entity by pressing a key?

To keep it short i'm almost positive no. I have never seen it anywhere else where someone was able to bind a certain key to a script. I mean, if you really wanted to you could do something such as making a script that loops maybe every 0.1 seconds that will check if the player has his lantern out and if so you could make it so it spawns the entity and turns the lantern back off. It would be something to the effect of binding the "f" key to the script.

If you are interested in using this method though here's how I believe the script would be set up:

void OnStart()
{
     //Goes to "LoopStart" function.
     LoopStart();
}

void LoopStart()
{
     //Adds timer to go to "LanternCheck" function.
     AddTimer("lantern_check", 0.1f, LanternCheck);
}

void LanternCheck(string &in asTimer)
{
     //Checks if lantern is on.
     if(GetLanternActive() == true) {
          //Sets your entity active. (Replace "your_entity" with your entity name.)
          SetEntityActive("your_entity", true);
          //Makes the lantern turn off.
          SetLanternActive(false, false);
     }
     //Else if the lantern is not on.
     else {
          //Make it loop all over again. (Change "0.1f" with any number to change the time intervals it loops.)
          AddTimer("LanternCheck", 0.1f, "LanternCheck");
     }
}

Nothing too fancy but I believe if you wanted to use this method it would work. Best of luck on whatever you're aiming to do! Big Grin

[Image: header.png]
01-21-2014, 03:37 AM
Website Find
Traggey Offline
is mildly amused

Posts: 3,257
Threads: 74
Joined: Feb 2012
Reputation: 185
#3
RE: Spawning entity by pressing a key?

Actually, in Horizon we had plenty of that stuff.

I on the other hand do not know how to, but it is doable!



(This post was last modified: 01-21-2014, 09:10 AM by Traggey.)
01-21-2014, 09:09 AM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#4
RE: Spawning entity by pressing a key?

I don't think it's possible, I tried once, but the closest connection between keys and script is the lantern callback.
Maybe in the new update there is another way.

The video above -I'm guessing- is using keys, but only the ones the game allows for movement -W A S D-
It has 4 areas around the player to detect his movement and one extra above to detect the using of space -jump-.

So still, no "T" to spawn anything.
That's what I think, you can always go and try it yourself.
You may find something.

01-21-2014, 12:35 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#5
RE: Spawning entity by pressing a key?

Aaaaw, this is an old-school script! Here:

void OnStart() //Or you can put the following stuff in OnEnter()
{
SetEntityCallbackFunc("YOUR_KEY", "OnPickup");
}

void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("YOURENTITY", true);
}

/////OR YOU CAN USE

void OnPickup(string &in asEntity, string &in type)
{
CreateEntityAtArea("Your_entity_name", "ENTITY.ENT", "AREATOBESPAWNEDATNAME", false);
}

EDIT: Oh my god, I misread your post... spawning an entity pressing a keyboard key... nope, nothing that I know of.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
(This post was last modified: 01-23-2014, 06:52 PM by The chaser.)
01-23-2014, 06:50 PM
Find




Users browsing this thread: 1 Guest(s)