Category talk:Scripting
Line number limit
Is there a limit to the number of lines a script can contain? I'm currently editing a script with about 52 lines (including debug code to later be stripped), and the CS refuses to save changes beyond a certain point. If I click on the save button, and then try to edit the script editor, I get the "do you want to save this script" message; if I say "yes", it just returns me to the editor. If I say "no", it closes the editor but the changes are not saved.
It _appears_ that if I put any function below line 39, it causes a problem (endifs and ENDS are fine). Perhaps I'm just doing something wrong? Eallman 16:20, 4 April 2006 (EDT)
Later: obviously not the case, since I just found a Beth script with about 150 lines.
Well, very strange. Apparently the problem was that I was passing an elseif without a specific parameter:
if var==1 somecode here else if someothercode here
This SHOULD be a legal structure, and the compiler didn't seem to dislike it. BUt as soon as I changed it to
if var==1 .... elseif var!=1
my saveprob disappeared. Now to debug the script itself, instead of the CS <G> Eallman 16:44, 4 April 2006 (EDT)
That's because else if implies some other condition. Try else instead of else if.--Tegid 12:51, 4 April 2006 (EDT)
- if and elseif require conditions:
if (condition) effect elseif (condition) effect else effect endif
- Note the presence of the condition for both if and elseif; this is mandatory, and if it's omitted and still compiles, that's a compiler bug. (By the way, use four tildes to sign: ~~~~.) —Simetrical (talk • contribs) 21:13, 4 April 2006 (EDT)
DO'H! I'm forgetting by basic programming skills <G> Oddly, though, the compiler doesn't complain about this- the script just won't run <G> Acutally, there are a number of errors the compiler doesn't catch- I just found a typo where I'd substituted "77" for logical "&&", and nary a peep.
But now I've run into another problem. I'm trying to build a script that will allow an item to give a scalar skill boost while it's in inventory based on the player's base skill (You get less benefit the higher your base skill is). Apparently, you can use PLayer.modav with a POSITIVE variable (player.modav var), but you can't decrement the same way (player.modav -var), at least I've found no syntax that the compiler will accept to do this- (I need to do this to "reset" the skill to its regular level). Am I correct in assuming this is a missing feature in the compiler, or am I doing something stupid again?
EA
- Tegid 14:48, 6 April 2006 (EDT): Read the ModAV page again. From my understanding you merely need to set player.modav back to 0 to remove the effect. If that doesn't help, you can always use GetAV and SetAV to do temporary modifications.
Eallman 16:48, 6 April 2006 (EDT)
(thanks for the sig tip) Not according to the page:
"If you use ModActorValue in a script, the Script Modifier is adjusted, and ONLY a script can adjust it back. In other words, if you have a script do
player.modav health 100
you are also responsible for doing
player.modav health -100 ".
So, you need to SPECIFICALLY reduce the mod by an equal amount, BUT the compiler apprently won't accept a negative variable as a parameter, only a positive one.
The problem is constructing the script in sucha way that you gon't get a looped reference from player.getav. Working on it.
Eallman 18:19, 6 April 2006 (EDT)
Found it! To use a negative variable for PLayer.modav, you have to first set ANOTHER variable to the negative value you want to use:
var2= -var1 PLayer.modav var2
very Byzantine, but it does indeed work
A bit off from the original topic:
I don't have any problem using player.modav strength -2 eg in a script... a problem occurs in the console window though.
Try using ModPCAttribute instead, I don't have any problems with this at all.
Or if you want the effect to hit an actor: ModActorValue
Are Script Blocks Atomic
--Tegid 15:19, 12 April 2006 (EDT) When I start executing a script on a particular object, is it guaranteed to finish with the block it is in before being interrupted by another script, or is there no such guarantee?
Eallman 18:50, 14 April 2006 (EDT)
Not even sure how you'd test this, without running a lOT of meesgae blocks by <G>. My initial reaction would be that this would be the case UNLESS you called another script from within the block, but that's gut feeling based on nothing in particular. If you called another script, it would surely intercept the rest of the block, and i'm nt _sure_ it would return correctly.
--Tegid 19:21, 14 April 2006 (EDT):How exactly would you call another script? You mean an Activate call? That just sets a flag to let the script parser know that the next time it runs through that objects script, it should run the activate block. See talk:Activate for details.