Jump to content

Scripting problem


Recommended Posts

i working on a script for an ingestible and had a look at several tutorials and topics with the same problem but my script wont work.

i have made an ingestible which opens a menu when used and the player can make different choices which should add or remove a token to/from the player inventory, but this wont happen, only the menu pops up.

can someone please have a look at my script and try to help me

 

the script

scn EDeffectSCRIPT

short go
short Button

begin ScriptEffectStart

showmessage EDmenu1
player.additem EDitem 1
set go to 1

END



Begin Gamemode
if go == 1

set Button to GetButtonPressed
set go to 0
		if Button == 0
			player.removeitem tokenmale 10
			player.removeitem tokenfemale 10
			

		elseif Button == 1
			player.removeitem tokenfemale 1
			player.additem tokenmale 1
		

		elseif Button == 2
			player.removeitem tokenmale 1
			player.additem tokenfemale 1
			
endif			
endif

END

 

thanking you in anticipation

Link to comment
Share on other sites

That bug in AddItem shouldn't affect the player, and I don't think it's relevant here anyway. The problem is that you're only using GetButtonPressed for only one frame - the player cannot possible press a button in the same frame as the menu appears. You also shouldn't really be using a GameMode block in an effect script. In fact, script effects shouldn't be used for menus - the blocktypes available to them just aren't suitable.

 

Instead, you should add a token to the player's inventory that has an object effect for your menu script. Use OnAdd and GameMode blocks, like this:

ScriptName EDeffectSCRIPT

int iButton

Begin OnAdd
ShowMessage EDmenu1
player.AddItem Editem 1
End

Begin GameMode
set iButton to GetButtonPressed
if iButton == -1
	Return
elseif iButton == 0
	player.RemoveItem tokenmale 10
	player.RemoveItem tokenfemale 10
elseif iButton == 1
	player.RemoveItem tokenfemale 1
	player.AddItem tokenmale 1
elseif iButton == 2
	player.RemoveItem tokenmale 1
	player.AddItem tokenfemale 1
endif
RemoveMe
End

Cipscis

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...