great. I overfed my script

Post » Wed Dec 30, 2009 4:54 am

max script size exceeded....

how do I split it and such?

it is being done for mmm and ooo, can I do it this way?

one mod to go for ooo, another that deals with mmm
and then use both at once?
User avatar
Cody Banks
 
Posts: 3393
Joined: Thu Nov 22, 2007 9:30 am

Post » Wed Dec 30, 2009 8:51 am

Try using OBSE - it removes one limit (there's still another, but it's often higher). Pretty sure the game doesn't even need to be run using OBSE to take advantage of that, you just need to use OBSE to open the editor so it can remove that restriction.
User avatar
Joanne Crump
 
Posts: 3457
Joined: Sat Jul 22, 2006 9:44 am

Post » Tue Dec 29, 2009 11:21 pm

Try using OBSE - it removes one limit (there's still another, but it's often higher). Pretty sure the game doesn't even need to be run using OBSE to take advantage of that, you just need to use OBSE to open the editor so it can remove that restriction.


thanks, let me go read up on that... only used obse to play
User avatar
Nikki Hype
 
Posts: 3429
Joined: Mon Jan 01, 2007 12:38 pm

Post » Wed Dec 30, 2009 2:58 am

ok, loaded the CS through wrye with obse active

warning max script size exceeded at line 662

the script has a total of 961 lines

I must be doing something wrong.


that and windows 7 keeps giving me the program is not responding, so we are closing it... when it is compiling!
User avatar
Richus Dude
 
Posts: 3381
Joined: Fri Jun 16, 2006 1:17 am

Post » Wed Dec 30, 2009 4:36 am

It would freeze if the process started using up too much memory or started banging on the CPU. That must be a really big script or maybe there is a loop or leak in the script somewhere. I have no idea how to debug TESCS scripts though. Try double-checking it for possible errors of that nature I guess.
User avatar
Yvonne
 
Posts: 3577
Joined: Sat Sep 23, 2006 3:05 am

Post » Tue Dec 29, 2009 9:29 pm

If your script is really too big, and it consists of a whole lot of "if/then" statements when checking for certain items then you can pull a bit of a trick with it.

Have the original script start normally, whether it be a quest script or a object script on an item. Use that script to narrow down the type of item if you can (misc/potion/ingredient/armor/weapon/whatever). If you can do this, then start a quest script based on what type of item it is.

If you can't separate the types of items in this manner, then instead start all your "If/then" statements, and when you run out of script room do an:

else
startquest sorterquestpart2

and pass the process off to the next quest script. If the starting script is a quest script, then the second script can reference the variables from the first quest script. If it's an object script, then you may have to manually copy the variables to the second script in order to continue.
User avatar
Darlene Delk
 
Posts: 3413
Joined: Mon Aug 27, 2007 3:48 am

Post » Tue Dec 29, 2009 11:50 pm

If your script is really too big, and it consists of a whole lot of "if/then" statements when checking for certain items then you can pull a bit of a trick with it.

Have the original script start normally, whether it be a quest script or a object script on an item. Use that script to narrow down the type of item if you can (misc/potion/ingredient/armor/weapon/whatever). If you can do this, then start a quest script based on what type of item it is.

If you can't separate the types of items in this manner, then instead start all your "If/then" statements, and when you run out of script room do an:

else
startquest sorterquestpart2

and pass the process off to the next quest script. If the starting script is a quest script, then the second script can reference the variables from the first quest script. If it's an object script, then you may have to manually copy the variables to the second script in order to continue.



it is page after page of

set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailHelmetWorn * 1)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailGauntletsWorn * 1)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailBootsWorn * 2)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailGreavesWorn * 4)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailCuirassWorn * 8)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailShieldWorn * 3)

set cNewIron to cNewIron + (CNTRef.GetItemCount IronHelmetWorn * 4)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronGauntletsWorn * 4)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronBootsWorn * 6)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronGreavesWorn * 12)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronCuirassWorn * 20)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronShieldWorn * 8)

listing items from Vanilla, MMM, and OOO armor and weapons, Non unique metal only. there are just that many items and I dont know how to break it into sections in order to use a few smaller scripts.
User avatar
Siidney
 
Posts: 3378
Joined: Fri Mar 23, 2007 11:54 pm

Post » Wed Dec 30, 2009 4:53 am

What activates the grinding process? Is it an item script or a quest script that is always running?
User avatar
Abel Vazquez
 
