Could a master scripter review this script, please?

Post » Tue May 17, 2011 11:06 am

ref cellref itemref Torchshort cavecountshort typeshort typecountshort oblivioncountbegin gamemodeif(cell != player.getparentcell)		set cell to player.getparentcell	set type to 0	set typecount to 0	set cavecount  to 0	set oblivioncount to 0	set Torch to Torch02		set item to getfirstref 28	label 10	if item		set oblivioncount to oblivioncount + item.comparemodelpath "Oblivion" 		if(item.comparemodelpath "Cave" || item.comparemodelpath "Mine")			set cavecount to cavecount + 1		endif		set item to apple		set item to getnextref		goto 10	endif	if(cavecount > typecount)		set type to 2		set typecount to cavecount	endif	if (typecount == 0)		set typecount to 1	endif	if (type == 2)	Torch.disable	Torch.enable	Torch.SetLightRadius 1728	endifendifend

User avatar
Nicole Mark
 
Posts: 3384
Joined: Wed Apr 25, 2007 7:33 pm

Post » Tue May 17, 2011 12:05 am

Might be a good idea to indicate what it's supposed to do and what it's actually doing. I am assuming it's supposed to detect when the player is in a cave or mine and make the area become lit by a torch. Main problem: Torch02 is a base object, not a reference, so it doesn't exist anywhere in the gameworld and can't be enabled or disabled. If this doesn't help, explain what you're trying to accomplish.
User avatar
Bethany Watkin
 
Posts: 3445
Joined: Sun Jul 23, 2006 4:13 pm

Post » Tue May 17, 2011 1:32 pm

Yeah, you are right. It's supposed to detect if a player is in a cave or mine, and increase the torch light radius because with the combination of mods I use, caves and mines are real dark.
User avatar
Jhenna lee Lizama
 
Posts: 3344
Joined: Wed Jun 06, 2007 5:39 am

Post » Tue May 17, 2011 12:54 am

This is the whole script, scruggsy. What I posted earlier is what I added. The script addition that I made isn't running. I tested it with the "PrintC" function at two points and it isn't running. Any ideas why?

scn droptorchMalonn; optimized & modified by dev_akm to block torch messageref cellref itemref Torchshort weapshort cavecountshort typeshort typecountshort oblivioncountbegin menumode 1	if (player.getitemcount torch05 > 0)		Message " "		Message " "		player.removeitem torch05 1	endifendbegin menumode 1008	if (player.getitemcount torch05 > 0)		Message " "		Message " "		player.removeitem torch05 1	endifendbegin gamemode	if TorchRetrieveMalonn		set TorchRetrieveMalonn to 0	endif	if (Player.IsWeaponOut != 1)		Return	else		if (player.getEquipped torch02)			if player.isshieldout				Message " "				Message " "				Player.additem torch06 1				Player.equipitem torch06				Player.Drop torch06 1				Player.RemoveItem Torch02 1			elseif (player.GetWeaponAnimType > 1)				Message " "				Message " "				Player.additem torch06 1				Player.equipitem torch06				Player.Drop torch06 1				Player.RemoveItem Torch02 1			endif		endif	endifif(cell != player.getparentcell)	printc "running"		set cell to player.getparentcell	set type to 0	set typecount to 0	set cavecount  to 0	set oblivioncount to 0	set Torch to Torch02		set item to getfirstref 28	label 10	if item		set oblivioncount to oblivioncount + item.comparemodelpath "Oblivion" 		if(item.comparemodelpath "Cave" || item.comparemodelpath "Mine")			set cavecount to cavecount + 1		endif		set item to apple		set item to getnextref		goto 10	endif	if(cavecount > typecount)		set type to 2		set typecount to cavecount	endif	if (typecount == 0)		set typecount to 1	endif	if (type == 2)	Torch.SetLightRadius 2592	PrintC "Cave"	endifendifend

User avatar
Robert Garcia
 
Posts: 3323
Joined: Thu Oct 11, 2007 5:26 pm

Post » Tue May 17, 2011 3:20 am

I've changed the script to make it much simpler. It still doesn't work. The script references a variable set in another esp. Is that why it's not working? Because you can't call a variable from an esp? Dropping lit torches works fine. This is all I've added to it:

if LocationType.Type == 2	Torch02.SetLightRadius 2592	PrintC "Cave"endif


It doesn't work though.
User avatar
Kortknee Bell
 
Posts: 3345
Joined: Tue Jan 30, 2007 5:05 pm

Post » Tue May 17, 2011 3:40 am

Alright, this is what I have now, but it doesn't work.

RunScriptLine "set Cave to LocationType.Type"if Cave == 2	Torch02.SetLightRadius 2592endif


According to the CS Wiki, "SetLightRadius" will only work when a cell has been loaded, or by disabling and enabling the reference. Scruggsy said that a torch is a base object, not a reference, so how do I disable it?
User avatar
Bee Baby
 
Posts: 3450
Joined: Sun Jun 18, 2006 4:47 am

Post » Tue May 17, 2011 9:41 am

Ok I see - you want to increase the radius of all torches when the player is in a cave.
The script is choking on this line:
Torch02.setlightradius 2592

Torch02 is a base object, not a reference. The thing on the left of the dot must be a reference; if it's not, the game will stop executing your script. Use this instead:
setlightradius 2592 torch02

This is a common idiom with OBSE commands - you can either call the command on a reference, which will apply the command to that ref's base object, or you can pass a base object as the final argument.
User avatar
Kirsty Collins
 
Posts: 3441
Joined: Tue Sep 19, 2006 11:54 pm

Post » Tue May 17, 2011 4:13 am

Yes! It works now. Thanks you, scruggsy. Another question: can I use the "RunBatchScript" function in a Object script? I'd like to be able to have the torch brightness configurable via an ini so I don't have to keep opening the CS if I want to tweak the brightness.
User avatar
Amanda savory
 
Posts: 3332
Joined: Mon Nov 27, 2006 10:37 am

Post » Tue May 17, 2011 11:44 am

Yes! It works now. Thanks you, scruggsy. Another question: can I use the "RunBatchScript" function in a Object script? I'd like to be able to have the torch brightness configurable via an ini so I don't have to keep opening the CS if I want to tweak the brightness.

Yes.
User avatar
Nikki Lawrence
 
Posts: 3317
Joined: Sat Jul 01, 2006 2:27 am

Post » Tue May 17, 2011 3:03 pm

Cool, thanks.
User avatar
Blackdrak
 
Posts: 3451
Joined: Thu May 17, 2007 11:40 pm


Return to IV - Oblivion