Jump to content

I must be worse at scripting than I thought


Khet

Recommended Posts

Alrighty, for those of you who know my current mod I'm working on, I've started my construction script... well, I'm worse at scripting than I thought because I've already ran into a roadblock. I've tried this script about four or five different times and it simply does not work. I won't post the entire thing (only stuff I'm leaving out are all the Short's I haven't used yet, which will be used for the other buildings)

 

Short DoOnce 1
Short CurrentDay
Short DayCount1

Begin GameMode

If DoOnce1 == 0 && GetStage EITownCon 10 && CurrentDay == 0
Set CurrentDay to GameDay
	Else 
If CurrentDay != GameDay
	Set DayCount1 to DayCount1 + 1
	Set CurrentDay to GameDay
		If DayCount1 == 3
		EHouse01.Enable
		endif
endif
endif

 

What the script is supposed to do, is when the player gets to the first quest stage (Stage 10) the script begins and three days later the building is complete and is enabled. Yet, I've waited for about 14 days and nothing has changed. I even tried leaving the island and waiting 14 days with no change.

 

Also, would I be able to recycle my CurrentDay short, or would I need to create a seperate Short for each building, like I need for DoOnce and DayCount?

Link to comment
Share on other sites

There is a ‘==’ missing in the first if: should be “. . . && GetStage EITownCon == 10 && . . .”

 

You could reset your variables to zero after enabling the building (“Set CurrentDay to 0”, etc) so they could be reused for the next building (I am assuming the buildings are built in sequence).

 

But you will either need a DoOnce for each building or create an additional stage (say, you set the stage to 11 after enabling the building) so this block does not run again.

 

And I suppose the extra space in "Short DoOnce 1" is a typo.

Link to comment
Share on other sites

Yes the extra space was a type, I just checked that. And thanks for catching the GetStage. I didn't know it needed the ==. The buildings are infact built in sequence and my current script is set up with a DoOnce for all buildings I just didn't include it in that to save some space. Also, I assume I could set DayCount back to 0 also? Right now I have it set up with DoOnce1 through 10 and DayCount 1 through 10. I'll make the changes and test it out. Wonder why the CS didn't catch the missing == though.

 

Edit: Still no good. Here's the FULL script with everything I currently have. Maybe I made a mistake in one of the parts I excluded from the first. This is a direct copy/paste.

 

scn EITownConstruct

Short DayCount1
Short DayCount2
Short DayCount3
Short DayCount4
Short DayCount5
Short DayCount6
Short DayCount7 
Short DayCount8
Short DayCount9
Short DayCount10
Short DoOnce1
Short DoOnce2
Short DoOnce3
Short DoOnce4
Short DoOnce5
Short DoOnce6
Short DoOnce7
Short DoOnce8
Short DoOnce9
Short DoOnce10
Short CurrentDay

Begin GameMode

If DoOnce1 == 0 && GetStage EITownCon == 10 && CurrentDay == 0
Set CurrentDay to GameDay
	Else 
If CurrentDay != GameDay
	Set DayCount1 to DayCount1 + 1
	Set CurrentDay to GameDay
		If DayCount1 == 3
		EHouseRef01.Enable
		Set DoOnce1 to 1
	endif
endif
endif
End

 

Edit2: I just looked up the GetStage command again on the CS wiki and it says the stage must be completed. Does that mean for the script to run properly the 'active' stage must be 20?

 

http://cs.elderscrolls.com/constwiki/index.php/GetStage

 

Or do I need to use GetStageDone and set the queststage to 20 for the script to run properly?

 

http://cs.elderscrolls.com/constwiki/index.php/GetStageDone

Link to comment
Share on other sites

The way the first if is coded, the Else block will run even if the quest stage is not 10.

Thus, it seems the script is not running at all. Is it a quest script?

 

I suggest something like:

 

short CurrentDay 
short DayCount

If GetStage EITownCon == 10 
if  CurrentDay == 0
	Set CurrentDay to GameDay
ElseIf CurrentDay != GameDay
	Set DayCount1 to DayCount1 + 1
	Set CurrentDay to GameDay
	If DayCount1 == 3
		EHouseRef01.Enable
		set CurrentDay to 0
		set DayCount to 0
		setstage EITownCon 11
	endif
endif
ElseIf GetStage EITownCon == 20 
; etc
endif
end

This code is good as long as you make sure stage 20 does not gets set until the first building is enabled.

If the stages are asynchronous , the code would be different.

 

I am not the best advisor on quest stages, but, as I understand it, a stage is considered done when it is set.

Meaning, is a script issues a ‘SetStage MyQuest 20”, stage 20 is considered done.

 

GetStage is fine if your stages go up in order (10,20,30,etc) (maybe the function should be called GetHighestStageSoFar)

You would need GetStageDone if your buildings could be built in any order, or, even, simultaneously. It works for ascending stages also.

Link to comment
Share on other sites

The only relation to the Construction quest it has is calling up the stages. It runs seperately from the quest (since there are things the player needs to do between each building that is built) so the script should call up only the parts where the buildings should be constructed at.

 

So it's my Else that's messing things up and should be changed to ElseIf? If I'm reading your script right that's the only real difference.

 

Another explination of how the stages would work:

 

Stage 10: Journal update.

Stage 11: Another journal update after building is completed (this was going to be added just after the EHouseRef01.enable line) which also mentions having to talk to the construction master.

 

So the quest CANNOT continue until each building is complete. But there's no point in scripting that little part in if the buildings won't even popup heh.

 

Edit: Ack, it's still not working. I don't know if it means anything but if I type EHouseRef01.Enable into the game console it says something along the lines of non-existant reference. But the house I'm trying to enable is persistant and has a reference.

Link to comment
Share on other sites

So it's my Else that's messing things up and should be changed to ElseIf? If I'm reading your script right that's the only real difference.
Not quite.

Placing several conditions in one IF may be tricky.

The way it was, the else block would run almost all the time because one or more of the conditions would not be true.

 

Suppose the player took some time to get the quest to stage 10: the IF would not be satisfied and the ELSE block would run and start counting the days. The EHouseRef01 would be enabled in 3 days, regardless of the stage (that is why I am guessing the script is not running at all).

 

Checking the stage first, makes sure the block will only run when it is supposed to do so.

 

Another thing that is important is what kind of script it is. Is it a quest script that runs all the time? Or is it attached to some object?

Link to comment
Share on other sites

Wait, maybe that's what I'm doing wrong? I just went to the edit scripts dialogue, made the script and saved it. How do I attatch it to my quest?

 

 

Edit: Nevermind, I changed the Script Type to Quest and it still doesn't work properly. I'm at my wits end here, and I'm sick of staring at this script for the past four hours so I'm gonna take a break for a while... I'll be back later tonight to check on any other ideas.

Link to comment
Share on other sites

Lol . . . I know the feeling. I am struggling with a script of mine for almost a week now.

 

Anyway, scripts must be attached to something: a quest, an object or a spell.

 

In your case, open the Quest Window, locate your quest: in the Quest Data tab there is a drop down box to select the script related to the quest. Find your script in the list and select it.

Link to comment
Share on other sites

Lol . . . I know the feeling. I am struggling with a script of mine for almost a week now.

 

Anyway, scripts must be attached to something: a quest, an object or a spell.

 

In your case, open the Quest Window, locate your quest: in the Quest Data tab there is a drop down box to select the script related to the quest. Find your script in the list and select it.

Link to comment
Share on other sites

Well, I attached the script to the quest and still no go. I just don't get it... it -should- work. I mean it's all there. Once DayCount hits 3 the building should be enabled...

 

Still, could it have something to do with the fact that when I type EHouseRef01.Enable in the console I get an error? And yes the house is marked as Persistant Reference.

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