Script not working

Post » Fri May 27, 2011 1:14 pm

Why does this script not work? (CTDs every time)
scn RPSQuicksandRopeUnequipScriptref RopeObjectshort ControlVarshort buttonBegin OnEquip	messagebox "Do you want to unequip the rope?", "Yes", "No"	set ControlVar to 1end	Begin MenuMode	if ControlVar == 1		set Button to GetButtonPressed		if Button == 0			set controlvar to 0			set RPSQuicksandControlQuest.PlayerHasRopeEquiped to 0			player.AddItemNS RPSQuicksandRope 1			player.RemoveItemNS RPSQuicksandRopeEquipped 1		elseif button == 1			set controlvar to 0		endif	endifend


But this very very similar one does?:
scn RPSQuicksandRopeScriptref RopeObjectshort ControlVarshort buttonBegin OnEquip	messagebox "Do you want to equip the rope?", "Yes", "No"	set ControlVar to 1end	Begin MenuMode	if ControlVar == 1		set Button to GetButtonPressed		if Button == 0			set controlvar to 0			set RPSQuicksandControlQuest.PlayerHasRopeEquiped to 1			player.RemoveItemNS RPSQuicksandRope 1			player.AddItemNS RPSQuicksandRopeEquipped 1		elseif button == 1			set controlvar to 0		endif	endifend


Thanks in advance.
User avatar
Alexxxxxx
 
Posts: 3417
Joined: Mon Jul 31, 2006 10:55 am

Post » Fri May 27, 2011 11:24 am

I would guess that not the script causes the CTD but the things that happen in the quest script when you set PlayerHasRopeEquipped to 0 after it was 1.
User avatar
JD FROM HELL
 
Posts: 3473
Joined: Thu Aug 24, 2006 1:54 am

Post » Fri May 27, 2011 2:14 pm

That's what's odd - the quest script just acts to store variables. Nothing apart from:

Scn RPSQuicksandControlQuestScript

short Playerhasropeequipped
short playerinquicksand
float distancesunk
User avatar
Russell Davies
 
Posts: 3429
Joined: Wed Nov 07, 2007 5:01 am

Post » Fri May 27, 2011 4:32 am

That's what's odd - the quest script just acts to store variables. Nothing apart from:

Scn RPSQuicksandControlQuestScript

short Playerhasropeequipped
short playerinquicksand
float distancesunk


But what is the variable for? In the script you posted it has no use.
User avatar
Robert Jackson
 
Posts: 3385
Joined: Tue Nov 20, 2007 12:39 am

Post » Fri May 27, 2011 6:46 am

I noticed that you have the variable "PlayerHasRopeEquipped" spelled one way in the Quest Script (with two "p"s in "equipped"), but only have one "p" in the other scripts you posted. Maybe that is causing an issue?

Koniption
User avatar
Elizabeth Davis
 
Posts: 3406
Joined: Sat Aug 18, 2007 10:30 am

Post » Fri May 27, 2011 3:46 am

But what is the variable for? In the script you posted it has no use.


Sorry, I should have mentioned. It is used in various checks for other scripts, but only when these other scripts run. For example, if it is 1, when you activate a cave entrance somewhere else, it lets you climb down into the cave. But that script only runs when you activate the cave. In my tests, this script is crashing wherever, and whenever I use it. (so far)

As for the spelling, it is consistent in the esp, it's just that typed up the quest script from memory, and spelt it with two p's.
User avatar
Emzy Baby!
 
Posts: 3416
Joined: Wed Oct 18, 2006 5:02 pm

Post » Fri May 27, 2011 3:21 am

Well, the only differences that I can see between the two scripts are:
- The item that is added and the item that is removed
- The add & remove order (on crashing script you add 1 item, then remove the other. Other way round for ok script)

Is the problem somehow caused by removing the item that the script is running on? I've not scripted for a few months now but I think that can cause problems.

Are the scripts attached to the correct items? I presume you created the second rope item in the CS by duplicating the first and changing the name, etc. Did you remember to change the script as well?
User avatar
Nathan Hunter
 
Posts: 3464
Joined: Sun Apr 29, 2007 9:58 am

Post » Fri May 27, 2011 3:48 pm

The items added/removed are basically identical, but one has the phrase "(equipped)" after "Rope". They have different scripts, and they are definitely the right ones, I just checked again.

The remove order - I hadn't noticed that. It's odd that they are not/are working in that arrangement. I've read that removeitem on a item running that script acts as a return, which is why in the non-functioning one (the one I wrote second) I put it at the bottom of the block. I'm going to test it the other way round now.

EDIT - Tested it with that block rearranged, but it still didn't work. I'm going to put some debug markers in it, and test it from a different, entirely clean save, and then maybe remake the objects involved with different ids. Ugh.

EDIT2 - Well, joy, I tested it with a clean save and now both scripts are crashing! :banghead: I think I'll just scrap them and use a different method.
User avatar
Bethany Short
 
Posts: 3450
Joined: Fri Jul 14, 2006 11:47 am

Post » Fri May 27, 2011 9:51 am

I just did a quick test. It seems that adding an item in the same frame as removing the item that the script is running on causes a CTD.

I tested both GameMode and MenuMode, and with two different orders (add then remove, remove then add).

If you allow one frame to elapse between adding the item and removing the current it should work fine.

Example for clarity:

	if ControlVar == 1		set Button to GetButtonPressed		if Button == 0			set RPSQuicksandControlQuest.PlayerHasRopeEquiped to 0			player.AddItemNS RPSQuicksandRope 1			set controlvar to 2		elseif button == 1			set controlvar to 0		endif	elseif ControlVar == 2		player.RemoveItemNS RPSQuicksandRopeEquipped 1	endif

User avatar
Nathan Maughan
 
Posts: 3405
Joined: Sun Jun 10, 2007 11:24 pm

Post » Fri May 27, 2011 7:03 am

Wow, thanks Horny Quintus! It's a good thing that rather than simply scrapping the method and starting a new one, I closed the CS and did something else instead! :D Thank you! :)
User avatar
JUan Martinez
 
Posts: 3552
Joined: Tue Oct 16, 2007 7:12 am


Return to IV - Oblivion