I'm not sure how to do something (as usual)

Post » Tue May 17, 2011 10:23 am

I have made a plugin that brightens torches in caves and mines. Simple plugin. But I don't want to keep opening the CS to adjust the brightness to where I want it. So I made a batch file and told the script to run it. But I'm unsure about how to script the actual implementation.

My batch file:
Set aaaTorchBrightnessQuest.Brightness to 1292

My script:
ScriptName TorchBrightnessScriptfloat fQuestDelayTimefloat Brightnessshort Caveshort DoOnceBegin GamemodeSet fQuestDelayTime to 1RunScriptLine "Set Cave to LocationType.Type"RunBatchScript "Data\Brighter Torches.ini"If DoOnce < 3PrintC "Brighter Torches Initialized"set DoOnce to DoOnce + 1EndIfIf Cave == 2	SetLightRadius 1292 Torch02EndIfEnd


How do I implement the reading of the batch file variable into the script? Because of the nature of the "SetLightRadius" function, you have to give it a value after calling it. So, I can't put...
Set Brightness to SetLightRadius

...because it needs a value after the function. I know I could make a different batch file that says...
SetLightRadius 1292

...and leave it at that, but I don't want to do that. If I have to, I will, but I'd rather use the batch file format that everybody else uses.
User avatar
Mario Alcantar
 
Posts: 3416
Joined: Sat Aug 18, 2007 8:26 am

Post » Tue May 17, 2011 4:56 am

I have made a plugin that brightens torches in caves and mines. Simple plugin. But I don't want to keep opening the CS to adjust the brightness to where I want it. So I made a batch file and told the script to run it. But I'm unsure about how to script the actual implementation.

My batch file:
Set aaaTorchBrightnessQuest.Brightness to 1292
This one looks good. When run, it sets your Brightness variable to 1292 (assuming the quest is named aaaTorchBrightnessQuest).

My script:
RunScriptLine "Set Cave to LocationType.Type"

What are you trying to do with this line? Do you have another quest named LocationType with a variable named Type? And you need to fully qualify your local variable Cave with its quest name too, e.g. "aaaTorchBrightnessQuest.Cave".

RunBatchScript "Data\Brighter Torches.ini"

This will make the batch script being read in every time your script run, every second. That is a complete waste of game resources. Change it to:
If GetGameLoaded	RunBatchScript "Data\Brighter Torches.ini"EndIf

I will also encourage you to use "Data\Ini" as folder for ini files, it makes it less cluttered that way, and easier to find ini files, but this is subjective.

If DoOnce < 3PrintC "Brighter Torches Initialized"set DoOnce to DoOnce + 1EndIf
This seems wrong too. It will write out "Brighter Torches Initialized" three times the first time you run it, and then never again. I'd ditch the DoOnce variable completely, and just move the PrintC line up to the GetGameLoaded block, making it write the message each time you load a savegame and read the ini file.

If Cave == 2	SetLightRadius 1292 Torch02EndIfEnd
This probably works, but replace "1292" with your variable ("Brightness").

How do I implement the reading of the batch file variable into the script? Because of the nature of the "SetLightRadius" function, you have to give it a value after calling it. So, I can't put...
Set Brightness to SetLightRadius

...because it needs a value after the function. I know I could make a different batch file that says...
SetLightRadius 1292

...and leave it at that, but I don't want to do that. If I have to, I will, but I'd rather use the batch file format that everybody else uses.
The radius parameter in the SetLightRadius command can take a variable, so a change from "SetLightRadius 1292 Torch02" to "SetLightRadius Brightness Torch02" does what you want.

With all those changes, the script should be something like:
ScriptName TorchBrightnessScriptfloat fQuestDelayTimefloat Brightnessshort CaveBegin GamemodeIf GetGameLoaded	Set fQuestDelayTime to 1	RunBatchScript "Data\Ini\Brighter Torches.ini"	PrintC "Brighter Torches Initialized"EndIfRunScriptLine "Set aaaTorchBrightnessQuest.Cave to LocationType.Type"If Cave == 2	SetLightRadius Brightness Torch02EndIfEnd

User avatar
Taylrea Teodor
 
Posts: 3378
Joined: Sat Nov 18, 2006 12:20 am

Post » Tue May 17, 2011 6:37 am

What are you trying to do with this line? Do you have another quest named LocationType with a variable named Type? And you need to fully qualify your local variable Cave with its quest name too, e.g. "aaaTorchBrightnessQuest.Cave".


Yeah, I'm trying to access another variable - "Type" - from another quest script.
Why do I need to qualify that variable with "aaaTorchBrightnessQuest.Cave"? I thought that syntax was only needed if you are trying to access a variable from another script. Is that just the nature of "RunScriptLine"?
User avatar
Mario Alcantar
 
Posts: 3416
Joined: Sat Aug 18, 2007 8:26 am

Post » Tue May 17, 2011 4:30 am

Yeah, I'm trying to access another variable - "Type" - from another quest script.
Why do I need to qualify that variable with "aaaTorchBrightnessQuest.Cave"? I thought that syntax was only needed if you are trying to access a variable from another script. Is that just the nature of "RunScriptLine"?

