Questions regarding scripting, magic effects, and animations

Post » Tue Jun 19, 2012 4:43 am

I just started my first mod, and have completed a simple script required for it. When I made it however, I became aware of a few issues: Firstly, is it not possible to assign a fraction to a float variable when it's declared? When I tried to do it the compiler gave me the error "required (...)+ loop did not match anything at input '/'". The line was:
float someFraction = 1.0/60.0
. As a followup to that, is it safe to compare two float variables to eachother by merely using the <,== and > operators? I know this is not the case in many programming languages. Third, how do you access the magnitude property of a magic effect in one of it's attached scripts? I saw a page entitled "GetMagnitude" or something along those lines on the wiki, but it has been deleted. Fourth, how do I add my new magic effect to a food item? I tried doing this by adding it in the food item's "results" effect list, but my custom effect (along with many others) is not present in the effect dropdown menu. Finally, I'm wondering how I can go about creating a custom animation for when this food item is consumed. I simply do not know where to start with this, so if someone could point me in the right direction that would be wonderful.

Thank you for your time.
User avatar
Andrew Lang
 
Posts: 3489
Joined: Thu Oct 11, 2007 8:50 pm

Post » Tue Jun 19, 2012 6:46 am

Only declarative code can take place outside of functions (including events, which are also functions). It's possible to initialise non-object variables to literal values in declarative code, but you cannot use expressions.

So, for example, this line would work:
float someFraction = 0.0166667

When it comes to comparing floats, it often depends on how you got the values. You shouldn't need to rely on any concept of machine zero or anything, though.

I don't think it's possible to return the magnitude of a magic effect via script.

Cipscis
User avatar
rolanda h
 
Posts: 3314
Joined: Tue Mar 27, 2007 9:09 pm

Post » Tue Jun 19, 2012 12:30 am

Only declarative code can take place outside of functions (including events, which are also functions). It's possible to initialise non-object variables to literal values in declarative code, but you cannot use expressions.

So, for example, this line would work:
float someFraction = 0.0166667

When it comes to comparing floats, it often depends on how you got the values. You shouldn't need to rely on any concept of machine zero or anything, though.

I don't think it's possible to return the magnitude of a magic effect via script.

Cipscis
That seems like an odd limitation.
Regarding comparing floats, say I have this code:
if target.GetActorValue("health") > arbitraryHealthValue
would that give me the expected behaviour?
How do you take the magnitude into account, if you can't access it?
I seem to have found out why I couldn't find my custom effect. As it turns out only effects of the type "Fire and Forget" are listed. Why is this, by the way; I see no reason for it.
How accurate is the call of the OnUpdateGameTime event? Diregarding wait/sleep interruptions, will it reliably get called every minute if I set the interval to 1/60?
Should I take it that you don't have an answer for my last question? Anyway, thanks for your help, it has made things a bit clearer =).
User avatar
Josh Dagreat
 
Posts: 3438
Joined: Fri Oct 19, 2007 3:07 am

Post » Tue Jun 19, 2012 4:51 am

That condition should give you expected behaviour, yes.

Hopefully this little bit on the wiki will help answer your question about timing - http://www.creationkit.com/Differences_from_Previous_Scripting#Timing

I'm about as clueless as they come when it comes to animation, so no I'm afraid I wouldn't know where to start either with your last question.

Cipscis
User avatar
Breautiful
 
Posts: 3539
Joined: Tue Jan 16, 2007 6:51 am

Post » Mon Jun 18, 2012 11:42 pm

Getting a little farther ahead, I've run into what appears to be a quite large problem, namely that of attaching a script to an object chosen by the player at runtime. I've looked over http://www.gamesas.com/topic/1349649-dynamically-attaching-scripts-to-actors-near-the-player/ guide to do it ( though based on proximity to the player, I think I've come up with a way for registering the player choice, once I have a pool of candidates) using the questing system, and it seems adequate, except for one thing: The scripts applied to the actors are not persistant. Is there any way to overcome this, or any alternative methods I can use to accomplish this task? I would like to imagine that there exists some function created for this purpose, but I have yet to find it.
User avatar
Wayland Neace
 
Posts: 3430
Joined: Sat Aug 11, 2007 9:01 am


Return to V - Skyrim