Posts: 3334
Joined: Tue Aug 14, 2007 12:25 am

Post » Tue Dec 29, 2009 9:32 pm

What activates the grinding process? Is it an item script or a quest script that is always running?


this is the activator. the script isnt mine, its an old one being revamped, the modder left the community a few years ago as far as I can tell so reverse engineering it... if only I could engineer forward


scn HaroKArrowForgeScript

short Selected

short num

begin OnAdd
if (HaroKArrowForgeGot == 0)
Set HaroKArrowForgeGot to 1
MessageBox "You've got the Arrow Forge. You can now recycle most any non-magical equipments and reforge them into arrows. Remember that nothing but arrows will left when the reaction stoped! Don't put anything important in the Forge! To enchant arrows, put ingredients with proper Effect in Forge with them. Make sure the Effect is powerful enough to meet the requirement. You can increase the Effect by drop multiple ingredients. Get your Armorer and Alchemy skills higher to help you out."
endif
end

begin OnEquip
if (HaroKArrowForgeQST.Crafting == 0)
SetQuestObject HaroKArrowForge 1
HaroKArrowForgeCNT.Activate player 1
set Selected to 1
;Message "The forging will start as soon as you close the inventory. EVERYTHING in the Forge will be lost when the work is finished."
set HaroKArrowForgeQST.DoOnce to 1
StartQuest HaroKArrowForgeQST
else
Message "The Forge is too hot. You can barely touch it."
endif
end

begin MenuMode 1002
if (Selected == 1)
set Selected to 0
SetQuestObject HaroKArrowForge 0
endif
end
User avatar
Rachel Hall
 
Posts: 3396
Joined: Thu Jun 22, 2006 3:41 pm

Post » Wed Dec 30, 2009 4:20 am

Looks like there's quest script that does the actual counting (or maybe an object script on the HaroKArrowForge).

What you'd likely want to do is have that script set a variable and activate another quest with part of your script on it:

If questcount == 0
set questcount to 1
startquest ArrowForgeCountingQuestOne
Endif

Then in the script attached to ArrowForgeCountingQuestOne you count all the armor components and send the variable back to the original script:

set HaroKArrowForge.cNewIron to HaroKArrowForge.cNewIron + (CNTRef.GetItemCount ChainmailHelmetWorn * 1)
set HaroKArrowForge.cNewIron to HaroKArrowForge.cNewIron + (CNTRef.GetItemCount ChainmailGauntletsWorn * 1)
set HaroKArrowForge.cNewIron to HaroKArrowForge.cNewIron + (CNTRef.GetItemCount ChainmailBootsWorn * 2)
set HaroKArrowForge.cNewIron to HaroKArrowForge.cNewIron + (CNTRef.GetItemCount ChainmailGreavesWorn * 4)

and so on. At the end you can pass the script back to the original script by setting HaroKArrowForge.questcount to 2 in order to activate the next part of the counting:

If questcount == 2
set questcount to 3
startquest ArrowForgeCountingQuestTwo
Endif

Then in ArrowForgeCountingQuestTwo, you count all the weapons, and pass the information back to the original script again, same as above.

Or, at the end of ArrowForgeCountingQuestOne you can do a direct startquest of QuestTwo.

When you've gone all the way through as many quest scripts as you need, the main quest will have all the counts from the container added up in it, so then you can add the arrows to the player based on those counts.
User avatar
Devils Cheek
 
Posts: 3561
Joined: Sun Aug 13, 2006 10:24 pm

Post » Wed Dec 30, 2009 10:12 am

Looks like there's quest script that does the actual counting (or maybe an object script on the HaroKArrowForge).

What you'd likely want to do is have that script set a variable and activate another quest with part of your script on it:

If questcount == 0
set questcount to 1
startquest ArrowForgeCountingQuestOne
Endif

Then in the script attached to ArrowForgeCountingQuestOne you count all the armor components and send the variable back to the original script:

set HaroKArrowForge.cNewIron to HaroKArrowForge.cNewIron + (CNTRef.GetItemCount ChainmailHelmetWorn * 1)
set HaroKArrowForge.cNewIron to HaroKArrowForge.cNewIron + (CNTRef.GetItemCount ChainmailGauntletsWorn * 1)
set HaroKArrowForge.cNewIron to HaroKArrowForge.cNewIron + (CNTRef.GetItemCount ChainmailBootsWorn * 2)
set HaroKArrowForge.cNewIron to HaroKArrowForge.cNewIron + (CNTRef.GetItemCount ChainmailGreavesWorn * 4)

