Asking for help with my house mod

Post » Sat Feb 19, 2011 3:42 am

I made a previous thread relating to this, but I thought it was necessary to post a more generalized thread for the topic. I am currently creating a house mod for Morroblivion, which probably will be released depending on how well it turns out. There are a few problems I've been having, and there are a few problems I'll probably run into in the future during its creation. Considering this is my first house mod (and first mod I've worked on in a very long time), I will and have been running into problems periodically that I am incapable of finding the solutions to on my own. Thats why I am requesting guidance for the problems I run into here, if anyone feels up to helping me out.

My newest problem is something thats gone wrong with the following script:

scriptname AAAMineExtension1short dooncebegin onaddif ( doonce == 0 )	setitemvalue 0	set doonce to 1	MineSegment1C.enable	MineSegment1D.enable	MineSegment1A.disable	MineSegment1B.disable	Mineworker2.enable	Foremancrate.additem 030056D3 1	message "You have purchased Construction Orders to expand your mine. Earnings can be found in the newly constructed segment of the mine."	endifend


When executed, this script apparently repeats itself indefinitely, sending you the same message over and over, and adding the same item to the "Foremancrate" repeatedly. I'm guessing theres a line I need to add somewhere to tell the script to stop itself.

Any help I may recieve will be greatly appreciated :)
User avatar
Ludivine Poussineau
 
Posts: 3353
Joined: Fri Mar 30, 2007 2:49 pm

Post » Sat Feb 19, 2011 7:46 am

Is the item you are adding in the script the same as the item that the script is attached to? If it is then the script will run again when the additem bit is run, adding another item to the crate which will make the script run again and add yet another one etc etc. Thats why the script repeats itself every frame. If the script is activated by the addition of an item to a crate, do you need the additem line? The item should still be in the crate.

On a side note, its not a good idea to use the form id when referring to items, use the editor id. As in change the 030056D3 to the actual name of the item.
User avatar
Frank Firefly
 
Posts: 3429
Joined: Sun Aug 19, 2007 9:34 am

Post » Sat Feb 19, 2011 2:25 am

Is the item you are adding in the script the same as the item that the script is attached to? If it is then the script will run again when the additem bit is run, adding another item to the crate which will make the script run again and add yet another one etc etc. Thats why the script repeats itself every frame. If the script is activated by the addition of an item to a crate, do you need the additem line? The item should still be in the crate.

On a side note, its not a good idea to use the form id when referring to items, use the editor id. As in change the 030056D3 to the actual name of the item.


Wow, I certainly feel stupid :P

How would I go about running the script only when the item is added to the player's inventory, and not any inventory?
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Sat Feb 19, 2011 12:09 pm

Use:
Begin OnAdd Player
as your block. This can be done with any container by placing the container ref after OnAdd. e.g.
Begin OnAdd [your containers ref]
will run the block only when the item is added to that specific container.

Have a look at http://cs.elderscrolls.com/constwiki/index.php/OnAdd page for more info.

Just to clarify my previous point, its not a good idea to use form ids in scripts because the form id changes depending on the load order of the mod. The second number (i think) increments by one for every place down the load order the mod that contains that item is.
User avatar
Claire Mclaughlin
 
Posts: 3361
Joined: Mon Jul 31, 2006 6:55 am

Post » Sat Feb 19, 2011 3:06 am

Use:
Begin OnAdd Player
as your block. This can be done with any container by placing the container ref after OnAdd. e.g.
Begin OnAdd [your containers ref]
will run the block only when the item is added to that specific container.

Have a look at http://cs.elderscrolls.com/constwiki/index.php/OnAdd page for more info.


Thanks for your help, the script is working nicely now. :)

Heres another question I have, which may be a bit more complex than the last one. Basically I'm in the process of making a mine that you can purchase for your house, and you can collect periodic earnings from it depending on how much you've previously upgraded your mine. The script I posted earlier is the script that is run when you upgrade your mine for the first time (each time the mine is ugraded a new section is added). Basically I'm putting chests that contain your "earnings" in each segment of the mine, so when you want to collect what your workers have retrieved from your mine, you go through and loot each of the chests that contain your earnings throughout the length of the mine.

