Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SCRIPT / MDL ED] Replace an entity / Creating a lamp
Mackiiboy Offline
Member

Posts: 101
Threads: 7
Joined: Jan 2012
Reputation: 11
#1
[SCRIPT / MDL ED] Replace an entity / Creating a lamp

[Image: ny8t5j.jpg]

I have been trying to make a sword start to glow while you're holding it in your hands. I have created two entities in the model editor, a regular sword, and a glowing one (with billboards etc). The main problem is to change the regular sword into a glowing one without dropping the sword to the ground. I have so far not found anything helpful in the "Engine scripts", and therefore asking you if you know any good methods to replace an entity with another one. If it's not possible to replace an entity with another one with Engine scripts, please tell me.

Another method I was thinking of was creating a grabbable sword-lamp (a sword entity with lamp-settings). When the sword is lit - the billboards appears and etc. I'm not sure if that will work tho, and even if it does, I'm not used to create lamps and do not really know how to do. I have been trying to connect the billboards to the sword, but I can't get it to work - nothing happens when you lit/unlit the sword. So, if you know how to create a lamp, or if it exists any custom-lamp-creating tutorials, please post a comment Shy
(This post was last modified: 03-07-2012, 08:46 PM by Mackiiboy.)
03-06-2012, 09:21 PM
Website Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#2
RE: [SCRIPT / MDL ED] Replace an entity / Creating a lamp

There might be a way to replace the entity. I'd rather not type it all out, so I'll try out some ideas I've had.
Got it working. Here's what you do.


In the model editor, create your entity with a light attached to its body. Make sure this light's name is "PointLight_1". In your map script, add these two following two lines to OnStart().

PHP Code: (Select All)
// in this script, your sword is named "sword_light_1"
void OnStart()
{
    
FadeLightTo("sword_light_1_PointLight_1"0001, -11.5f);
    
SetEntityPlayerInteractCallback("sword_light_1""PickSword"false);


Next, add this function to the main body of your script

PHP Code: (Select All)
void PickSword(string &in entity)
{
    
FadeLightTo(entity+"_PointLight_1"1111, -11.5f); 
    
SwordPickLoop(entity);
}
void SwordPickLoop(string &in timer)
{
    if(!
GetPropIsInteractedWith(timer))    
    {
        
FadeLightTo(timer+"_PointLight_1"0001, -11.5f);
           return;
     }
     
AddTimer(timer0.0166f"SwordPickLoop");


Then, you're good to go! The sword's light will fade in/out over 1.5 seconds when the player picks it up or drops it. Enjoy.

(This post was last modified: 03-06-2012, 11:47 PM by palistov.)
03-06-2012, 11:17 PM
Find
Mackiiboy Offline
Member

Posts: 101
Threads: 7
Joined: Jan 2012
Reputation: 11
#3
RE: [SCRIPT / MDL ED] Replace an entity / Creating a lamp

(03-06-2012, 11:17 PM)palistov Wrote: Then, you're good to go! The sword's light will fade in/out over 1.5 seconds when the player picks it up or drops it. Enjoy.
.
You are awesome, thanks! Shy
03-07-2012, 10:59 AM
Website Find




Users browsing this thread: 1 Guest(s)