Roborabbit Posted December 30, 2011 Share Posted December 30, 2011 I'm working on a little project, trying to make a town. However I have run into a bit of an issue. I am using the Crane that is used at the Citadel as my gate, however it won't play the animation when I activate it.I want it to be able to be closed and opened by the player using an activator. I have tried to code it myself, but I don't know enough about coding and so my attempts have merely been trying to spot the bit that allows the player to open the citadel gate and adjust it to fit my own needs :/ If any one can help I would appreciate it greatly! Here is what I have tried: This was copied directly from the original code used for the crane at the Citadel, I changed the Reference Id for CitCraneRef to JYCraneRef and now I receive an error saying that "State" is an unknown variable or function... ScriptName JunkYardCraneScript short doonce ;used to activate Citadel Crane to open gate as the player Begin OnTrigger if ( doonce == 0 ) if isActionRef Player == 1 if ( JYCraneRef.State != 1 ) JYCraneREF.Playgroup Forward 1 set JYCraneRef.State to 1 endif endif endif End Link to comment Share on other sites More sharing options...
caramellcube Posted December 30, 2011 Share Posted December 30, 2011 Is this script inside the crane itself or the activator? There's a few things you might need to change to get this to work... Begin OnTrigger This will start your script each time anything collides with the scripted object, not when the player activates it. This might be helpfull http://geck.bethsoft.com/index.php/OnTriggerIf you want to have a button that controls the crane, I'd say put the script in the button and change this part to Begin OnActivate if ( doonce == 0 ) This will prevent the script from running more than once, if that's what you intend then that's fine, otherwise you'll need to remove this add some way of handling forward and backward animations, I'm not good with animation though so hopefully someone else could help with that if needed. if ( JYCraneRef.State != 1 ) JYCraneREF.Playgroup Forward 1 set JYCraneRef.State to 1 endif This seems to be the part that's causing the error, I take it you gave the crane a name of JYCraneREF ?It might be worth trying the script like this... ScriptName JunkYardCraneScript short doonce ;used to activate Citadel Crane to open gate as the player Begin OnActivate Player if ( doonce == 0 ) JYCraneREF.Playgroup Forward 1 endif End That looks like it should work, though only once. Link to comment Share on other sites More sharing options...
Roborabbit Posted December 30, 2011 Author Share Posted December 30, 2011 (edited) Thanks for the reply Caramellcube! Unfortunately the script that you posted still didn't work for me. However the information you posted was very helpful and allowed me to solve the issue, I prefer the solution that I came up with over my original idea anyway :D Originally I had tried to make the crane be activated when the player press an electrical switch, I was trying to make it so that if the gate was down and the button was pressed then the gate would open and vice versa. However I still don't know how to do this, as what you posted should have worked... but it didn't lol To fix it, instead of using a electrical switch I chose to use a terminal. In the terminal menu I added two menu options to appear when the player used the terminal. 1. Open Gate2. Close Gate I then attached code to each option in the "Item Result Script" For Opening the Gate I used this: Ref myLink Set myLink to getLinkedRef myLink.Playgroup Forward 1 For Closing the Gate: Ref myLink Set myLink to getLinkedRef myLink.Playgroup Backward 1 This creates an empty Reference called "myLink" it then 'fills' the empty reference with reference of the item that the terminal is linked to ( I had to do this because it kept telling me that JYCrane was not a reference, so I let it the stubborn geck find it for itself :] ) Playgroup Forward and Backward are self explanatory. Thanks for the Reply Caramell, your information was very helpful :] I suppose this could be adapted to a button aswell, if I still wanted to use an electrical switch the code would probably be something like this: scn (insert script name here) short doonce Begin OnActivate if ( doonce == 0 ) Ref myLink set myLink to getLinkedRef myLink.Playgroup Forward 1 else Ref myLink set myLink to getLinkedRef myLink.Playgroup Backward 1 endif End Lol, absolutely no idea if that works - just a stab in the dark at what might work with a switch... Edit::: Just tried that code to see if would work for a switch and this time the geck accepts it, but in-game it does nothing : / oh well, I was just curious - my terminal still works perfectly. Edited December 30, 2011 by Roborabbit Link to comment Share on other sites More sharing options...
Recommended Posts