What I'm having trouble with is the refreshing of the earnings chests. I set them to "respawn", but I don't think that will impliment the function that they should have in the best manner possible. Ideally, I'd like all of the chests to refresh their contents simultaneously once every few days, and send you a message each time they do, telling you that you are now able to collect your earnings.

I'm not very positive exactly on what would be the best way to execute this function. Any ideas or thoughts?

EDIT-

I just changed each of the scripts that used Form IDs to utilize their Editor IDs instead. Thanks for the suggestion :)
User avatar
Fam Mughal
 
Posts: 3468
Joined: Sat May 26, 2007 3:18 am

Post » Fri Feb 18, 2011 11:45 pm

Have a quest script that starts once you first get the mine going. Have it track your upgrade progress for the mine, and use a timer to add whatever to the appropriate chests, depending on how upgraded the mine is. If you use the respawn method, if you miss a trip to collect your earnings, when the container respawns, that earnings that are currently there will be gone, and only the most recent earnings will be present. With the script just adding whatever to the chests, earnings will be cumulative. Which I think is what you want anyway.
User avatar
D LOpez
 
Posts: 3434
Joined: Sat Aug 25, 2007 12:30 pm

Post » Sat Feb 19, 2011 1:34 am

Have a quest script that starts once you first get the mine going. Have it track your upgrade progress for the mine, and use a timer to add whatever to the appropriate chests, depending on how upgraded the mine is. If you use the respawn method, if you miss a trip to collect your earnings, when the container respawns, that earnings that are currently there will be gone, and only the most recent earnings will be present. With the script just adding whatever to the chests, earnings will be cumulative. Which I think is what you want anyway.


Alright, that sounds like a really good idea. I'm not experienced at scripting yet, but I plan to be sooner than later, so with that in mind try to bear with me as I try to work my way through getting this script running.

A question I have is, if there are chests that are disabled, and the script tries to add earnings to those chests, will the contents that the script tried to add to them be there when they become enabled? Or will the script just not put the contents into them because they are disabled? Or will I have to use a getif disabled command?

I also would like to know how to set a timer, because that is something I don't know much at all about, and as far as I've seen is one of the more complicated scripting functions.

EDIT---

Also, if I can actually figure out how to set timers on scripts correctly, I could add some realism to this mod by creating a waiting period between the purchase of a construction order and the enabling of the corresponding addition to the house, therefor adding a sort of simulated construction time for each addition, rather than the addition magically appearing there the second you purchase it. One of my main aims for this mod is to replicate the town creation system Bethesda set up when you build Raven Rock in the Bloodmoon expansion for Morrowind, except in a more concentrated household setting.
User avatar
matt oneil
 
Posts: 3383
Joined: Tue Oct 09, 2007 12:54 am

Post » Fri Feb 18, 2011 11:43 pm

Yes, you will have to check and see if the chests are disabled first, and if they are, don't add anything.

Not really so much a Timer, as a Counter. When the mine is first opened, set a variable to the current game day. Call it LastUpdate. Then have the script compare CurrentDay (a variable set by the script for comparison purposes) and compare LastUpdate, with CurrentDay, if CurrentDay is >= LastUpdate + whatevertimeframeformoreearnings..... add the new earnings to the chest, and set LastUpdate to CurrentDay. If it isn't, don't do anything. :D

Make sense?
User avatar
Eliza Potter
 
Posts: 3481
Joined: Mon Mar 05, 2007 3:20 am

Post » Sat Feb 19, 2011 10:19 am

Maybe GameDaysPassed would be better, in case the waiting period goes into the next month, and the GameDay global variable will go from 30 (or whatever, depending on the month) to 0, thereby breaking the code.

