Jump to content

Scripting problem : P


mikolajgos

Recommended Posts

I've tried to make a button for turning the lights on and off, just like the one on the top of Anvil Lighthouse. I've found the script from the lighthouse:

scn AnvilLighthouseActivator

begin OnActivate
if IsActionRef player == 1

	if AnvilLighthouseFire.GetDisabled == 0
		AnvilLighthouseFire.disable
	else
		AnvilLighthouseFire.enable
	endif
elseif IsActionRef UlfgarFogEyeRef == 1
;		message "DEBUG: Ulfgar activating lighthouse bowl"
	; turn on if evening, turn off if morning
	if gamehour <= 12
		AnvilLighthouseFire.disable
	else
		AnvilLighthouseFire.enable
	endif
endif
end

 

Then I've changed the activator "AnvilLighthouseFire" into "TestFire01", an activator I created. It looked like this:

 

scn 0TESTFIRE

begin OnActivate
if IsActionRef player == 1

	if TestFire01.GetDisabled == 0
		TestFire01.disable
	else
		TestFire01.enable
	endif
elseif IsActionRef UlfgarFogEyeRef == 1
;		message "DEBUG: Ulfgar activating lighthouse bowl"
	; turn on if evening, turn off if morning
	if gamehour <= 12
		TestFire01.disable
	else
		TestFire01.enable
	endif
endif
end

 

I tried to save but an error occured saying that the game cannot find script in line 7 (TestFire01.disable).

 

I'm not good at scripting in Oblivion, so I ask You, what am I doing wrong? : /

Regards : )

Link to comment
Share on other sites

The enable/disable function must be performed on a reference and not objectID. To get the needed reference you must place your activator on the world and go to the proper field in it's properties and give it an explicit referenceID, which is what you use in your script.

 

Notice I'm supposing you are using the ObjectID, since no information about it is given. The objectID is the name you give to the activator (in this case) at the Object window instead it's actual instance in the Render window.

 

To access the field you can select the item either in the render window or the Cell View window and right click it and Edit. The field is the top most, named "Reference editor ID". call it something like TestFire01Ref to easy identification as referenceID from the objectID.

Edited by nosisab
Link to comment
Share on other sites

Don't name anything using numbers at the front.

I didn't understand, mean you the FormID? the above mentioned are all names and not numbers.

 

PS: you rose an interesting point, something called EdDabb01 could easily pass for a hex number :)

Edited by nosisab
Link to comment
Share on other sites

Ah, yes, but that's convention and not game breaking, still should be avoided indeed. Keeping a more meaningful prefixing standard is the way to good coding. I believe the OP named it so to have quicker access to the script in the list... Edited by nosisab
Link to comment
Share on other sites

  • Recently Browsing   0 members

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