Jump to content

Small Scripting Issue | Please Help


KaelVirum

Recommended Posts

Silly me. That should be a "float" not an "int". It's obviously past my bedtime.

 

There's a properties button on the screen in the CK where you add the script to an object.

 

Technically for that script you can also just replace all of the uses of PlayerREF with Game.GetPlayer() but using the property is much more efficient for the system.

Link to comment
Share on other sites

I'm still very much a noob when it comes to scripting. I've typed your code into ck and it compiles but when I test it the activator doesn't return me to scale 1.00. Anyway, I'm going to bed now, as well. I'll work on it more tomorrow. Thanks for all the help, though, guys! I do really appreciate every suggestion/"this is what it needs to be"! lol

Link to comment
Share on other sites

Okay, this may be a really dumb question... But maybe the scale is based on what the Actor's current scale is? So, for example, you've set the scale to 0.25 and then you set the scale to 1.00. But what you actually need to set the scale to is 4.00? Does that make sense? If the original scale is 1.00, you set it to 0.25... Then if you set it to 1.00, you're just setting it to 0.25 again? Or is it based on a constant scale?

 

Just a thought!

Link to comment
Share on other sites

Ok, guys, I would like to update you on my progress, here. Thank you guys for all your help and suggestions! Credits to you will go on the finished product.

 

Alright, sadly, I couldn't get any of the code to work properly up until now, I tried everything I could think of and it still wouldn't work. So what I did was I went back to my first script, the one where I was actually able to shrink the player.

 

Event onActivate(ObjectReference akActionRef)

 

Game.GetPlayer().SetScale(0.25)

 

endEvent

 

And I thought to myself, there must be some way for this to work properly as long as I add the proper conditionals, though, every other iteration of this I tried didn't work. But just this morning I finally figured out how to make the activator switch you from 1.00 scale to 0.25 then back to 1.00 on a second activation. Now, I think what the problem was was that I was using static numbers for the code (i.e. == 1.00 and == 0.25) to tell it what to do and I would always end up being shrunk by the activator but it would never restore me back to scale 1.00. So, as I said, I went back to my first simple script and added the conditionals (ifs) to it so that it looked like this:

 

Event onActivate(ObjectReference akActionRef)

 

if Game.GetPlayer().GetScale() == 1.00

Game.GetPlayer().SetScale(0.25)

 

else

Game.GetPlayer().SetScale(1.00)

 

endif

 

endEvent

 

Even though I knew this wouldn't work because I had tried it several times (I may be somewhat smart but I'm bull headed too! XD). So I sat here looking this morning and it finally hit me. Instead of using the comparison == for one or both ifs as I had done previously it would probably make more sense to use both >= and <= for their respective lines. But I knew that if I continued to use 1.00 and 0.25, even with these comparisons that I would still have trouble so I played around with it a bit and finally got it. So now, just for anyone that may want to do something similar to what I've done, Here's what the code looks like.

 

Event onActivate(ObjectReference akActionRef)

 

if Game.GetPlayer().GetScale() >= 0.50

Game.GetPlayer().SetScale(0.25)

 

elseif Game.GetPlayer().GetScale() <= 0.49

Game.GetPlayer().SetScale(1.00)

 

endif

 

endEvent

 

I just tested this out and it does actually work. it's obvious to me that you know more about code than I do, cdcooley, and I'm sorry I wasn't able to get the code you provided me to work. I do, however, consider your suggestions (as well as JMSFedaykin's) to be integral to me actually figuring this out so you both will still be credited on the finished mod.

Link to comment
Share on other sites

Yeah, that's kind of what I was thinking. But if you set the scale to 0.25, shouldn't it actually be 0.25? Unless it's functions like a modifier / multiplier on the original value, which doesn't really make sense. Or the conflicting mod is later in the load order? Wierd...

Link to comment
Share on other sites

I'm using a mod that sets the default player height to 1.03. I think it's called better camera. I was kinda thinking that was affecting it as well. That's why I went with the <= and >= and set the first if to 0.50 since that is the smallest you can make a custom race. Then, just to be sure that I trigger the regrowth I set the second if to <= 0.49. It works, that's all I know. However, about a mod modifying scale, this mod I have sets the player scale to 1.03 and when I would use the console command player.getscale while normal sized I would get the return GetScale >> 1.00 (with a base of 1.03) then when I used it after shrinking I would get the return GetScale >> 0.25 (with a base of 0.26). So I don't know if that makes a difference or not, but when I use my code everything functions properly.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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