I would do:
If doonce == 0   Set purchaseday to GameDaysPassed ;hid this in a do-once variable to prevent it begin reset every frame   Set doonce to 1EndIfIf GameDaysPassed >= purchaseday + 7 ;(or however many days you want to wait)   ;do stuffEndIf


Have a look at http://cs.elderscrolls.com/constwiki/index.php/Category:Time_Functions functions for more info.
User avatar
Auguste Bartholdi
 
Posts: 3521
Joined: Tue Jun 13, 2006 11:20 am

Post » Sat Feb 19, 2011 7:53 am

Maybe GameDaysPassed would be better, in case the waiting period goes into the next month, and the GameDay global variable will go from 30 (or whatever, depending on the month) to 0, thereby breaking the code.

I would do:
If doonce == 0   Set purchaseday to GameDaysPassed ;hid this in a do-once variable to prevent it begin reset every frame   Set doonce to 1EndIfIf GameDaysPassed >= purchaseday + 7 (or however many days you want to wait   ;do stuffEndIf


Have a look athttp://cs.elderscrolls.com/constwiki/index.php/Category:Time_Functionsfunctions for more info.


Ooo, good point, and great idea. :D
User avatar
Lori Joe
 
Posts: 3539
Joined: Tue Jun 20, 2006 6:10 am

Post » Sat Feb 19, 2011 8:32 am

Yes, you will have to check and see if the chests are disabled first, and if they are, don't add anything.

Not really so much a Timer, as a Counter. When the mine is first opened, set a variable to the current game day. Call it LastUpdate. Then have the script compare CurrentDay (a variable set by the script for comparison purposes) and compare LastUpdate, with CurrentDay, if CurrentDay is >= LastUpdate + whatevertimeframeformoreearnings..... add the new earnings to the chest, and set LastUpdate to CurrentDay. If it isn't, don't do anything. :D

Make sense?


Haha, I'm really losing you. :wacko: I don't really have enough experience with scripting to truely understand how I would start writing up the script.

This is probably too much to ask, but could you write up a sample script to get me on the right track? Here's the original script that is run when you purchase the Construction Orders for the mine:

scriptname AAAConstructionOrdersMineshort dooncebegin onaddif ( doonce == 0 )	setitemvalue 0	set doonce to 1	Minedoorframe.enable	Minedoor.enable	messagebox "You have purchased Construction Orders dictating the addition of a mine to your underground estate. These orders also include the contracts of multiple mine workers."endifend


I think all I need is some handholding at first so that I can get up on my feet and be independent from now on.

EDIT---

Alright, I didn't see Jack's post until now. That makes it much more clear for me to understand, but I'm not sure exactly how I would fit that into my script; or should I attach your script to a quest?

EDIT---

I created a script to what I think is considered as on the right track. Its connected to a quest that will be added when you purchase the mine. Here it is thus far:

Scriptname AAAMineEarningsQuestScriptshort dooncefloat purchasedaybegin gamemode	if doonce == 0	Set purchaseday to GameDaysPassed 	Set doonce to 1EndIf	If GameDaysPassed >= purchaseday + 5EndIfEnd


Now if all is right I just need to add in the part of the script that puts the earnings into the chest, correct?
User avatar
Roy Harris
 
Posts: 3463
Joined: Tue Sep 11, 2007 8:58 pm

Post » Sat Feb 19, 2011 3:25 am

Well, as HeyYou said, you will need a quest script to keep track of the days gone passed since you purchased the construction orders, then enabled the extension to the mine after a predetermined amount of days. I would change your existing script to this:
scriptname AAAConstructionOrdersMineshort dooncebegin onaddif ( doonce == 0 )        setitemvalue 0        set doonce to 1        StartQuest AAAConstructionOrdersQuest ;New quest you will need to put in, make sure it is NOT start-game enabled        messagebox "You have purchased Construction Orders dictating the addition of a mine to your underground estate. These orders also include the contracts of multiple mine workers." ;Maybe add in a bit here about having to wait for a week or whatever.endifend


The script attached to the new quest might look like this:

scn AAAConstructionOrdersQuestScriptshort doonceshort purchasedayBegin GameModeIf doonce == 0        Set purchaseday to GameDaysPassed ;hid this in a do-once variable to prevent it begin reset every frame        Set doonce to 1EndIfIf GameDaysPassed >= purchaseday + 7 ;(or however many days you want to wait)        MineDoorFrame.Enable        MineDoor.Enable        Set doonce to 0        StopQuest AAAConstructionOrdersQuestEndIf


Is this construction orders thing only gonna happen once? If it is then you can remove the set doonce to 0 bit as its unnecessary then. And just incase you missed the comment above, make sure the quest is not start-game enabled, your basically calling on it to run in the background for as long as you need it, this is why quest scripts aree so useful :D

EDIT:

I think I may have misunderstood what you wanted the timer for actually. If its for waiting to activate the mine extension leave it as above, but if its for the earnings then put the additem stuff where Ive put the MineDoor.Enable stuff and move the enabling to the item script (the onadd stuff) it you wanted that to happen instantly.
User avatar
Kelly Tomlinson
 
Posts: 3503
Joined: Sat Jul 08, 2006 11:57 pm

Post » Sat Feb 19, 2011 8:41 am

Ok, Create a quest: MyHouseMineQuest, or some such, and have a quest script on it. (we will get to that.) Do NOT have it set as a start quest. (starts running as soon as you start a new game. Needs to be called to run.)

Modify the above script like so:

scriptname AAAConstructionOrdersMineshort dooncebegin onaddif ( doonce == 0 )        setitemvalue 0        set doonce to 1        Minedoorframe.enable        Minedoor.enable        messagebox "You have purchased Construction Orders dictating the addition of a mine to your underground estate. These orders also include the contracts of multiple mine workers."        startquest MyHouseMineQuest        set MyHouseMineQuest.LastUpdate to gamedayspassedendifend


Then, for the quest script:

scn MyHouseMineQuestScriptshort LastUpdateshort CurrentDayset currentday to gamedayspassed <- I think you can do this.... not sure.....If ( currentday - lastupdate >= 3 ) ; will update chests every three days.     set lastupdate to currentday     if ( firststagechestname.isdisabled == 0 )          firststagechestname.additem {editorID of what you want to add} {how many you want to add}     endif     if ( secondstagechestname.isdisabled == 0 )etc.


Or, something like that at least. Get the general Idea?

LOLOL. Ninjaed jackbarnard. :D
User avatar
Josephine Gowing
 
Posts: 3545
Joined: Fri Jun 30, 2006 12:41 pm

Post » Fri Feb 18, 2011 10:49 pm

Lol yea with the one I put up there, if you wanted it to repeat, (ie do stuff every 7 days until the end of time ;) ) then remove the StopQuest bit, then it would be pretty much identical to HeyYou's.
User avatar
megan gleeson
 