and so on. At the end you can pass the script back to the original script by setting HaroKArrowForge.questcount to 2 in order to activate the next part of the counting:

If questcount == 2
set questcount to 3
startquest ArrowForgeCountingQuestTwo
Endif

Then in ArrowForgeCountingQuestTwo, you count all the weapons, and pass the information back to the original script again, same as above.

Or, at the end of ArrowForgeCountingQuestOne you can do a direct startquest of QuestTwo.

When you've gone all the way through as many quest scripts as you need, the main quest will have all the counts from the container added up in it, so then you can add the arrows to the player based on those counts.


ok, I will give this a try after I finish up something I left on the back burner about 4 years ago. I have never scripted, so this one will take time, the other involves no scripting...
User avatar
joannARRGH
 
Posts: 3431
Joined: Mon Mar 05, 2007 6:09 am

Post » Wed Dec 30, 2009 8:21 am

The important thing to remember is that scripts can alter variables in other scripts that are attached to quests or persistent objects.

That means that your main script can do nothing but keep track of your variables and do the actual crafting based on those variables (counts) while a series of other scripts can do the actual counting and just update the variables in the main script.

Biggest mod I've ever seen that uses this method is Living Economy. Huge scripts, incredibly complex.

Of course, this is all done far easier with OBSE if you are able to use that instead of using the brute force method.
User avatar
He got the
 
Posts: 3399
Joined: Sat Nov 17, 2007 12:19 pm

Post » Wed Dec 30, 2009 12:21 am

The important thing to remember is that scripts can alter variables in other scripts that are attached to quests or persistent objects.

That means that your main script can do nothing but keep track of your variables and do the actual crafting based on those variables (counts) while a series of other scripts can do the actual counting and just update the variables in the main script.

Biggest mod I've ever seen that uses this method is Living Economy. Huge scripts, incredibly complex.

Of course, this is all done far easier with OBSE if you are able to use that instead of using the brute force method.



there are 3 scripts in this mod, 1 for the activator, 1 for listing the enchanting, 1 for listing armor and weapons. if I can make a fourth one to handle just the iron part of the armor and weapons, that would take about a fourth of the script size off the third script.

and even tho the obse has functions and all listed. I need actual working scripts to study and dissect. its one of the best ways I can learn.
User avatar
Jonathan Egan
 
Posts: 3432
Joined: Fri Jun 22, 2007 3:27 pm

Post » Tue Dec 29, 2009 8:06 pm

it is page after page of

set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailHelmetWorn * 1)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailGauntletsWorn * 1)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailBootsWorn * 2)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailGreavesWorn * 4)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailCuirassWorn * 8)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailShieldWorn * 3)

set cNewIron to cNewIron + (CNTRef.GetItemCount IronHelmetWorn * 4)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronGauntletsWorn * 4)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronBootsWorn * 6)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronGreavesWorn * 12)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronCuirassWorn * 20)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronShieldWorn * 8)

listing items from Vanilla, MMM, and OOO armor and weapons, Non unique metal only. there are just that many items and I dont know how to break it into sections in order to use a few smaller scripts.


If you are just exceeding the 32K text limit for the script, and not by a ton, you could probably optimize the above code a bit. Something like this maybe...

	short x	set x to CNTRef.GetItemCount ChainmailHelmetWorn * 1 + x	set x to CNTRef.GetItemCount ChainmailGauntletsWorn * 1 + x	set x to CNTRef.GetItemCount ChainmailBootsWorn * 2 + x	set x to CNTRef.GetItemCount ChainmailGreavesWorn * 4 + x	set x to CNTRef.GetItemCount ChainmailCuirassWorn * 8 + x	set x to CNTRef.GetItemCount ChainmailShieldWorn * 3 + x	set x to CNTRef.GetItemCount IronHelmetWorn * 4 + x	set x to CNTRef.GetItemCount IronGauntletsWorn * 4 + x	set x to CNTRef.GetItemCount IronBootsWorn * 6 + x	set x to CNTRef.GetItemCount IronGreavesWorn * 12 + x	set x to CNTRef.GetItemCount IronCuirassWorn * 20 + x	set x to CNTRef.GetItemCount IronShieldWorn * 8 + x	set cNewIron to x


Just over that small section that would save about 200 bytes.
User avatar
Andrew Perry
 
