KaelVirum Posted July 28, 2015 Share Posted July 28, 2015 Ok, here's the thing. I've created my own race that is 0.25 in height and now I'm trying to create an activator that will shrink the player down to that size so that they can interact with my race more comfortably. I know I have most of the script correct as I'm only getting one error. Here's the Script: ScriptName ShrinkPlayerScript extends ObjectReference Function SetScale(float afScale) Event onActivate(objectReference akActionRef) Player().SetScale(0.25) endEvent endFunction But when I try to compile it in CK I get an error message (10,0) missing EOF at 'endFunction' What exactly is it that I'm missing here? Any help will be greately appreciate! Link to comment Share on other sites More sharing options...
GrimyBunyip Posted July 28, 2015 Share Posted July 28, 2015 player() isn't a function? also you can't nest an event inside a function. Link to comment Share on other sites More sharing options...
JMSFedaykin Posted July 28, 2015 Share Posted July 28, 2015 I think you need to use Game.GetPlayer().SetScale(0.25) Link to comment Share on other sites More sharing options...
KaelVirum Posted July 28, 2015 Author Share Posted July 28, 2015 Thank you, JMSFedaykin! changing my code to that and taking away the "endFunction" at the end completely and totally worked! Link to comment Share on other sites More sharing options...
KaelVirum Posted July 29, 2015 Author Share Posted July 29, 2015 (edited) Ok, sorry for the double post, guys, but I felt it would be better than cluttering up the front page with an issue dealing with the same thing. I've got the script working, thanks to JMSFedaykin, and attached to an activator and it works perfectly. However, I'm now trying to figure out how to add the conditionals so that once I activate it and my scale is set to 0.25 that I can activate it again and have my scale reset to 1.00. Here's the script I have, does anyone know where I'm going wrong? Scriptname ShrinkPlayerScript extends ObjectReference {This script sets the scale of the Player to 0.25.} Function SetScale(float afScale) native int afScale Event onActivate(ObjectReference akActionRef) afScale = Game.GetPlayer().GetScale() Game.GetPlayer().SetScale()endEvent int Function GetScale(int currentafScale) if currentafScale == 1.00 Game.GetPlayer().SetScale(0.25) elseif currentafScale == 0.25 Game.GetPlayer().SetScale(1.00) endif endFunction Edited July 29, 2015 by KaelVirum Link to comment Share on other sites More sharing options...
JMSFedaykin Posted July 29, 2015 Share Posted July 29, 2015 (edited) ok, i think you need to rewrite this a little bit... try something like this: Event onActivate(ObjectReference akActionRef) if (Game.GetPlayer().GetScale() == 1.00) Game.GetPlayer().SetScale(0.25) else Game.GetPlayer().SetScale(1.00) endifendEvent Now I'm not sure if you would need to do this, but for good-coding's sake, you might want to make sure that only the player can activate the object. If so, you could do it like this: Actor Property PlayerREF Auto Event onActivate(ObjectReference akActionRef) if (akActionRef == PlayerREF && Game.GetPlayer().GetScale() == 1.00) Game.GetPlayer().SetScale(0.25) elseif (akActionRef == PlayerREF && Game.GetPlayer().GetScale() == 0.25) Game.GetPlayer().SetScale(1.00) endifendEvent Now I'm not positive, but I think after compiling the script, you would still need to set the PlayerREF in the properties of the script in the CK. But after that it should work... Hope that helps! Edited July 29, 2015 by JMSFedaykin Link to comment Share on other sites More sharing options...
cdcooley Posted July 29, 2015 Share Posted July 29, 2015 Just in case the player had been set to some other scale before starting I would use:Actor Property PlayerREF Auto int PreviousScale = 0.25 ; default to 0.25 in case by some strange chance the player was already that size Event OnActivate(ObjectReference akActionRef) if akActionRef == PlayerREF ; so activator only works for the player if PlayerRef.GetScale() != 0.25 PreviousScale = PlayerRef.GetScale() ; record current scale so it can be restored PlayerRef.SetScale(0.25) else ; already small PlayerRef.SetScale(PreviousScale) ; restore previous scale endif endif EndEvent And yes, you then need to fill the script properties, but Auto-Fill will know what to do with PlayerREF. Link to comment Share on other sites More sharing options...
JMSFedaykin Posted July 29, 2015 Share Posted July 29, 2015 Just out of curiosity... This is a really dumb question, but what is the code you use for that code highlighting? Link to comment Share on other sites More sharing options...
KaelVirum Posted July 29, 2015 Author Share Posted July 29, 2015 Ok, I'm still learning all of this stuff. How do I fill the script properties? Link to comment Share on other sites More sharing options...
KaelVirum Posted July 29, 2015 Author Share Posted July 29, 2015 Just in case the player had been set to some other scale before starting I would use: Actor Property PlayerREF Auto int PreviousScale = 0.25 ; default to 0.25 in case by some strange chance the player was already that size Event OnActivate(ObjectReference akActionRef) if akActionRef == PlayerREF ; so activator only works for the player if PlayerRef.GetScale() != 0.25 PreviousScale = PlayerRef.GetScale() ; record current scale so it can be restored PlayerRef.SetScale(0.25) else ; already small PlayerRef.SetScale(PreviousScale) ; restore previous scale endif endif EndEvent And yes, you then need to fill the script properties, but Auto-Fill will know what to do with PlayerREF. That didn't work for me. The script wouldn't compile because it couldn't set an int to 0.25. Link to comment Share on other sites More sharing options...
Recommended Posts