Posts: 3493
Joined: Wed Feb 07, 2007 2:01 pm

Post » Sat Feb 19, 2011 6:38 am

Okay, heres what I got for the quest script:

Scriptname AAAMineEarningsQuestScriptshort doonceshort purchasedaybegin gamemode	if doonce == 0	Set purchaseday to GameDaysPassed 	Set doonce to 1EndIf	If GameDaysPassed >= purchaseday + 5	Set doonce to 0	Earningschest1.additem 000MineEarningsRandomizedEbony 6	Earningschest1.additem 000MineEarningsRandomizedDiamond 3	Earningschest1.additem 000MineEarningsRandomizedEmerald 3	Earningschest1.additem 000MineEarningsRandomizedGlass 5	Message "Your earnings from the mine are ready to be collected."EndIfend


Does that look about right? I will add more chests to the section of the script where I add their contents to them. Also, am I going to have to put in a section that detects if the chests are disabled so it doesn't add contents to the chests that are in the segments of the mine that haven't been constructed yet?
User avatar
Louise Dennis
 
Posts: 3489
Joined: Fri Mar 02, 2007 9:23 pm

Post » Sat Feb 19, 2011 6:36 am

Okay, heres what I got for the quest script:

Scriptname AAAMineEarningsQuestScriptshort doonceshort purchasedaybegin gamemode	if doonce == 0	Set purchaseday to GameDaysPassed 	Set doonce to 1EndIf	If GameDaysPassed >= purchaseday + 5	Set doonce to 0	Earningschest1.additem 000MineEarningsRandomizedEbony 6	Earningschest1.additem 000MineEarningsRandomizedDiamond 3	Earningschest1.additem 000MineEarningsRandomizedEmerald 3	Earningschest1.additem 000MineEarningsRandomizedGlass 5	Message "Your earnings from the mine are ready to be collected."EndIfend


