Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

General Script Questions #1


WillieSea
 Share

Recommended Posts

IS - this is off-the-OBSE-topic: Could you explain for us the general use of 'apple' in scripts? Is it to guard against bloat?

Here's a script. It's not mine:

SCN AASideLightBabylonLampScript

ref nextitem

BEGIN OnActivate

set nextitem to apple
set nextitem to GetFirstRef 26
while ( nextitem )
if ( GetDistance nextitem < 24 )
if ( nextitem.GetDisabled )
nextitem.enable
else
nextitem.disable
endif
endif
set nextitem to GetNextRef
loop

END[/code]

AFAIK this script checks for lights nearby, then enables a disabled one and disables an enabled one. Making it light up, I imagine. The apple use here, though, is kinda confusing to me. I've never dabbled in using 'apple'. Any help is wonderfully appreciated, by both myself, and my seldom-harsh mistress...:)

Link to comment
Share on other sites

Too bad I´m using the 0018 Beta because of the Oblivion XP Mod, the 0018 version which requires it. Is there not any other workaround? :)

I am unsure at this moment in time :no:

IS - this is off-the-OBSE-topic: Could you explain for us the general use of 'apple' in scripts? Is it to guard against bloat?

Apple is used when user the GetNextRef, I cannot recall 100% why its used but I know its to assign a reference for the Function to pick up on before it does its job. IIRC without it the function does not work correctly.

I will look up the exact reason why its used, but thats a general reason why :)

Edit: OK the OBSE documentation does not mention using Apples as the first reference when using a Ref Walking function, but it did say that the GetNextRef function has to be called first, hence the use of Apple :)

Link to comment
Share on other sites

No sweat IS keep yer plate as clean as you can. As long as it's necessary I'll trust you. :) Just that 'apple' = bloat protection for me ( from something I read years ago ), and I couldn't understand what would bloat a save with this script. But as you say it's function helper, I'm good with it. :)

Link to comment
Share on other sites

No sweat IS keep yer plate as clean as you can. As long as it's necessary I'll trust you. :no: Just that 'apple' = bloat protection for me ( from something I read years ago ), and I couldn't understand what would bloat a save with this script. But as you say it's function helper, I'm good with it. :)

Actually there is nothing in the Script that jumps out at me as a bloat causing function. Looks very clean :)

Link to comment
Share on other sites

Apple is used when user the GetNextRef, I cannot recall 100% why its used but I know its to assign a reference for the Function to pick up on before it does its job. IIRC without it the function does not work correctly.

I will look up the exact reason why its used, but thats a general reason why :candle:

Edit: OK the OBSE documentation does not mention using Apples as the first reference when using a Ref Walking function, but it did say that the GetNextRef function has to be called first, hence the use of Apple :P

The apple bug has been squished as of OBSE v17. It was used to re-initialize reference variables when they were to store formIDs of unexpected records ( like doors and lights ). It isn't connected, to my knowledge, to bloat.
Link to comment
Share on other sites

The apple bug has been squished as of OBSE v17. It was used to re-initialize reference variables when they were to store formIDs of unexpected records ( like doors and lights ). It isn't connected, to my knowledge, to bloat.

Lovely :P, though I am sure there was mention of this bug not too long ago, maybe I read wrong. Doesnt matter, thanks for clearing that up Shade :clap:

Link to comment
Share on other sites

The apple bug has been squished as of OBSE v17. It was used to re-initialize reference variables when they were to store formIDs of unexpected records ( like doors and lights ). It isn't connected, to my knowledge, to bloat.

Operating with a faulty memory...I could have sworn I read something about apple and bloat, but could find nothing yesterday when I went looking. Does the squishing of the bug mean that there's no need for the use of apple now?

Thanks Shade

Link to comment
Share on other sites

Looks like you all have this thread well in hand.

One note on OBSE, I cannot answer any questions on that topic since I do not use it. Just wanted to 'remind' everyone of that! :rofl:

You are welcome to discuss it if you like, I just will not be able to respond on that subject.

