Jump to content

Small Scripting Issue


armageddon818

Recommended Posts

Ok so this isnt even a big deal all that much, its just that I cant even believe it DIDNT work. So basically this is what i want to do:

There is a set of stairs, initially disabled, persistent reference, object ref ID aaastonestairs

There is a switch with a script attached.

 

All i want, is when you press the switch, the stupid stairs are enabled.

 

My really short script for this REALLY simple problem:

 

scn blahblahblah (not really its like aaastairsinitialization or something)

begin onactivate

enable aaastonestairs

end

 

Shouldnt that be all? What am I doing wrong?

 

Basically we wanted a lift for the main palace of our mod, but i guess we couldnt figure it out because of the scripting or something, so I am trying appearing stairs instead. Regardless, if somone knew where we could get an Actual lift, that would be great. It doesnt even need to be an elevator...just a floating disc would be plenty good for us. It doesnt even need to have stops, so long as it just goes up and down all by itself. If someone could tell us how to make that, that would be great. If not, appearing stairs is what we will have to settle for, although a lift would settle a lot of problems. I've always wanted someone to make a telekinesis mod that let you find a shield or something and then stand on it and fly with it...I think telekinesis is TERRIBLY underused, but havent the scripting ability to do anything about that. I mean honestly...you should be able to move boulders out of your freaking way!

Link to comment
Share on other sites

Well we would like to have it be able to stop at different points but we didnt exactly know how to make that work either, so really either one would work. Really, the best thing we could get would be a lift that when you pull a switch/activate something (on the lift) a menu comes up, you choose the floor you want, and the you go there...that would be the best, but we are willing to settle for just about everything!

 

LOL I knew it was something simple!!!! Thanks!

Link to comment
Share on other sites

Okay, how to make a working elevator:

 

Building Your Elevator

First thing's first, figure out which models you want your elevator to be made of. There's no reason you can't use multiple models to make the elevator, but you'll need at least one "body" object and one "switch" object. This tutorial will use WorldObjects that are already designed as Activators or Statics, but if you're well-versed in BSA Commander, feel free to use other WorldObjet models. If your switch of choice animates, though, you'll probably want to keep it to one animation instead of a switch with two states, since the switch does the same thing every time it's activated. For the purposes of this tutorial, we'll use OBMedblock04's (A square block of dark stone) model for the body, and ARSwitch01's (The Ayleid Ruin push button) model for the switch. If the body is an Activator, use Edit to create a new form for it with no script attached or name. Do the same for the switch. Use these to assemble your elevator however you want. Everything aside from the lever will need to be a persistent reference, with a specified Ref ID (For the purposes of this tutorial, the elevator body will be named MyElevatorBody)

 

 

Script Preparation

Figure out the Z positions of the "stops" for your elevator, and make note of them. You can do this by moving the elevator to its proper stop, double-clicking on the *switch*, and looking at its Z position. The switch will have the script, so measure where the switch is at the stop instead of the body.

 

 

Scriptwriting

Create a new Object script.

 

scn MyElevatorSwitchScript

short DestinationFloor
short CurrentFloor
short choosing
short choice
short DoOnce
float NewPos
;Declaring a couple of variables for use in the script.  Short variables hold comparatively small numbers.
;Floats take up comparatively more space, but hold comparatively larger numbers.

Begin OnActivate
;OnActivate blocks run when the object is activated in the world.

  if (IsAnimPlaying == 0)
;If no animation is playing...

  PlayGroup Forward 0
;...Play the lever's animation

  messagebox "Which floor would you like to go to?", "First floor", "Second Floor", "Third Floor", "Cancel"
;Add more floors or take some away as you want.

  set choosing to 1
;This will let the GameMode block know if it should check what Messagebox button the player pushes or not.
  endif
end

Begin GameMode
  if (DoOnce == 0)
;Initializing CurrentFloor and DestinationFloor variables if this is the first time this runs.

  set CurrentFloor to 1
  set DestinationFloor to 1
;If the elevator doesn't start on the first floor, change these numbers accordingly.

  set DoOnce to 1
  endif

  if (choosing == 1)

  set choice to GetButtonPressed
;GetButtonPressed returns -1 for no button, 0 for button 1, 1 for button 2, etc.

   if (choice != -1 && choice != 3)
 ;If you changed the number of floors, change "3" to (number of MessageBox options minus 1).
 ;That is to say, the cancel button at the end.

	  set DestinationFloor to (choice + 1)
	  set choosing to 0

	 elseif (choice == 3)
;Else essentially means "otherwise" for if-loops.  So in this case, it means "Otherwise, if choice *is* 3..."
		set choosing to 0
	 endif
endif

  if (CurrentFloor != 1 && GetPos Z < 257 && GetPos Z > 255)
;This is a series of ifs to see if it's time to change CurrentFloor.  Rig these so they read...
;"If/Elseif (CurrentFloor != *the floor in question, starting at 1 and going up*...
;...&& GetPos Z < *The floor in question's Z position + 1*...
;...&& GetPos Z > *The floor in question's Z position - 1*)

  set CurrentFloor to 1
  elseif (CurrentFloor != 2 && GetPos Z < 513 && GetPos Z > 511)
  set CurrentFloor to 2
  elseif (CurrentFloor != 3 && GetPos Z < 769 && GetPos Z > 767)
  set CurrentFloor to 3
  endif
;If you make it move faster, you'll need to increase the difference it checks for to match.
;So, say, if you make it move 3 points every time it runs, you'd need to change the first one to...
;GetPos Z < 258 && GetPos Z > 254

  if (DestinationFloor > CurrentFloor)
;If the elevator's destination is higher up than it...
  set NewPos to (GetPos Z + 1)
  SetPos Z NewPos
  set NewPos to ( (MyElevatorBody.GetPos Z) + 1)
  MyElevatorBody.SetPos Z NewPos
;Adjust the Elevator's and Body's positions by 1 upwards.
;Add more "Set NewPos to/SetPos Z" lines to match for any other parts you have, if it's more than two pieces.

  elseif (DestinationFloor < CurrentFloor)
  set NewPos to (GetPos Z - 1)
  SetPos Z NewPos
  set NewPos to ( (MyElevatorBody.GetPos Z) - 1)
  MyElevatorBody.SetPos Z NewPos
  endif
end

 

Attach this script to your lever and, if neither of us have messed anything up (Which is quite likely, since the only testing I bothered to do was seeing if the Construction Set would compile the script), you should have a working elevator. Let me know if you run into any issues, or there's anything else you'd like the system to do, like being able to call it to your floor using different levers.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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