I made a mistake in the post where I suggested that you use RunScriptLine... :facepalm:

Your line should be:
RunScriptLine "Set MyQuestName.Cave to LocationType.Type"

Also, is LocationType the actual name of the quest in the other esp? (It shoud be.)

RunScriptLine is essentially the same as you opening the console and typing the stuff between the quotes.
Getting or setting the value of specific variables from the console be formated as QuestName.Variable
User avatar
Danel
 
Posts: 3417
Joined: Tue Feb 27, 2007 8:35 pm

Post » Tue May 17, 2011 12:37 pm

I made a mistake in the post where I suggested that you use RunScriptLine... :facepalm:

Your line should be:
RunScriptLine "Set MyQuestName.Cave to LocationType.Type"

Also, is LocationType the actual name of the quest in the other esp? (It shoud be.)

RunScriptLine is essentially the same as you opening the console and typing the stuff between the quotes.
Getting or setting the value of specific variables from the console be formated as QuestName.Variable


Oh, okay. You made a mistake. Confused me when TNO said to type "questname.variable".
Everything seems to be working now, finally.
Thanks for all your help.
User avatar
Rachel Hall
 
Posts: 3396
Joined: Thu Jun 22, 2006 3:41 pm

Post » Tue May 17, 2011 3:24 am

The plugin works now. Thanks. But I'm still running into the limitation of the SetLightRadius function. The cell has to be freshly loaded for the light radius to take effect. This is fine when I am in a two - three level dungeon. But not a one level dungeon. So, I know about "PlaceAtMe"'s save game bloating. Is there a way I can limit the save game boating and still use that function?
User avatar
Krista Belle Davis
 
Posts: 3405
Joined: Tue Aug 22, 2006 3:00 am

Post » Tue May 17, 2011 7:33 am

Bump.
User avatar
April
 
Posts: 3479
Joined: Tue Jun 20, 2006 1:33 am

Post » Tue May 17, 2011 2:09 pm

So, I know about "PlaceAtMe"'s save game bloating. Is there a way I can limit the save game boating and still use that function.

Yes. You must:

1. Disable the placeatme'd torch: torch.Disable
2. Check that it is registered as deleted by the game (may take a couple of frames): if torch.GetDisabled...
3. When it has been disabled, delete it: torch.DeleteReference
User avatar
Sarah Unwin
 
Posts: 3413
Joined: Tue Aug 01, 2006 10:31 pm

Post » Tue May 17, 2011 3:55 am

Thanks again, TNO. Does this look right?

ScriptName TorchBrightnessScriptfloat fQuestDelayTimefloat Brightnessfloat Brightness05float Brightness06short Caveref TorchBegin GamemodeIf GetGameLoaded	Set fQuestDelayTime to 1	RunBatchScript "Data\Brighter Torches.ini"	PrintC "Brighter Torches Initialized"EndIfRunScriptLine "Set aaaTorchBrightnessQuest.Cave to LocationType.Type"If Cave == 2	Set Torch to Player.PlaceAtMe Torch02		Torch.Disable		Torch.Enable	SetLightRadius Brightness Torch02	SetLightRadius Brightness05 Torch05	SetlightRadius Brightness06 torch06	Torch.Disable	Torch.DeleteReferenceEndIfEnd

User avatar
Felix Walde
 
Posts: 3333
Joined: Sat Jun 02, 2007 4:50 pm

Post » Tue May 17, 2011 3:55 pm

Thanks again, TNO. Does this look right?

Not really ... ;)

One thing is what you're trying to do with your placeAtMe, etc., which looks weird, but that's not really anything I know much about. But the other thing is that you've just ignored step 2 in my previous post. When doing it in one frame like you do, the torch is certainly not yet disabled by the engine, and therefore the deletion will fail.
User avatar
lolly13
 
Posts: 3349
Joined: Tue Jul 25, 2006 11:36 am

Post » Tue May 17, 2011 2:13 pm

Alrighty then, TNO. How's this look? Thanks a lot for your help, by the way.
ScriptName TorchBrightnessScriptfloat fQuestDelayTimefloat Brightnessfloat Brightness05float Brightness06short Caveref TorchBegin GamemodeIf GetGameLoaded	Set fQuestDelayTime to 1	RunBatchScript "Data\Brighter Torches.ini"	PrintC "Brighter Torches Initialized"EndIfRunScriptLine "Set aaaTorchBrightnessQuest.Cave to LocationType.Type"If Cave == 2	Set Torch to Player.PlaceAtMe Torch02	Torch.Disable		If Torch.GetDisabled == 1			Torch.Enable		EndIf	SetLightRadius Brightness Torch02	SetLightRadius Brightness05 Torch05	SetlightRadius Brightness06 torch06	Torch.Disable	If Torch.GetDisabled == 1		Torch.DeleteReference	EndIfEndIfEnd


?
User avatar
Jason Wolf
 
Posts: 3390
Joined: Sun Jun 17, 2007 7:30 am


Return to IV - Oblivion