Per the first post in this thread:

1. Use this thread to ask question about scripts.

2. Use this thread to request classes on scripting topics.

3. Use this thread to ask if something you want to do can be scripted.

4. Just need to say something about anything, use this thread.

NOTE: Only vanilla scripts are discussed in this forum. I do not code using OBSE.

Link to comment
Share on other sites

  • 4 weeks later...

Trying to make a random playsound music script since streammusic function is so buggy. Could someone please check over script?

Thanks :D Oh, the second half of the playsound script, I want it to play the sound only if the playsound in the worldspace above has been played and the player has just moved inside the house. Thought it would be kinda immersion breaking if the sound was going outside and no party inside :thumbup:

Scn DiannePartyMusic


Short GameDaysPassed

Short GetRandomPercent

Short PlaySound


if ( GameDaysPassed == 3 )

     if ( GetRandomPercent <= 40 )

     if ( GetInWorldSpace AnvilWorld == 1 )

     PlaySound aaAnvilPartyHouseSoundOutside == 1

else

     if ( GetInWorldSpace AnvilWorld == 0 )

     Playsound aaAnvilPartyHouseSoundOutside == 0

elseif 

     if ( GetRandomPercent >= 60 )

     if ( GetInWorldSpace AnvilWorld == 1 )

     Playsound aaAnvilPartyHouseSoundOutside == 0

