Jump to content

Script Help


stealthtank91

Recommended Posts

Hello everyone,

i was having trouble finding anything on the subject of animating a object through a script so i had to start a topic here, hopefully this is the right place to post.

 

Basically i made a script where there are 5 switches, 3 of them use the electricalswitch02 base, and the other 2 use electricalswitch01 base. the script basically fires when all switches are activated which i tracked this with an individual "short" variable for each. i added the script to each switch, but now, when any of the switches are activated ingame, they dont play the animation they are suppose to by default ( like the little lever that goes down), or the red light turning into the green light for electricalswitch01. is there a function that can run this animation when activated upon? i was thinking playidle, but idk how to go about it. Here is the actual script:

 

 

scn aaaSTBunkerCityCell4fRelayScript1

 

short aaaSTBunkerCityCell4fRelayShrt1

short aaaSTBunkerCityCell4fRelayShrt2

short aaaSTBunkerCityCell4fRelayShrt3

short aaaSTBunkerCityCell4fRelayShrt4

short aaaSTBunkerCityCell4fRelayShrt5

int aaaSTBunkerCityCell4fRelayInt1

 

begin gamemode

if aaaSTBunkerCityCell4fRelayShrt1 == 1 && aaaSTBunkerCityCell4fRelayShrt2 == 1 && aaaSTBunkerCityCell4fRelayShrt3 == 1 && aaaSTBunkerCityCell4fRelayShrt4 == 1 && aaaSTBunkerCityCell4fRelayShrt5 == 1

PlaySound OBJBuzzerBell

endif

end

 

begin onactivate player

if GetIsReference aaaSTCell4fRlSwch1Ref == 1

set aaaSTBunkerCityCell4fRelayShrt1 to 1

elseif GetIsReference aaaSTCell4fRlSwch2Ref == 1

set aaaSTBunkerCityCell4fRelayShrt2 to 1

elseif GetIsReference aaaSTCell4fRlSwch3Ref == 1

set aaaSTBunkerCityCell4fRelayShrt3 to 1

elseif GetIsReference aaaSTCell4fRlSwch4Ref == 1

set aaaSTBunkerCityCell4fRelayShrt4 to 1

elseif GetIsReference aaaSTCell4fRlSwch5Ref == 1

set aaaSTBunkerCityCell4fRelayShrt5 to 1

endif

end

 

 

 

sry for the long variables, i like to be specific :P

Link to comment
Share on other sites

SetOpenState 1

Makes the light turn green. Probably works for the lever switch too.

 

k it worked, thx a lot, for some reason, i tried using this function before but it didnt work. but hey, it worked this time

Edited by stealthtank91
Link to comment
Share on other sites

you should use playgroup... don't get me wrong, i'm sure setopenstate works

but... openstate is ment for doors, which should never override animations, I've had animation bugs (animation resets) using setopenstate

playgroup allows you to specify how the animation begins relative to active animations.

 

e.g. a radio activator script to animate a vertibird landing: using Mq05VertibirdLand (MSTT) , which is ref (VertiBirdDyna)

 

scn VertiRadioScript

short isAct
Begin OnActivate
if isAct == 0
VertiBirdDyna.PlayGroup Forward 0
set isAct to 1
else
if isAct == 1
VertiBirdDyna.Playgroup Backward 0
set isAct to 0
endif
endif
end

in the above example, using 1 instead of 0 would force the vertibird into the takeoff animation before the landing animation finishes if the activator is activated twice in succession.

 

when you preivew a activator, etc. you will see the various "states", with their titles.

things like the vertibird encounter have several (forward, idle, backward, fast forward, etc.) , and you may have to actually preview them ingame (GECK is iffy..)

 

0/1/2 determines how the play is started, wether it immediately overrides the current animation and starts or not..

0 = normal start, 1=immediate start, 2=immediate start and loop..

 

http://geck.bethsoft.com/index.php/PlayGroup

http://geck.bethsoft.com/index.php/AnimGroups

Edited by xab666
Link to comment
Share on other sites

thx, xab666, that seems like it would work, ill give it a shot, but for the switches, do you think it would be "forward" and "backward" ? the vertibird example made sense, but idk if it is the same for a switch, is there any way to find out what animations an object has to choose from?
Link to comment
Share on other sites

thx, xab666, that seems like it would work, ill give it a shot, but for the switches, do you think it would be "forward" and "backward" ? the vertibird example made sense, but idk if it is the same for a switch, is there any way to find out what animations an object has to choose from?

 

the animation groups are in the preview window

should be open and close.

 

 

OK

so i saw this post yesterday and replied but then saw you had your solution and removed my reply. but its been buggin me because the solution discussed here could not have made this script work.... it may have forced the animation (necessary if your script needs to know and control the exact state of the switch but not here)

 

so now after implementing your script and testing i see my suspicions are confirmed so i am going to repost my post from yesterday now here:

 

 

 

 

 

 

your onactivate block is lacking a "activate"

pretty sure it still needs the command to activate because an onactivate block replaces the default onactivate function with whatever you script so it needs to be told to activate somewhere in there in order to do so. (tested this morning, it works, all you need is 'activate' to get them to animate)

 

