Jump to content

[LE] Quick Questions, Quick Answers


Recommended Posts

Scriptname xxxGiantScaleScript Extends Actor


Race Property NordRace Auto


EVENT OnInit()
	Race NPCRace = GetRace()
	if NPCRace == NordRace
		float RandomScale = Utility.RandomFloat(2.40, 2.60)
		setScale(RandomScale)
		;debug.notification("Giant Scale Modified")
	endif	
endEVENT

The script above is attached to a actor (which pulls the traits/models/animations from a leveled list) and it is supposed to change their scale if the actor is from the Nord Race, but it doesn't get applied when the actor spawned is a Nord. Any help on this?

Edited by Magnusen2
Link to comment
Share on other sites

  On 10/3/2016 at 6:36 PM, IsharaMeradin said:

You have to call GetRace() on an actor. Right now it is trying to use Self by default but Self is a script. Change it to:

Race NPCRace = (Self as Actor).GetRace()

See if that works for you.

 

Self refers to the object that the script is attached to, so in this case self is an actor. Self is never a script.

Link to comment
Share on other sites

  On 10/3/2016 at 7:52 PM, lofgren said:

 

 

Self refers to the object that the script is attached to, so in this case self is an actor. Self is never a script.

 

Maybe my memory is faulty. I could have sworn that I couldn't get some functions that should have ran on the type of object I was using without first casting Self into that object type.

In any event, it wouldn't hurt as a quick test yielded that Self.GetName() and (Self as ReferenceAlias).GetName() have the same result for a reference alias on a quest.

 

I suppose if it is not a casting issue, if could be possible that the OnInit() event is processing before the actor is fully loaded. And for some things, that can be an issue. To test for that, you can register for a single update and run the code in the update event instead.

Link to comment
Share on other sites

HI again. Working on a small mod to give Kharjo a few followers of his own. Right now, I have them on an AI package to follow, and in the khajiit caravan faction. If their package just uses Kharjo as the reference link to be followed, will that conflict with other mods that affect Kharjo? Or am I safe as long as I don't change him directly?

Link to comment
Share on other sites

  On 10/4/2016 at 1:47 AM, thumbincubation said:

HI again. Working on a small mod to give Kharjo a few followers of his own. Right now, I have them on an AI package to follow, and in the khajiit caravan faction. If their package just uses Kharjo as the reference link to be followed, will that conflict with other mods that affect Kharjo? Or am I safe as long as I don't change him directly?

I don't think it would be an issue. Then again, I've never done anything like that. Wouldn't hurt to test it out. Make a second temporary mod that changes Kharjo and see how it affects your actual mod.

Link to comment
Share on other sites

Thanks.

Still didn't work. I got another issue.

What i'm trying to do:
A set of sliders in which the user can determine the scale of actors when they spawn.

The problem:
As soon as one of the actors that has the script is spawned, they are "invisible". They can still taunt (in the case of enemies) and followers/summons attack them.
I suspect that their scale was set to a very small value (even though i set it to be normal size) due to my lack of knowledge when dealing with floats.

Here's the MCM code snippet:

  Reveal hidden contents



And here's the code attached to the actor:

  Reveal hidden contents



So the questions:
1. Before i got the idea of a MCM i attached the script above but instead of using Globals to get the values for the RandomFloat i used numbers (e.g. Utility.RandomFloat(0.93, 1.07)). Everything worked perfectly. Why it doesn't work now?

2. In the log i get lots of "Cannot call GetValue() on a None object". Why?

3. When i open the MCM, the slider values are working as intended. But as soon as i modify one and accept, the float values are "reset" to a whole number (e.g. 1.07 becomes 1). This continues no matter what value is set. Only when the menu is reopened that the values appears as float again. Looking at the code above, why is this happening?

 

Link to comment
Share on other sites

#2

Are you assigning the global variable properties in the Creation Kit? An error of 'cannot call GetValue() on a None object' typically indicates that the property variable intended to contain the global variable does not have a global variable assigned to it.

 

Why are you using things like: SomeVar.GetValue() as float

GetValue() automatically returns a float. You do not need to cast it.

 

As far as questions 1 or 3. Those can't really be answered with just the snippets that are there. MCM scripts are very interconnected with parts for each option spread throughout the script. A little less spread out if using the State method, but still spread out.

Link to comment
Share on other sites

 

  Reveal hidden contents


Yes. With every actor that have the script (about 40+). But the log still gets spammed with errors.
The NPCs still are invisible.

  Reveal hidden contents


Sorry. I didn't know.

  Reveal hidden contents


I was able to fix Issue #3 by replacing:
This:


        SetSliderOptionValue(a_option, a_value)

With this:


        SetSliderOptionValue(a_option, a_value, "{2}")

Now when the slider is set 2 extra decimals appear.

Below is the code with more structure.

  Reveal hidden contents

 

 

Maybe this is happening because the script attached extends as Actor?

Edited by Magnusen2
Link to comment
Share on other sites

  On 10/4/2016 at 1:53 AM, IsharaMeradin said:

 

I don't think it would be an issue. Then again, I've never done anything like that. Wouldn't hurt to test it out. Make a second temporary mod that changes Kharjo and see how it affects your actual mod.

 

Awesome. I should have thought of that. Sorry. Am going to give it a shot.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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