Posts: 3505
Joined: Sat Jul 07, 2007 5:40 am

Post » Tue Dec 29, 2009 9:09 pm

Use Obse user-made functions, they are incredibly easy to use. Just divide the stuff into a few groups, copy paste the script parts into a few functions and just call the functions.


I?ll give you an example by converting your code snippet below into a function:

it is page after page of

set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailHelmetWorn * 1)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailGauntletsWorn * 1)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailBootsWorn * 2)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailGreavesWorn * 4)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailCuirassWorn * 8)
set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailShieldWorn * 3)

set cNewIron to cNewIron + (CNTRef.GetItemCount IronHelmetWorn * 4)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronGauntletsWorn * 4)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronBootsWorn * 6)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronGreavesWorn * 12)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronCuirassWorn * 20)
set cNewIron to cNewIron + (CNTRef.GetItemCount IronShieldWorn * 8)

listing items from Vanilla, MMM, and OOO armor and weapons, Non unique metal only. there are just that many items and I dont know how to break it into sections in order to use a few smaller scripts.



Go into "edit scripts", and start a new script (Object type of script, but not inside any actual Object).

The funtion would look like this:

scn fucntionCountItemsref CNTRefshort cNewIronbegin Function {CNTRef} ;this is a parameter passed to the function, and gets stored into the ref variable above automatically;this is your code you copypasted hereset cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailHelmetWorn * 1)	set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailGauntletsWorn * 1)	set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailBootsWorn * 2)	set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailGreavesWorn * 4)	set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailCuirassWorn * 8)	set cNewIron to cNewIron + (CNTRef.GetItemCount ChainmailShieldWorn * 3)	set cNewIron to cNewIron + (CNTRef.GetItemCount IronHelmetWorn * 4)	set cNewIron to cNewIron + (CNTRef.GetItemCount IronGauntletsWorn * 4)	set cNewIron to cNewIron + (CNTRef.GetItemCount IronBootsWorn * 6)	set cNewIron to cNewIron + (CNTRef.GetItemCount IronGreavesWorn * 12)	set cNewIron to cNewIron + (CNTRef.GetItemCount IronCuirassWorn * 20)	set cNewIron to cNewIron + (CNTRef.GetItemCount IronShieldWorn * 8);then you return the result to the "mother script"setfunctionvalue cNewIronend



Then your original, overbloated script converges into a function call:

set cNewIron to call fucntionCountItems CNTRef


or if you want to add to an existing value...

set cNewIron to cNewIron + call fucntionCountItems CNTRef



There, easy isn?t it? :)
User avatar
Roanne Bardsley
 
Posts: 3414
Joined: Wed Nov 08, 2006 9:57 am

Post » Tue Dec 29, 2009 8:44 pm

Use Obse user-made functions, they are incredibly easy to use. Just divide the stuff into a few groups, copy paste the script parts into a few functions and just call the functions.


I´ll give you an example by converting your code snippet below into a function:

Go into "edit scripts", and start a new script (Object type of script, but not inside any actual Object).
Note that since function scripts are also object scripts, it can be called on an object, and therefore be simplified.

scn fucntionCountItemsshort cNewIronbegin Function {};this is your code you copypasted here	set cNewIron to cNewIron + (GetItemCount ChainmailHelmetWorn * 1)	set cNewIron to cNewIron + (GetItemCount ChainmailGauntletsWorn * 1)	set cNewIron to cNewIron + (GetItemCount ChainmailBootsWorn * 2)	set cNewIron to cNewIron + (GetItemCount ChainmailGreavesWorn * 4)	set cNewIron to cNewIron + (GetItemCount ChainmailCuirassWorn * 8)	set cNewIron to cNewIron + (GetItemCount ChainmailShieldWorn * 3)	set cNewIron to cNewIron + (GetItemCount IronHelmetWorn * 4)	set cNewIron to cNewIron + (GetItemCount IronGauntletsWorn * 4)	set cNewIron to cNewIron + (GetItemCount IronBootsWorn * 6)	set cNewIron to cNewIron + (GetItemCount IronGreavesWorn * 12)	set cNewIron to cNewIron + (GetItemCount IronCuirassWorn * 20)	set cNewIron to cNewIron + (GetItemCount IronShieldWorn * 8);then you return the result to the "mother script"setfunctionvalue cNewIronend



Then the call is changed to:

set cNewIron to CNTRef.call fucntionCountItems 