also by applying this script to separate references, each is going to hold its own variables so you need to point to which variable from which script you need.

 

if you are updating an existing script ignore this next paragraph, if however you are attempting to save it for the first time this is very important:

*note geck will not allow you to save this script until its saved... i know that sounds ridiculous but its true.. in order to save geck is going to try to make sure those variables exist in those scripts.. but seeing how your trying to save the script its checking it wont find them. what you have to do is comment out the contents of the gamemode block (which is whats causing it to check for those variables) by adding semicolons to the beginning of each line in it, save the script then open the script back up an remove the semicolons on the gamemode block and save again be sure the ref names are set up on the switches though otherwise itll still not save.

 

 

 

try:

 

 

scn aaaSTBunkerCityCell4fRelayScript1

short aaaSTBunkerCityCell4fRelayShrt1
short aaaSTBunkerCityCell4fRelayShrt2
short aaaSTBunkerCityCell4fRelayShrt3
short aaaSTBunkerCityCell4fRelayShrt4
short aaaSTBunkerCityCell4fRelayShrt5
int aaaSTBunkerCityCell4fRelayInt1

begin gamemode
if aaaSTCell4fRlSwch1Ref.aaaSTBunkerCityCell4fRelayShrt1 && aaaSTCell4fRlSwch2Ref.aaaSTBunkerCityCell4fRelayShrt2 && aaaSTCell4fRlSwch3Ref.aaaSTBunkerCityCell4fRelayShrt3 && aaaSTCell4fRlSwch4Ref.aaaSTBunkerCityCell4fRelayShrt4 && aaaSTCell4fRlSwch5Ref.aaaSTBunkerCityCell4fRelayShrt5
	PlaySound3D OBJBuzzerBell ; see the note at the bottom about this line
endif
end

begin onactivate player
if GetIsReference aaaSTCell4fRlSwch1Ref == 1
	set aaaSTBunkerCityCell4fRelayShrt1 to 1
elseif GetIsReference aaaSTCell4fRlSwch2Ref == 1
	set aaaSTBunkerCityCell4fRelayShrt2 to 1
elseif GetIsReference aaaSTCell4fRlSwch3Ref == 1
	set aaaSTBunkerCityCell4fRelayShrt3 to 1
elseif GetIsReference aaaSTCell4fRlSwch4Ref == 1
	set aaaSTBunkerCityCell4fRelayShrt4 to 1
elseif GetIsReference aaaSTCell4fRlSwch5Ref == 1
	set aaaSTBunkerCityCell4fRelayShrt5 to 1
endif
ACTIVATE
end

 

 

*EDIT*

1 more thing i just saw, the playsound command will probably not work because it is not an ambient sound and therfore you must play it from a reference. so you can put playsound3d like i did up there. but this is going to play the sound from the switch.. so i would suggest adding an alarm reference and playing the sound from there by using: yourREFhere.Playsound3d OBJBuzzerBell

 

 

i tested this ingame.. it for sure works.

if you have problems let me know ill try to help.

 

BTW you realize the buzzer sound is on loop? you intend for it to play forever?

if not i have a really easy solution for you.. drag the sound itself into the world editor and assign it a reference name and set it persistent. then instead of calling playsound on that sound simply use 'yourSoundRefNameHere.enable' or 'yourSoundRefNameHere.disable' on the reference to control whether or not its playing. remember to set the reference to initially disabled when setting it up though otherwise itll be wailing when it loads.

Edited by angelwraith
Link to comment
Share on other sites

the animgroups for the switch are open and close, yes.

 

using 'OnActivate' prevents normal activation, 'Activate' doesn't (http://cs.elderscrolls.com/constwiki/index.php/OnActivate)

 

I like your change from the if ref.variable == 1, to if ref.variable, checking nullity.

I take it the GECK script langauge doesn't automatically initialize variables until they're called then? thats not something i've tried. but ill have to find some excuse too :)

 

i have a question about the workings of your script (Stealthtank) the lines

...if GetIsReference aaaSTCell4fRlSwch5Ref == 1

set aaaSTBunkerCityCell4fRelayShrt5 to 1

 

 

GetisReference aaSTCell4fRlSwch5Ref returns 1 if aaaSTC... is the calling reference, so my question is, is aaaSTBunkerCityCell4fRelayScript1 the script in all your activators? (you made a new form and put that as the script?)

 

P.S. I've never used triggered sounds but I think AngelWraith may be right about not using playsound (http://geck.bethsoft.com/index.php/PlaySound) according to the GECK page, it doesn't work on ambient sounds using .ogg files

