Jump to content

Problems with scripting


NoM

Recommended Posts

hey, well i'm new here.

i'm a modder, but not realy good one, learning how to script.

now i found a mod wit cheasts where the upper glass thing can go down.( i dont remember from who the script is)

i edited it so it became a lift,

now i only have one problem.

after you activate the lift, it goes down nice and cool, but when its down, it goes up after some time, how can i make it that way that it stays down, until you activate it again?

 

begin Lift

float Timer

short State

 

if ( MenuMode == 1 )

return

endif

 

if ( OnActivate ==1 )

if ( State == 0 )

PlaySound "Door Stone Open"

set State to 245

endif

endif

 

if ( State >= 245 )

 

set timer to ( timer + GetSecondsPassed )

 

;slide lid down

if ( Timer < 15 )

MoveWorld Z, -100

 

;set back to start

elseif ( Timer > 105 )

SetAtStart

set State to 0 ;can now press button again

set Timer to 0

 

elseif ( Timer > 90 )

if ( State == 245 )

PlaySound "Door Stone Close"

set State to 246

endif

MoveWorld Z, 100

endif

endif

 

end

 

this is the script.

thank you already, when you can help me:)

 

o and what is the hp, mp and exp thing? :S

how you get exp??

Link to comment
Share on other sites

so uuhm

<bla bla bla>

 

if (onactivate == 1)

MessageBox "do you want to go up or down", "up", "down"

if (controlvar == 1)

set button to GetButtonPressed

 

if ( button == -1 ) moveworld Z, 100

 

<bla bla bla>

 

else moveworld Z, -100

 

<bla bla bla>

 

enz?

 

edit:

i edit a bit i made:

 

begin House_wall

float Timer

short State

 

if ( MenuMode == 1 )

return

endif

 

if ( OnActivate ==0 )

(variable == 0 )

setvariable 1

PlaySound "Door Stone Open"

endif

endif

 

set timer to ( timer + GetSecondsPassed )

 

if ( Timer < 15 )

MoveWorld Z, -98

 

elseif ( Timer > 105 )

SetAtStart

 

set Timer to 0

 

if (onactive == 1 )

(variable == 1 )

setvariable 0

playsound "door stone close"

enddif

moveworld Z, 98

endif

endif

 

end

will this work? :huh: :(

i'm not realy good :(

Link to comment
Share on other sites

Okay there is a way!

 

I made a lift as well, when the player clicks on a button you need a variable that tells the script if the lift is going to go up or down.

 

First you need 2 switchs, Different names. When the player clicks on one of them it will either make the player go up or down.

 

Lets say the lift is at the bottom, and the player has no choice but to go up. Place a switch. Place a script within the switch.

Before you add code go into the globals and add a new global variable called "States" Make it a SHORT.

 

Now back to the switch, add a script and make the script say

 

Begin Switch_1

      Set States to 1;Up

end

 

 

now this will tell the computer that the lift must go up. There now must be a script within the moving object/Lift.

 

Begin Lift1

Float Timer1
Short Done

if (MenuMode == 1)
return
endif


if ( states == 1);UP (down can be 2 or what ever but not 0)
      if (Done == 0 )
             Set zp to "Start point"
             Set Done to 1
      endif

      Move Z, 20
      Set Timer1 to Timer1 + GetSecondsPassed

      if (Timer1 >= 1)	
             Set zp to zp + 20
             Set Timer1 to 0
      endif

      if ( zp >= "Stop point")
             Set states to 0;Stop  	
             set zp to "Stop point"
      endif

endif

******

end

Where the "*"s are is where you must add more code, to make it go up or down or what ever.

 

Now let me explain the ZP, this variable determines when to stop the lift. Also remember that you must move the object to the spot that you want it to stop or start, take the X or Y or Z pos's and use those numbers in place of the "Stop point" or "Start point".

 

This part of the code:

if (Timer1 >= 1)	
      Set zp to zp + 20
      Set Timer1 to 0
endif

Will determine how fast the ZP must count up, the "20" must be the same as the MOVE Z, num

if not then the start and stop point will not work correctly. To move the object down besure the MOVE Z, num is a NEG number

Example: MOVE Z, -20

 

Now to get into the REAL WORLD type gravity, in real life, when an object is going up it will take longer, depending on its weight. When its moving up it will be slower than for it going down. So make it a NEG 30 or 40 to give it a better feel of an object trying to fight gravity.

 

I really hope this gave you a better look at scripting and how to work with globals, because they ROCK!

 

Now please remember I took alot of time helping you out. Please Quote this code I took time to do this so please give me some credit.

 

Also remember that you can edit code, place sounds or lights or what ever :P

 

If you continue to have problems please tell me :)

 

Serrieth - NOW BEEN A MEMBER FOR almost A YEAR!!!!!!
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...