else 

     if ( GetInWorldSpace AnvilWorld == 0

     PlaySound aaAnvilPartyHouseSoundOutside == 0


if ( Playsound aaAnvilPartyHouseSoundOutside == 1 )

     if ( GetInCell aadiaAnvilPartyHouse, aadiaAnvilPartyHouseSecondFloor == 1 )

     PlaySound aaAnvilPartyHouseSoundInterior01 == 1

else 

     if ( PlaySound aaAnvilPartyHouseSoundOutside == 0 )

     if ( GetInCell aadiaAnvilPartyHouse, aadiaAnvilPartyHouseSecondFloor == 0 )

     PlaySound aaAnvilPartyHouseSoundInterior01 == 0



Link to comment
Share on other sites

Trying to make a random playsound music script since streammusic function is so buggy. Could someone please check over script?

Thanks :D Oh, the second half of the playsound script, I want it to play the sound only if the playsound in the worldspace above has been played and the player has just moved inside the house. Thought it would be kinda immersion breaking if the sound was going outside and no party inside :thumbup:

try this:

Scn DiannePartyMusic


Short GameDaysPassed

Short GetRandomPercent

Short PlaySound

short timer


Begin GameMode

If timer < 10 ; 10 seconds, change to whatever you want...

set timer to (timer + getsecondspassed)

return

Endif


if ( GameDaysPassed == 3 )

     if ( GetRandomPercent <= 40 )

          if ( GetInWorldSpace AnvilWorld == 1 )

               PlaySound aaAnvilPartyHouseSoundOutside == 1

          else

               Playsound aaAnvilPartyHouseSoundOutside == 0

          endif

     elseif ( GetRandomPercent >= 60 )

          if ( GetInWorldSpace AnvilWorld == 1 )

               Playsound aaAnvilPartyHouseSoundOutside == 0

          else 

               PlaySound aaAnvilPartyHouseSoundOutside == 0

          endif

     endif


     if ( Playsound aaAnvilPartyHouseSoundOutside == 1 )

          if ( GetInCell aadiaAnvilPartyHouse, aadiaAnvilPartyHouseSecondFloor == 1 )

               PlaySound aaAnvilPartyHouseSoundInterior01 == 1

          endif

     else 

         if ( GetInCell aadiaAnvilPartyHouse, aadiaAnvilPartyHouseSecondFloor == 0 )

               PlaySound aaAnvilPartyHouseSoundInterior01 == 0

          endif

     endif

     set doOnce to 1

endif

end

I think that is what you are wanting.

Pacific Morrowind

Link to comment
Share on other sites

1. PlaySound is not a function that returns a value.

     if ( Playsound aaAnvilPartyHouseSoundOutside == 1 )
2. Using GetRandomPercent has the chance to return a different value each time its called. Unless you want that, you need to set it to a variable at the start and use the variable in the IF statements.
     if ( GetRandomPercent <= 40 )
     elseif ( GetRandomPercent >= 60 )

Link to comment
Share on other sites

Can this be done? Sort of. Well, not really but there are a few work arounds:

A. You change the color of the frost enchantment. DONT DO IT! laugh.gif Unless you want it for yourself, because it will change the color of all frost enchantments in the game. This is the easiest way, but least useful.

B. Use OBSE's functions:

SetMagicEffectEnchantShader

SetMagicEffectEnchantShaderC

You will have to set the Frost Damage shader to yours, and this can get quite annoying as you will have to set it to red and then set it back to white when the player sheathes the weapon. This is because you are changing the all of the frost enchant shaders in the game, not just your weapon, and it would be best to have it red only for the time the player has the weapon out.

This is about the best way to do it that I can think of. Every other way is too ridiculously difficult or just won't work right. Having magic functions hard-codded in this game really annoys me, but we do our best to work around it...

C. Turn the whole player red. Use "Player.PlayMagicShaderVisuals" to make the player turn red when the player equips the weapon.

Hope this helps :lmao:

Link to comment
Share on other sites

1. PlaySound is not a function that returns a value.

     if ( Playsound aaAnvilPartyHouseSoundOutside == 1 )
2. Using GetRandomPercent has the chance to return a different value each time its called. Unless you want that, you need to set it to a variable at the start and use the variable in the IF statements.
     if ( GetRandomPercent <= 40 )
     elseif ( GetRandomPercent >= 60 )
I don't understand your meaning, but is this what you mean?
Scn DiannePartyMusic 


Short GameDaysPassed 

Short GetRandomPercent 

Short PlaySound 

short timer 


Begin GameMode 

If timer < 10 ; 10 seconds, change to whatever you want... 

set timer to (timer + getsecondspassed) 

return 

Endif 


if ( GameDaysPassed == 3 ) 

     if ( GetRandomPercent <= 40 ) 

          if ( GetInWorldSpace AnvilWorld == 1 ) 

          if ( Playsound aaAnvilPartyHouseSoundOutside == 1 )

          else 

                if ( Playsound aaAnvilPartyHouseSoundOutside == 0 )

          endif 

     elseif ( GetRandomPercent >= 60 ) 

          if ( GetInWorldSpace AnvilWorld == 1 ) 

          if ( Playsound aaAnvilPartyHouseSoundOutside == 0 )

          else  

          if ( Playsound aaAnvilPartyHouseSoundOutside == 0 )   

          endif 

     endif 


     if ( Playsound aaAnvilPartyHouseSoundOutside == 1 ) 

          if ( GetInCell aadiaAnvilPartyHouse, aadiaAnvilPartyHouseSecondFloor == 1 ) 

             if ( Playsound aaAnvilPartyHouseSoundOutside == 1 ) 

          endif 

     else  

         if ( GetInCell aadiaAnvilPartyHouse, aadiaAnvilPartyHouseSecondFloor == 0 ) 

              if ( Playsound aaAnvilPartyHouseSoundOutside == 0 )

          endif 

     endif 

     set doOnce to 1 

endif 

end

:)

Link to comment
Share on other sites

okay forgot a few things (thanks WillieSea for pointing some out) so actually try this

Scn DiannePartyMusic


Short GameDaysPassed

Short GetRandomPercent

short timer

short rand

short musiconoutside


Begin GameMode

If timer < 10 ; 10 seconds, change to whatever you want...

set timer to (timer + getsecondspassed)

return

Endif


if ( GameDaysPassed == 3 )

