Page 1 of 1

Details on getting flashlight to work

Posted: Mon Mar 20, 2006 4:07 pm
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.

Posted: Mon Mar 20, 2006 4:39 pm
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

Posted: Mon Mar 20, 2006 6:47 pm
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?

Posted: Mon Mar 20, 2006 6:53 pm
by AndyCR

Posted: Mon Mar 20, 2006 9:23 pm
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.

Posted: Tue Mar 21, 2006 1:50 am
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.

Posted: Wed Mar 22, 2006 4:54 pm
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.

Posted: Wed Mar 22, 2006 5:21 pm
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

Posted: Wed Mar 22, 2006 5:35 pm
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.

Posted: Wed Mar 22, 2006 6:11 pm
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.

Posted: Wed Mar 22, 2006 6:32 pm
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.

Posted: Wed Mar 22, 2006 7:57 pm
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

Posted: Thu Mar 23, 2006 6:21 pm
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.

Posted: Fri Mar 24, 2006 9:04 am
by QuestOfDreams
You should also change
PositionToPlayer(0, 30, 10, true);
to
PositionToPlayer(0, 30, 10, true, false);

Posted: Fri Mar 24, 2006 5:31 pm
by incenseman2003
I did that and there is no change. Keep the ideas coming. Glad to get the input.