Jump to content

OnActivate Script


Recommended Posts

Another scripting question, this one should be more simple, but I can't wrap my head around it.

 

I want it to basically say

 

If 'player' activates 'object'

Display MessageBox

Option 1: Would you like to pick up the object?

Option 2: Would you like to destroy the object?

 

Option 1 disables the object, effectively getting rid of it, and then puts a clone of the object (a Misc Item that looks exactly like the Activator) into your inventory.

 

Option 2 disables the object, with no bonus effect other than satisfaction of how evil the player is.

Link to comment
Share on other sites

Can anyone find the problem here, I recycled it from an old script with someone having a similiar problem posted in these forums.

 

Problem is it doesn't matter which button I press, it states "You have destroyed the object." I'm not understanding what's wrong.

 

Begin SW_Activate
Short controlvar
Short button

If ( MenuMode == 1 )
Return
Endif

If ( OnActivate == 1 )
If ( controlvar == 0 )
MessageBox "What would you like to do with the object?", "Pick it up.", "Destroy it."
Set controlvar to 1
elseif controlvar > 1
activate
endif
endif

if ( controlvar == 1 )
set button to GetButtonPressed
if ( button == -1 )
return
elseif ( button == 2 )
MessageBox "You have picked up the object."
Activate
set controlvar to 2
else
MessageBox "You have destroyed the object."
set controlvar to –1
Endif
elseif ( controlvar == 2 )
Activate
Set controlvar to 3
endif

End
Link to comment
Share on other sites

Begin SW_Activate


Short nState

Short nButton


if ( MenuMode )

elseif ( nState == 0 )

if ( OnActivate )

MessageBox "What would you like to do with the object?", "Pick it up.", "Destroy it."

Set nState to 1

endif

elseif ( nState )

Set nButton to GetButtonPressed

if ( nButton < 0 )

Return

elseif ( nButton == 0 )

MessageBox "You have picked up the object."

Activate

else

MessageBox "You have destroyed the object."

Disable

endif

Set nState to 0

endif


End

Edited by ZWolol
Link to comment
Share on other sites

 

Can anyone find the problem here, I recycled it from an old script with someone having a similiar problem posted in these forums.

 

Problem is it doesn't matter which button I press, it states "You have destroyed the object." I'm not understanding what's wrong.

 

Begin SW_Activate

Short controlvar

Short button

If ( MenuMode == 1 )

Return

Endif

If ( OnActivate == 1 )

If ( controlvar == 0 )

MessageBox "What would you like to do with the object?", "Pick it up.", "Destroy it."

Set controlvar to 1

elseif controlvar > 1

activate

endif

endif

if ( controlvar == 1 )

set button to GetButtonPressed

if ( button == -1 )

return

elseif ( button == 2 )

MessageBox "You have picked up the object."

Activate

set controlvar to 2

else

MessageBox "You have destroyed the object."

set controlvar to –1

Endif

elseif ( controlvar == 2 )

Activate

Set controlvar to 3

endif

End

 

 

GetButtonPressed returns 0 for the first button, 1 for the second button. Therefore it should [elseif ( button == 0 )] not 2.

Link to comment
Share on other sites

Okay, I appreciate both of y'all.

 

I ended up going with this one, but I had to change around that button 1 says Destroy it and button 2 says pick it up. It didn't seem right but it worked.

 

Begin SW_Activate
Short nState
Short nButton
if ( MenuMode )
elseif ( nState == 0 )
if ( OnActivate )
MessageBox "What would you like to do with the object?", "Pick it up.", "Destroy it."
Set nState to 1
endif
elseif ( nState )
Set nButton to GetButtonPressed
if ( nButton < 0 )
Return
elseif ( nButton == 0 )
MessageBox "You have picked up the object."
Activate
else
MessageBox "You have destroyed the object."
Disable
endif
Set nState to 0
endif
End

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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