maybe PlaySound3d. it plays the sound at the calling ref location (http://geck.bethsoft.com/index.php/PlaySound3D). just a thought

Link to comment
Share on other sites

this is all very wierd, forgive me, cause im a noob at scripting myself and dont understand everything that is said in this thread, but the odd thing is, the original script i used at the the begining of this topic worked in the sense that, after using the "SetOpenState 1" command on each switch, they DID animate, the onlything was that the sound didnt play. However, i used the PlaySound OBJBuzzerBell command in a diffrent script, and there was no problem, no looping, it just plays once just like i intended it. so playsound3D would be better in that it would have a source ingame rather than being played the same loudness wherever you are - but playsound works for me too.

 

In the script i presented though, the sound doesnt play when i activate all the switches, which means im doing something wrong in the script, not the playsound command itself - because it works.

 

now im confused about about what you said

 

"I like your change from the if ref.variable == 1, to if ref.variable, checking nullity."

 

what does ref.variable do instead of ref.variable == 1? it seems my problem with scripting is mostly not knowing what the functions do exactly, and the geck webpage doesnt really help.

 

also when i wrote "if GetIsReference aaaSTCell4fRlSwch5Ref == 1" for instance, does this mean the condition is true, if the called upon reference is actually the reference? because getisid is for the object base right?

 

basically to clear it up what i want this script to do is:

when the player switches 5 of the switches to "on" position, a gamemode block should check the condition that all the switches are indeed in "on" position - upon meeting this condition, i want somthing to happen - i used playsound in my script as an example.

 

and yes, i did apply this same script to all the 5 switches, because it would be close to impossible to do this in seperate scripts unless i used a quest and queststages as external conditions, but that would just be a mess.

given this - i want the script to check which switch is being activated, so that it switches a "short" variable for each independently, and the gamemode block should just check that all the short variables of each switch are set to 1, which in turn would fire the intended action (playsound) being the example i used.

 

so, i take it that i need a ACTIVATE at the very end of the second block right before end right?

also does GetIsReference target the object that has the script by default, when otherwise not specified?

 

now i havent tried angelwraiths suggested script, so idk if it solved it, but as soon as i do, ill let yall know if there is anything else i need tweaking.

 

Thx for all the support though, i appreciate it.

Edited by stealthtank91
Link to comment
Share on other sites

I'll briefly explain some of what i was saying.

 

Functions are what you call to perform operations. e.g SetOpenState changes the "open state" of a object to what you specify.

objects have Openstates assigned to them if compatible, and this value can be checked via the function GetOpenState (though the numbers dont directly corispond).

 

variables are storage(memory) locations (pointers really). which store a number (usually - tho there are other kinds)

for example Short stores a Integer from ~(apx) -32,000 - +32,000.

 

a declaration is when something is assigned to something else

 

e.g. at the start of your scripts you declare your variables

 

short name

 

this reserves space for it (big in c)

 

Condition statements are logic statements which will make up the majority of your program/script.

 

these include if statements, which are structed as such (generally)

 

if CONDITION provided the condition is met (could be the value returned by a fuction, or JUST ITS EXISTANCE as in ref.variable mentioned before)

ACTION provided the condition is met the action is performed, (actions can be other conditions)

endif

 

References can also be used to call variables (tho this is where the GECK is a mystery to me).

 

normally references (or object period) have multiple variables in them (like location x,y,z rotation x,y,z its state, disabled/enabled, lighting etc.)

these can be retrieved by using the functions with the reference

thats how Doorname.getOpenState works - but i don't know where the GECK Library is (http://geck.bethsoft.com/index.php/Image:Fallout3commands.rar)

thats only a list..

 

on a linux box/mac if one wonders about a command simply typing 'man Command' will bring up the manual page.

(you can also compile scripts and create your own commands). theres no such convience for the GECK

 

 

 

 

anyways,.....

I tried these in GECK, AngleWraiths works, but again, the Sound Loops forever.

 

also, once started, you cannot disengage a switch to cancel the process. it only recongizes where the switch was used (not its current state)...

 

for the record. playgroup DOES NOT WORK on switch, setopenstate does though, i was wrong about that.. sry (least i clearified).

 

to cancel the buzzer, i was think ur best bet would be to declare

float ftimer

 

and play the playsound3d OBJBuzzerBell with a timer, like

 

if ftimer > 0

playsound3d OBJBuzzerBell

set ftimer to ftimer - getsecondspassed

endif

 

instead of just playing it, I'll play around with this later (tomorow, etc) (im now actually thinking of incorperating something like this)... although i've already done multi-keyed terminals, this is much more challenging...

 

so for the record; the script works, but doesn't allow you to turn off the buzzer to turn off with a switch (or at all without another line of code).

 

I doubled the switch conditions and appended the second set for a short switchXcancel

to store wether the switch had been up and then down.

 

by editing: (with decalred short SwitchXcancel)

if GetIsReference aaaSTCell4fRlSwch5Ref == 1 
   set aaaSTBunkerCityCell4fRelayShrt5 to 1

 

to

elseif GetIsReference aaaSTCell4fRlSwch5Ref == 1 && Switch5Cancel == 0
               set aaaSTBunkerCityCell4fRelayShrt5 to 1
elseif GetIsReference aaaSTCell4fRlSwch5Ref == 1 && aaaSTBunkerCityCell4fRelayShrt5 == 1
               set switch5cancel to 1
               setaaaSTBunkerCityCell4fRelayShrt5 to 0

 

 

anyways, I'll keep trying, just short on time tonight...

Edited by xab666
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...