set rand to GetRandomPercent

     if ( rand <= 40 )

          if ( GetInWorldSpace AnvilWorld == 1 )

               PlaySound aaAnvilPartyHouseSoundOutside

               set musiconoutside to 1

          else

               Playsound aaAnvilPartyHouseSoundOutside 

               set musiconoutside to 1

          endif

     elseif ( rand >= 60 )

          if ( GetInWorldSpace AnvilWorld == 1 )

               Playsound aaAnvilPartyHouseSoundOutside

               set musiconoutside to 1

          else 

               PlaySound aaAnvilPartyHouseSoundOutside 

               set musiconoutside to 1

          endif

     else

          set musiconoutside to 0

     endif


     if ( musiconoutside == 1 )

          if ( GetInCell aadiaAnvilPartyHouse == 1 || GetInCell aadiaAnvilPartyHouseSecondFloor == 1 )

               PlaySound aaAnvilPartyHouseSoundInterior01

          endif

     else 

          if ( GetInCell aadiaAnvilPartyHouse == 1 && GetInCell aadiaAnvilPartyHouseSecondFloor == 1 )

               set doOnce to 1

               return

          endif

     endif

     set doOnce to 1

endif

end

Pacific Morrowind

Link to comment
Share on other sites

I don't understand your meaning, but is this what you mean?

     if ( GetRandomPercent <= 40 ) 
...
elseif ( GetRandomPercent >= 60 ) [/code] The first random percent could come back as 50 and the second as 40 making neither true. When you call the function, it gives you a NEW random number.
[code] if ( Playsound aaAnvilPartyHouseSoundOutside == 1 )

This is an invalid command. You cannot call an IF statement on a PlaySound function.

See the changes that Pacific noted above.

Link to comment
Share on other sites

  • 1 month later...

I'm trying to write an OBMM Install script and am having problems getting it to install just the

right version of the .esp I want. What I have below seems to install both versions and I'm a little

confused as to how it should be written to install only the version I want from its own subdirectory.

Can anybody help me figure out what I have wrong here as I am a little new to scripting?

Sorry if this might be in the wrong topic.

Metallicow

If VersionLessThan 1.0.0

   Message "This mod must be installed by OBMM version 1.0.0 or later to prevent script errors."

   FatalError

EndIf


AllowRunOnLines


DontInstallAnyDataFiles

DontInstallAnyPlugins


CopyPlugin "Alt Version Esp\\AltModVer1-3.esp" "AltModverV1-3.esp"

CopyPlugin "Script Version Esp\\ModVer1-3.esp" "ModVer1-3.esp"


If DialogYesNo "Do you use DarNified UI?"

	SetVar MODD 1

Else

	SetVar MODD 0

EndIf


If Equal %MODD% 1

;================================================================================== 

	SelectWithDescriptionsAndPreviews "Choose which version you want to install.","Alt Version" "Screenshots\\DarNified UI Comp.jpg" "Use with DarNified UI.","|Script Version (default)" "Screenshots\\Vanilla Comp.jpg" "Use with Vanilla UI."

		"Frames Alt Version" "Screenshots\\DarNified UI Comp.jpg" \

		"Frames Script Version" "Screenshots\\Vanilla Comp.jpg" \

		Case Name Version "Alt Version Esp\\AltModVer1-3.esp"

  			CopyPlugin "Alt Version Esp\\AltModVer1-3.esp" True 

 			Break

		Case Script Version (default) "Script Version Esp\\ModVer1-3.esp"

			CopyPlugin "Script Version Esp\\ModVer1-3.esp" True

 			Break

	EndSelect

;==================================================================================	

Else		CopyPlugin "Script Version Esp\\ModVer1-3.esp" True

;==================================================================================

EndIf

;==================================================================================

Link to comment
Share on other sites

Get rid of these 2 lines :


CopyPlugin "Alt Version Esp\\AltModVer1-3.esp" "AltModverV1-3.esp"

CopyPlugin "Script Version Esp\\ModVer1-3.esp" "ModVer1-3.esp" 
... from
DontInstallAnyDataFiles

DontInstallAnyPlugins