This way the function script runs on the CNTRef object, so no need to pass it explicitely.
User avatar
Cathrine Jack
 
Posts: 3329
Joined: Sat Dec 02, 2006 1:29 am

Post » Tue Dec 29, 2009 8:25 pm

Note that since function scripts are also object scripts, it can be called on an object, and therefore be simplified.

scn fucntionCountItemsshort cNewIronbegin Function {};this is your code you copypasted here	set cNewIron to cNewIron + (GetItemCount ChainmailHelmetWorn * 1)	set cNewIron to cNewIron + (GetItemCount ChainmailGauntletsWorn * 1)	set cNewIron to cNewIron + (GetItemCount ChainmailBootsWorn * 2)	set cNewIron to cNewIron + (GetItemCount ChainmailGreavesWorn * 4)	set cNewIron to cNewIron + (GetItemCount ChainmailCuirassWorn * 8)	set cNewIron to cNewIron + (GetItemCount ChainmailShieldWorn * 3)	set cNewIron to cNewIron + (GetItemCount IronHelmetWorn * 4)	set cNewIron to cNewIron + (GetItemCount IronGauntletsWorn * 4)	set cNewIron to cNewIron + (GetItemCount IronBootsWorn * 6)	set cNewIron to cNewIron + (GetItemCount IronGreavesWorn * 12)	set cNewIron to cNewIron + (GetItemCount IronCuirassWorn * 20)	set cNewIron to cNewIron + (GetItemCount IronShieldWorn * 8);then you return the result to the "mother script"setfunctionvalue cNewIronend



Then the call is changed to:

set cNewIron to CNTRef.call fucntionCountItems 


This way the function script runs on the CNTRef object, so no need to pass it explicitely.


so I can do this with each crafting material, glass, ebony, and have em each as seperate functions?

scn fucntionCountIronshort cNewIronbegin Function {};this is your code you copypasted here	set cNewIron to cNewIron + (GetItemCount ChainmailHelmetWorn * 1)	set cNewIron to cNewIron + (GetItemCount ChainmailGauntletsWorn * 1)	set cNewIron to cNewIron + (GetItemCount ChainmailBootsWorn * 2)	set cNewIron to cNewIron + (GetItemCount ChainmailGreavesWorn * 4)	set cNewIron to cNewIron + (GetItemCount ChainmailCuirassWorn * 8)	set cNewIron to cNewIron + (GetItemCount ChainmailShieldWorn * 3)	set cNewIron to cNewIron + (GetItemCount IronHelmetWorn * 4)	set cNewIron to cNewIron + (GetItemCount IronGauntletsWorn * 4)	set cNewIron to cNewIron + (GetItemCount IronBootsWorn * 6)	set cNewIron to cNewIron + (GetItemCount IronGreavesWorn * 12)	set cNewIron to cNewIron + (GetItemCount IronCuirassWorn * 20)	set cNewIron to cNewIron + (GetItemCount IronShieldWorn * 8);then you return the result to the "mother script"setfunctionvalue cNewIronend


with the mother script being scn HaroKArrowForgeQSTScript or just HaroKArrowForgeQSTScript?

set cNewIron to CNTRef.call fucntionCountIron 

User avatar
Roisan Sweeney
 
Posts: 3462
Joined: Sun Aug 13, 2006 8:28 pm

Post » Wed Dec 30, 2009 6:05 am

so I can do this with each crafting material, glass, ebony, and have em each as seperate functions?
Sure. Just give the different functions appropriate names.


with the mother script being scn HaroKArrowForgeQSTScript or just HaroKArrowForgeQSTScript?
Was that a question? I don't think I understood it...
User avatar
Ebou Suso
 
Posts: 3604
Joined: Thu May 03, 2007 5:28 am

Post » Wed Dec 30, 2009 10:39 am

Sure. Just give the different functions appropriate names.


Was that a question? I don't think I understood it...


with the mother script being "scn HaroKArrowForgeQSTScript" or just "HaroKArrowForgeQSTScript"?


been a long time since I programmed, over a decade.


edit: NVM, I figured it out..... :facepalm:


If you are just exceeding the 32K text limit for the script, and not by a ton, you could probably optimize the above code a bit. Something like this maybe... *snip*




yeah, the script in question, this section at least is 55k, so the help you are giving is much needed and even more appreciated.
User avatar
Heather Kush
 
Posts: 3456
Joined: Tue Jun 05, 2007 10:05 pm


Return to IV - Oblivion