Jump to content

Please help scripters!


rotarydanimal

Recommended Posts

I have everything working except that the static wont rotate. What am I doing wrong?

 

SCN CMGeneratorMenuScript

int Button
Ref LREF

begin OnActivate

Set LREF to GetLinkedRef

if IsActionRef Player == 1
	showmessage CMGeneratorMessage
endif
End

begin GameMode
set Button to GetButtonPressed
if Button == 0													; Button 0 = "On"
	if LREF != player
		LREF.Rotate Z 30
	elseif Button == 1											; Button 1 = "Off"
		Set LREF to Player
	endif
	Set LREF to GetLinkedRef
endif
end

Link to comment
Share on other sites

In what capacity is this script being used? I'm somewhat confused by your menu there. Seems to me it will never rotate so long as the player is the LREF. What object are you trying to rotate, and why set LREF to the player if you don't do anything with it (or have you excluded code from this)?
Link to comment
Share on other sites

I am very new to scripting. I am sure I have just not done it right. I was trying to make a condition so that the object would rotate. The object is just to show motion when a motor is started. I could not find anything that has the animation that I want so I figured that I would make my own object rotate.

 

The buttons work and the rotation works on the correct axis, but the object only rotates once when the "ON" button is pushed. I think that the problem is in this section:

 

if Button == 0                                                                                                  ; Button 0 = "On"
               if LREF != player
                       LREF.Rotate Z 30
               elseif Button == 1                                                                                      ; Button 1 = "Off"
                       Set LREF to Player
               endif
               Set LREF to GetLinkedRef

Link to comment
Share on other sites

OH! You want it to rotate all the time? That would be....taxing, but doable.

 

What you need is a GameMode block that runs all the time. Of course, you'll also need to build in a timer, otherwise it'll move it every single frame and I'm not sure what that would look like.

 

So what you'd do is set a variable in this section:

                if LREF != player
                       LREF.Rotate Z 30
               elseif Button == 1          

that is used later on in a manner like:

if isActivated		;defaults to 1=true so you don't need an "==1"
LREF.Rotate Z 30
endif

 

That should do what you want, but it might also slow your game down noticeably in the cell with that object, since this will be happening every frame (approximately 30-60 times a second).

Link to comment
Share on other sites

I will give that a shot. thanks

 

I have been toying around with an animated object that I found in speedy resources.

 

When I use this script the console lets me open the menu as many times as I want until I activate the animation then the menu will not appear when I click on the console.

What is wrong now?

 

SCN CMGeneratorAnimationScript

int Button
int IsActivated
Ref LREF

begin OnActivate

Set LREF to GetLinkedRef

if isactivated == 0
	set isactivated to 1
	Activate
	if IsActionRef Player == 1
		showmessage CMGeneratorMessage
	endif
endif
End

begin GameMode
set Button to GetButtonPressed
	if Button == 0													; Button 0 = "On"
		LREF.PlayGroup Left 2
	elseif Button == 1												; Button 1 = "Off"
		Set isactivated to 0
		LREF.PlayGroup Forward 0
	endif
endif
end

Link to comment
Share on other sites

I am not sure how to do that.

 

Should it be:

 

SCN CMGeneratorAnimationScript

int Button
int IsActivated
Ref LREF

begin OnActivate

       Set LREF to GetLinkedRef

       if isactivated == 0
               set isactivated to 1
               Activate
               if IsActionRef Player == 1
                       showmessage CMGeneratorMessage
               endif
       endif
End

begin GameMode
       set Button to GetButtonPressed
               if Button == 0                                                                                                  ; Button 0 = "On"
                       LREF.PlayGroup Left 2
                       Set isactivated to 0
               elseif Button == 1                                                                                              ; Button 1 = "Off"
                       Set isactivated to 0
                       LREF.PlayGroup Forward 0
               endif
       endif
end

Link to comment
Share on other sites

That would work, but if you're going to set it back in both cases, you could either combine it at the end of the if block, or really, why have it? What you should probably have in that gamemode block is before the

set Button to GetButtonPressed

have a line that says

if isactivated

and then go on with the rest of it. That way all that part will only run when you want it to, and not potentially grab some other button press (not sure if that can happen, but better safe than sorry).

Link to comment
Share on other sites

thanks for the patience Gribleshnibit8, I am really new to this. I am pretty good at designing levels though.

If you have not seen my mod you should check out some of my pics. The mod is not posted yet cause it is far from usable.

 

http://steamcommunity.com/id/rotarydanimal/

Edited by rotarydanimal
Link to comment
Share on other sites

  • Recently Browsing   0 members

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