CopyPlugin "Alt Version Esp\\AltModVer1-3.esp" "AltModverV1-3.esp"

CopyPlugin "Script Version Esp\\ModVer1-3.esp" "ModVer1-3.esp"

Link to comment
Share on other sites

Get rid of these 2 lines :


CopyPlugin "Alt Version Esp\\AltModVer1-3.esp" "AltModverV1-3.esp"

CopyPlugin "Script Version Esp\\ModVer1-3.esp" "ModVer1-3.esp" 
... from
DontInstallAnyDataFiles

DontInstallAnyPlugins


CopyPlugin "Alt Version Esp\\AltModVer1-3.esp" "AltModverV1-3.esp"

CopyPlugin "Script Version Esp\\ModVer1-3.esp" "ModVer1-3.esp"

I tried that and now it won't install any esps. Eventually in the end, both esps will have the same name. That is why I have them separated in the two folders.

At the moment all I'm planning on is getting the right esp from it's subdirectory to install correctly. The descriptions and pic previews are working with what had written so far. I have been looking at other OMODs with install scripts and haven't had any luck finding one that does something similar. Is there another way to write this that might be simpler or do you know of an OMOD that has a similar install script that I could look at.

Link to comment
Share on other sites

I figured it out. wmj at the official forums led me in the right direction.

The esps in the subdirectorys can also have the same esp name(which was my intention since

you can't have two esps of the same name in a folder without one overwriting the other.)

This also leaves room for different(or unlimited or multiple) versions/esps to be added.

So basically this installs the default version if you press NO and an alt version if you

press YES you have a choice of either(or more)with comparison pics and descriptions.(Could

be used with SelectManyWithDescriptionsAndPreviews also).

Sorry I generalized the names of everything, but I figured if I did that, people would

understand what I was trying to achieve better.

Feel free to use this OBMM Install Script if you want for learning purposes as it can be

used for installs other than what I have used it for here.

Mooo

;**================OBMM Install Script written by Metallicow=======================

If VersionLessThan 1.0.0

   Message "This mod must be installed by OBMM version 1.0.0 or later to prevent script errors."

   FatalError

EndIf


DontInstallAnyDataFiles

DontInstallAnyPlugins


If DialogYesNo "Do you use (or plan to use) DarNified UI (or a variant thereof)?" "Question"

	SetVar MODD 1

Else

	CopyPlugin "Script Version Esp\\ModVersion.esp" "ModVersion.esp"

EndIf


If Equal %MODD% 1

;================================================================================== 

	SelectWithDescriptionsAndPreviews "Choose which version you want to install.","Name Version" "Screenshots\\DarNified UI Comparison.jpg" "Use with DarNified UI or Vanilla UI.","Script Version (default)" "Screenshots\\DarNified UI Comparison.jpg" "Use with DarNified UI or Vanilla UI"

		"Frames Name Version" "Screenshots\\DarNified UI Comparison.jpg" \

		"Frames Script Version" "Screenshots\\DarNified UI Comparison.jpg" \

		Case Name Version

  			CopyPlugin "Name Version Esp\\AltVersion.esp" "AltVersion.esp"

 			Break

		Case Script Version (default)

			CopyPlugin "Script Version Esp\\ModVersion.esp" "ModVersion.esp"

 			Break

	EndSelect

;==================================================================================     


EndIf

;==================================================================================

Link to comment
Share on other sites

Is there a reversed version of the function GetParentRef?

In this example the target is named the parentRef and then disabled:


set target to getParentRef
target.disable
[/code]

What I need though is a way to disable the childRef when the parentref is added to the player's inventory. Is it possible?

Link to comment
Share on other sites

Is there a reversed version of the function GetParentRef?

In this example the target is named the parentRef and then disabled:


set target to getParentRef
target.disable
[/code]

What I need though is a way to disable the childRef when the parentref is added to the player's inventory. Is it possible?

Need some more information.

Where is the script? On what object? Is it on the object that is the child?

You can use GetSelf to get the reference name of the child, assuming the script is running on the child.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...