Jump to content

Help Moving an object


circuitbomb

Recommended Posts

Hello TESNexus community!

 

I've ran into a bit of trouble attempting to move an object in a mod I have been working on, while I believe this may have been asked before, I would like a bit more of an explanation than what I have found on the TES Wiki regarding it.

 

I have an object, a shelf to be specific, it is an activator, and I have a switch, when the switch is 'hit' I need the shelf object to raise straight up on its z axis.

 

Here is my code thus far:

 

scn MyModRaisingShelf01SCRIPT

short open
long zPos

begin OnActivate
  set zPOS to MyShelf.GetPos Z
  
  if open == 0 && isAnimPlaying == 0
     if zPos == 20358.2402
           MyShelf.disable
           MyShelf.MoveToMarker MyMarkerOpen
           MyShelf.enable
           MyShelf.setPos z, 20366.6133
           set open to 1
     endif
 else
     if zPos == 20366.6133
           MyShelf.disable
           MyShelf.MoveToMarker MyMarkerClosed
           MyShelf.enable
           MyShelf.setPos z, 20358.2402
     endif
 endif

end

 

Now something is going on here that I am simply missing, I've been troubleshooting this for a few hours now, so your assistance would be genuinely appreciated.

 

When I load the mod up and goto my switch, it does nothing, it is an animated switch(like a lever) yet does not move, the shelf does not move either, nothing happens.

 

Thanks in advance.

 

Edit: Just to note, both the lever and the shelf are set as persistant with the levers parent set as the shelf.

 

-Circuitbomb

Link to comment
Share on other sites

Hello TESNexus community!

 

I've ran into a bit of trouble attempting to move an object in a mod I have been working on, while I believe this may have been asked before, I would like a bit more of an explanation than what I have found on the TES Wiki regarding it.

 

I have an object, a shelf to be specific, it is an activator, and I have a switch, when the switch is 'hit' I need the shelf object to raise straight up on its z axis.

 

Here is my code thus far:

 

scn MyModRaisingShelf01SCRIPT

short open
long zPos

begin OnActivate
  set zPOS to MyShelf.GetPos Z
  
  if open == 0 && isAnimPlaying == 0
     if zPos == 20358.2402
           MyShelf.disable
           MyShelf.MoveToMarker MyMarkerOpen
           MyShelf.enable
           MyShelf.setPos z, 20366.6133
           set open to 1
     endif
 else
     if zPos == 20366.6133
           MyShelf.disable
           MyShelf.MoveToMarker MyMarkerClosed
           MyShelf.enable
           MyShelf.setPos z, 20358.2402
     endif
 endif

end

 

Now something is going on here that I am simply missing, I've been troubleshooting this for a few hours now, so your assistance would be genuinely appreciated.

 

When I load the mod up and goto my switch, it does nothing, it is an animated switch(like a lever) yet does not move, the shelf does not move either, nothing happens.

 

Thanks in advance.

 

Edit: Just to note, both the lever and the shelf are set as persistant with the levers parent set as the shelf.

 

-Circuitbomb

 

 

It could be possible that your "if zPos == ....." are too specific to actually come true since these are floating point numbers. Even though I can't say for sure that this is the problem, you would be better off changing your ifs to something like the following (partial code - lines removed for clarity):


     if zPos < 20360
           MyShelf.enable
           MyShelf.setPos z, 20366.6133
           set open to 1
     endif
 else
     if zPos > 20360
           MyShelf.enable
           MyShelf.setPos z, 20358.2402
     endif

Link to comment
Share on other sites

  • Recently Browsing   0 members

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