Details on getting flashlight to work

Post topics regarding Level Building/Design and Entity Usage with Reality Factory
Post Reply
incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Details on getting flashlight to work

Post by incenseman2003 »

I have the scripts for the flashlight. It could take me a very long time to get it to work through trial and error, taking into account number of entities to try and all the sttings for each one. Is there anyone that can tell me the information as to what entity to use and the settings for it, that they are certain will work. That would save alot of time and headache. There is very little detail on the subject.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.
User avatar
AndyCR
Posts: 1449
Joined: Wed Jul 06, 2005 5:08 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

quote from the thread you got the flash light script from:
You will need AndyCR's flashlight pawn demo which has everything you need for the flashlight to work.
you can get it here: (discard the script, replace it with the one in zens thread)

viewtopic.php?t=242
incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 »

I searched the members list and there was no mention of a zen as a member. Can you give the link to his thread?
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.
User avatar
AndyCR
Posts: 1449
Joined: Wed Jul 06, 2005 5:08 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

hike1
RF FAQ-Keeper
Posts: 607
Joined: Tue Jul 05, 2005 4:19 am
Contact:

Post by hike1 »

The flashlight thing works as a standalone, always on thing, but
when I make it a pickup off the floor attribute, it only shines to the west.
User avatar
ZenBudha
Posts: 285
Joined: Wed Aug 17, 2005 6:06 am
Contact:

Post by ZenBudha »

Yes there is no Zen here because he is a Ninja and magically dissappears from time to time...
8)

It's stickied in the Scripts threads.
Fear not the textures for the almighty stylus is with thee - Book of Zen
incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 »

When I use the following info for the flashlight it works fine.

Player.ini:

[flashlight]
initial = 1
low = 0
high = 1


Pawn.ini:

[Flashlight]
actorname = Xanibot3.act
actorrotation = 0 180 0
actorscale = 1.0
fillcolor = 255 255 255
ambientcolor = 255 255 255
subjecttogravity = false
boundingboxanimation = idle


flashspawn.s:

{
Spawn[ ()
{
SetNoCollision();
FadeOut(0, 0);
LowLevel("Update");
//MoveForward("Idle", 10000, 10000, "");
}]

Update[ ()
{
MatchPlayerAngles();
PositionToPlayer(0, 0, 0);
PositionToPlayer(0, 0, GetCollideDistance("Bip01", 0, 0, 500000)-20, true);

RestartOrder();
}]
}




=========================

When I change the script to the following it does not work.

Is there something I missed?

Whats is a good trigger for this, and what would the settings be?




KEYNUMBER [0] //Add your keynumber...
ON [false]
TRIGGER_NAME [] //Add name of trigger for the light itself

Spawn[()
{
LowLevel("setup");
}]

setup[()
{
SetNoCollision();
PawnRender(false);
self.yaw_speed = 100000;
self.pitch_speed = 100000;

self.think = "update";
}]

update[()
{
self.ThinkTime = 0.0;
if(GetAttribute("flashlight")=1) //Check if player has flashlight
{
self.think = "fll";
}//HAVE FLASHLIGHT
}]

fll[ ()
{
if(ON) //if flashlight is on...
{

self.ideal_yaw = self.player_yaw;
ChangeYaw();

PositionToPlayer(0, 30, 10, true);

self.ideal_pitch = -(self.camera_pitch);
ChangePitch();
}//ON
if(self.key_pressed=KEYNUMBER) //if flashlight-key is being pressed
{
if(ON = false)//if flashlight</spa0





Any help at this point would be a godsend.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

In the script you need to change the KEYNUMBER variable (=the keycode of the keyboard key that activates the light). Each button on the keyboard has its own keycode, for example "F" is 29.

You can find out the keycodes for each button by adding a pawn to the level and giving it this very simple script:
{

Spawn[ ()
{
Console(true);
debug(self.key_pressed);
RestartOrder();
} ]

}
Another thing you need to do is set the trigger to turn the light on and off. Its name can be almost anything. Something like FlashLightSwith will do fine. Then you have to go to the editor again. Select the entity that acts as your flashlight (note that it has to be DynamicLight or DSpotLight) and change the field TriggerName to whatever you named your trigger.

Oh... and in case you don't know much about scripting, just change the first three lines of your script to:
KEYNUMBER [29] //Add your keynumber...
ON [false]
TRIGGER_NAME [FlashLightSwitch] //Add name of trigger for the light itself
Pain is only psychological.
incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 »

I did exactly as you said and Im afraid it is still not working. Good try though. The way it is written makes sense. Just didnt work is all.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.
User avatar
bernie
RF Moderator
Posts: 1249
Joined: Tue Nov 15, 2005 10:07 am
Location: Ireland

Post by bernie »

That script does not work for rf 0,75 you need to change

if(GetAttribute("flashlight")=1) //Check if player has flashlight

to

if(GetAttribute("flashlight","player")=1) //Check if player has flashlight

it will then work fine
the GetAttribute command changed in rf 0.75 and now needs 2 parameters not one as before.
I would also change it to read

if(GetAttribute("flashlight","player")>0) //Check if player has flashlight

so that it works if the player has more that one flashlight too, instead of exactly one.
incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 »

Im sorry to say that the method that you outlined did not work. It did however give valuable info on rf75.

Thank you.

Im still looking to make the flashlight work so that it can be turned on and off.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.
User avatar
bernie
RF Moderator
Posts: 1249
Joined: Tue Nov 15, 2005 10:07 am
Location: Ireland

Post by bernie »

Erm just a thought. You did set the flashlight attribute in player.ini didn't you?

[flashlight]
initial = 1
low = 0
high = 1

as opposed to

[light]
initial = 1
low = 0
high = 1
incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 »

bernie,

player.ini has the following entry:

[flashlight]
initial = 1
low = 0
high = 1


Rmemeber that I said that I can get it to work with one script but when I change to the other it doesnt work. That means that the proper entry has to be in the player.ini .

Thanks for the attention to detail though.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

You should also change
PositionToPlayer(0, 30, 10, true);
to
PositionToPlayer(0, 30, 10, true, false);
incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 »

I did that and there is no change. Keep the ideas coming. Glad to get the input.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.
Post Reply