Jump to content

Photo

Help with a simple script


  • Please log in to reply
16 replies to this topic

#11
tunaisafish

tunaisafish

    Old hand

  • Supporter
  • PipPipPip
  • 641 posts

I didn't want to do this because one of you may be the future player of my mod and that would spoil all the feature... :biggrin:


I'd say that most of the people here that read these threads in detail probably spend more time modding and testing than actually playing the game.
My poor character has been living a ground-hog day for the last few months.
By the time I get to play again I'll probably have forgotten how to shoot a weapon, let alone the details of all the mods I have installed waiting to be explored ;)

So I placed the both objects (switch+waterfall) to my cell and set the following options:
For the waterfall I gave it a unique reference ID (pump) and checked the "Persistent Reference".
For the switch I checked "Open By Deafault", attached the script and connected it with the waterfall by the "Enable Parent" option.


Yep as Stevie states, the enable parent is the only thing you did wrong. Remove that and choose your waterfall object in the 'Linked Ref' tab and all should be well.

#12
Andyno

Andyno

    Enthusiast

  • Members
  • PipPip
  • 190 posts
Of course I read it. But as you may already know now, I'm too stupid for the scripting. You can notice that if you look at my script - I even didn't realize that "ref pump" is something different than the rest of "if pump == 0", "set pump to GetLinkedRef", "if pump.GetDisabled", etc... :ohmy:

Anyway... I choose your last script (it's most simple and the best for me I think) and it works! It's really wonderful to know that many things can be solved by many options...

Thanks for everything mate. :thumbsup:

#13
tunaisafish

tunaisafish

    Old hand

  • Supporter
  • PipPipPip
  • 641 posts

and for the script,

ScriptName BLPumpScript

ref pump

Begin OnActivate
	if pump == 0
		set pump to GetLinkedRef
	endif                                          
i assume pump == 0 means the pump is not there and 1 is there?
so what's the if for, you'll need the linked ref anyway to check it's state
wouldn't do anything anyway, because you ask if pump is a numeric value (0), but you have pump set as a reference variable, that returns a string (the id of the linked object)


When a reference variable has not been set, then it has the value '0', so there's nothing wrong with that. You can also use 'set rMyRef to 0' to clear it if needed.

and i don't know if it's a good idea to give a ref-variable ("pump") exactly the same name the reference it asks for has ("pump" as well).
most people seem to tend to call their object references like objectREF, not necessary, but makes orientation easier.


Yep, well spotted :) I hadn't noticed that.

The objects that have REF appended are ususally persistent references. Bethesda/Obsidian use this practice too.

In scripts, I tend to precede my variable names with a letter depending on the type.

int iMyNumericValue
float fMyPrecisionNumber
ref rMyObject

BTW, yep there was nothing wrong with your revised script, but there was nothing wrong with the original either.
Both would work.
The light script from the Useful Scripts page has the advantage that the same script can be used with multiple switches. And by using the Xmarker (or someother object) as an enable parent then the same script can control multiple objects.

#14
rjhelms84

rjhelms84

    The Beyond Team

  • Supporter
  • PipPipPipPip
  • 1,219 posts
Place your (Activator) switch and place your object you want to disappear and reappear. Name that object and mark it as Persistent Reference. (You don't need to link anything or make anything a parent or any of that.)

Then use this script in the Activator:

short OnOffValue

begin onactivate player

if OnOffValue == 0
set OnOffValue to 1
elseif OnOffValue == 1
set OnOffValue to 0
endif

end

begin gamemode

if OnOffValue == 0
ObjectREF.enable
elseif OnOffValue == 1
ObjectREF.disable
endif

end

Edited by rjhelms84, 26 May 2011 - 06:32 PM.


#15
tunaisafish

tunaisafish

    Old hand

  • Supporter
  • PipPipPip
  • 641 posts
@rjhelms84, it's better to avoid gamemode blocks in object scripts where possible.
Take a look at Stevie's script posted before for a more elegant solution (and the one already adopted by Andyno)

#16
rjhelms84

rjhelms84

    The Beyond Team

  • Supporter
  • PipPipPipPip
  • 1,219 posts

@rjhelms84, it's better to avoid gamemode blocks in object scripts where possible.
Take a look at Stevie's script posted before for a more elegant solution (and the one already adopted by Andyno)


lol, good point.

#17
Andyno

Andyno

    Enthusiast

  • Members
  • PipPip
  • 190 posts
Hi there again.
I'm not going to start the new topic for my new problem because it would have the same title...

Now I'm trying to make some trigger that triggers a certain sound. I was trying that with the Enable Parent feature but I think it's not working because it requires some script... :rolleyes:

Please help somebody, if you have experience with the sound triggers.




Page loaded in: 1.112 seconds