Does that look about right? I will add more chests to the section of the script where I add their contents to them. Also, am I going to have to put in a section that detects if the chests are disabled so it doesn't add contents to the chests that are in the segments of the mine that haven't been constructed yet?


Yea you would need to check the enabled state of the chests using http://cs.elderscrolls.com/constwiki/index.php/GetDisabled. So for the one chest you have scripted so far, it would change to:

Scriptname AAAMineEarningsQuestScriptshort doonceshort purchasedaybegin gamemodeif doonce == 0	Set purchaseday to GameDaysPassed 	Set doonce to 1EndIfIf GameDaysPassed >= purchaseday + 5	Set doonce to 0        If Earningschest1.GetDisabled == 0	        Earningschest1.additem 000MineEarningsRandomizedEbony 6	        Earningschest1.additem 000MineEarningsRandomizedDiamond 3	        Earningschest1.additem 000MineEarningsRandomizedEmerald 3	        Earningschest1.additem 000MineEarningsRandomizedGlass 5        EndIf        ;add getdisabled checks for the other chests	Message "Your earnings from the mine are ready to be collected."EndIfend

User avatar
Kelvin
 
Posts: 3405
Joined: Sat Nov 17, 2007 10:22 am

Post » Fri Feb 18, 2011 10:12 pm

Alright, everything is working correctly thus far except for one thing. For some reason I can't attach the script to the quest in the quest window. Any idea what the reason for that could be?
User avatar
jeremey wisor
 
Posts: 3458
Joined: Mon Oct 22, 2007 5:30 pm

Post » Sat Feb 19, 2011 5:55 am

Alright, everything is working correctly thus far except for one thing. For some reason I can't attach the script to the quest in the quest window. Any idea what the reason for that could be?


Have you saved it as a Quest Script? In the script edit window change the script type at the top to 'Quest'. I think it defaults to 'Object'.
User avatar
willow
 
Posts: 3414
Joined: Wed Jul 26, 2006 9:43 pm

Post » Fri Feb 18, 2011 7:53 pm

Have you saved it as a Quest Script? In the script edit window change the script type at the top to 'Quest'. I think it defaults to 'Object'.


Ahh, perfect :) Thank you. This should be working soon. With my luck there will certainly be a problem once I set all these scripts up, so I'll let you guys know if I have any further troubles when I make a new post in a few hours.
User avatar
TWITTER.COM
 
Posts: 3355
Joined: Tue Nov 27, 2007 3:15 pm

Post » Sat Feb 19, 2011 9:16 am

Ahh, perfect :) Thank you. This should be working soon. With my luck there will certainly be a problem once I set all these scripts up, so I'll let you guys know if I have any further troubles when I make a new post in a few hours.


I stopped work on the mod for a few days but now I'm back at it. And I'm having a problem with path grid editting. I set a path grid to reference a chair, and when I did, all other path grid nodes were set to reference it too. There are purple lines leading from every single node on the map to that one single reference. Any ideas?
User avatar
JERMAINE VIDAURRI
 
Posts: 3382
Joined: Tue Dec 04, 2007 9:06 am


Return to IV - Oblivion