MWSFD Question on variables

Post » Sat Jan 23, 2010 5:31 pm

exception:
do not quote player references when using MWSE. this causes bizarre errors, as i found out to my debugging sorrow.


I've never had this issue, and have quoted "player" in MWSE and regular scripts. Can you post a script known to repro it?
User avatar
Nick Pryce
 
Posts: 3386
Joined: Sat Jul 14, 2007 8:36 pm

Post » Sat Jan 23, 2010 11:15 pm

Two New Questions!!

Alright, I'll do the scripting question first.
Here are two scripts that are supposed to make the two npc's fight.
This goes on npc1:
Begin 01mc_kleffinnpcfight1Short NoLoreshort doOnceA if ( CellChanged == 0 )    Returnendifif ( doOnceA == 0 )	if ( GetDeadCount "01mc_fightingslave2" == 0 )	    StartCombat "01mc_fightingslave2"	    set doOnceA to 1	endifendifEnd


And this goes on npc2:
Begin 01mc_kleffinnpcfight2Short NoLoreshort doOnceA if ( CellChanged == 0 )    Returnendifif ( doOnceA == 0 )	if ( GetDeadCount "01mc_fightingslave1" == 0 )	    StartCombat "01mc_fightingslave1"	    set doOnceA to 1	endifendifEnd


I went ingame to check that it worked, and they were just standing there. It looks solid to me, but I didn't write them, so I don't really know. Do i have to do something special to get them to start? I attatched them to the respective npcs.


Question two:
So I was trying to make two dancer's like in Desele's House of Earthly Delights to go into some crow cages in a bar. But I went in game and they were just standing there. I used the same animation as the dancers in THe House of Earthly Delights, But I didn't change anything else about them. Do I need to make a script or something to get them to start?
User avatar
Noraima Vega
 
Posts: 3467
Joined: Wed Jun 06, 2007 7:28 am

Post » Sat Jan 23, 2010 2:13 pm

I don't know much about NPC interactions, but you could try removing or commenting out the CellChanged block first. To get people to move you need to use AITravel and enter the coordinates of the destination(s). It may need to be done in multiple steps if there are objects in the way or the path is complicated.
User avatar
Matthew Aaron Evans
 
Posts: 3361
Joined: Wed Jul 25, 2007 2:59 am

Post » Sat Jan 23, 2010 12:51 pm

I don't know much about NPC interactions, but you could try removing or commenting out the CellChanged block first. To get people to move you need to use AITravel and enter the coordinates of the destination(s). It may need to be done in multiple steps if there are objects in the way or the path is complicated.

Well they are standing right beside each other, so I don't see why it would require anything like that. I'll try what you suggested though, It isn't really needed now that I think about it.
User avatar
elliot mudd
 
Posts: 3426
Joined: Wed May 09, 2007 8:56 am

Post » Sat Jan 23, 2010 4:32 pm

Well they are standing right beside each other, so I don't see why it would require anything like that. I'll try what you suggested though, It isn't really needed now that I think about it.

It could very well be needed. say the NPCs are in the next cell. You can still see them, but they wont begin attacking until you cross into their cell. CellChanged is known to be unreliable, because it can't always know the player has changed cells if it is done by a non-standard means. You could replace it with a distance check however.

Also, why is your variable called "doOnceA"? I hope you didn't misunderstand when I said no variable can have the same name. I should have precised that they can't have the same name in the same script. It won't conflict with other scripts, so you may as well save some space and remove the "A".
User avatar
Dj Matty P
 
Posts: 3398
Joined: Sat Jun 09, 2007 12:31 am

Post » Sat Jan 23, 2010 2:18 pm

So, Thanks to this community I've written my first script, from scratch!!

begin 01mc_impishwardrumTshort getactivateif ( activate == 1 )	if ( getactivate == 1)		return	endif	else	if ( getactivate == 0)		activate		"player"->PositionCell 4314 5449 15577 0 "Kleffin's Family Home, Basemant"		set getactivate to 1	endifendifend


I know it's basic, but I'm still proud of it!
For explaining and teaching, I just want to thank Arsuru, and Peechykeen. Both of you have contributed greatly to teaching me,especially Arsuru! Thanks!

EDIT: Accidentally posted script twice in box
User avatar
Kira! :)))
 
Posts: 3496
Joined: Fri Mar 02, 2007 1:07 pm

Post » Sat Jan 23, 2010 8:15 pm

I've never had this issue, and have quoted "player" in MWSE and regular scripts. Can you post a script known to repro it?

you posted in the thread =D

http://www.fliggerty.com/phpBB3/viewtopic.php?f=24&t=3737

the whole issue with that script (which would give "no room for zero pointers" errors when you load a game, causing the came to CTD) was that the references to player were quoted. it might be something internal with MWedit, or something about MWSE (the version i have is the one that is built into MGE, using rev 186 or something close i think)

slaanesh:
try removing the "getcellchanged" block. getcellchanged only ever returns 1 when the player is changing cells, this means that it only triggers when the player is leaving a cell.

for the dancers, checks the dancers in the house of earthly delights, i think they have a script on them that loops the animation.
User avatar
Jade Payton
 
Posts: 3417
Joined: Mon Sep 11, 2006 1:01 pm

Post » Sat Jan 23, 2010 11:27 pm

It could very well be needed. say the NPCs are in the next cell. You can still see them, but they wont begin attacking until you cross into their cell. CellChanged is known to be unreliable, because it can't always know the player has changed cells if it is done by a non-standard means. You could replace it with a distance check however.

Also, why is your variable called "doOnceA"? I hope you didn't misunderstand when I said no variable can have the same name. I should have precised that they can't have the same name in the same script. It won't conflict with other scripts, so you may as well save some space and remove the "A".

It's in a house, and the means of getting there would disable the cellchange anyways, since its by script. I want it to start as soon as you "enter" the cell. Is it possible?
Also, I didn't write that script, "DoonceA" was just the variable the writer used, I didn't really think it mattered so I didn't change it. I'll remove it though, since it would be smart to save space.


RAKNinja: I checked them, and they didn't have a script one the one i checked. Ill look again though.
User avatar
TOYA toys
 
Posts: 3455
Joined: Sat Jan 13, 2007 4:22 am

Post » Sat Jan 23, 2010 9:15 pm

It's in a house, and the means of getting there would disable the cellchange anyways, since its by script. I want it to start as soon as you "enter" the cell. Is it possible?
Also, I didn't write that script, "DoonceA" was just the variable the writer used, I didn't really think it mattered so I didn't change it. I'll remove it though, since it would be smart to save space.


RAKNinja: I checked them, and they didn't have a script one the one i checked. Ill look again though.

Then use a distance check in the script where CellChanged would be. Get the distance from them to the place where the player arrives, plus a little more to be sure, and it should work fine.

For the dancers, you don't need to mess with the animation at all. To get them in the cage, use AITravel.
User avatar
Vicky Keeler
 
Posts: 3427
Joined: Wed Aug 23, 2006 3:03 am

Post » Sat Jan 23, 2010 7:25 pm

Then use a distance check in the script where CellChanged would be. Get the distance from them to the place where the player arrives, plus a little more to be sure, and it should work fine.

For the dancers, you don't need to mess with the animation at all. To get them in the cage, use AITravel.

Well i placed them in the cage, and added the animation to them via the animation button when you double click on an npc in TECS. Nothing happened.

As for the distance check, I'll try that. How many units would be about the distance of an ingame bed? (from pillow to feet end). The unit measurement in morrowind confuses me.
User avatar
Alexx Peace
 
Posts: 3432
Joined: Thu Jul 20, 2006 5:55 pm

Post » Sat Jan 23, 2010 3:21 pm

Well i placed them in the cage, and added the animation to them via the animation button when you double click on an npc in TECS. Nothing happened.

As for the distance check, I'll try that. How many units would be about the distance of an ingame bed? (from pillow to feet end). The unit measurement in morrowind confuses me.

I must be misunderstanding. If you want them to dance, check the script on the normal dancing girls.

There is no really easy way to measure distance that I know. Most squared room tiles are 256 units. I suggest lining up a bunch of dock pieces with grid snap set to 128. Each dock piece is 256 units, and there is a half-length one with 128 in the name. Snap them together until you get the length you need, position them to be sure, and do some math. 256 and/or 128 times the amount of respective pieces used with some addition if you used both kinds.
User avatar
Charlotte Buckley
 
Posts: 3532
Joined: Fri Oct 27, 2006 11:29 am

Post » Sat Jan 23, 2010 2:46 pm

you posted in the thread =D

http://www.fliggerty.com/phpBB3/viewtopic.php?f=24&t=3737

the whole issue with that script (which would give "no room for zero pointers" errors when you load a game, causing the came to CTD) was that the references to player were quoted. it might be something internal with MWedit, or something about MWSE (the version i have is the one that is built into MGE, using rev 186 or something close i think)

That is interesting. I thought that the quotes were for the compiler and I didn't think the compiled form differed between quoted and unqutoed strings. I know for a fact it doesn't with function arguments.
User avatar
Schel[Anne]FTL
 
Posts: 3384
Joined: Thu Nov 16, 2006 6:53 pm

Post » Sat Jan 23, 2010 3:03 pm

I must be misunderstanding. If you want them to dance, check the script on the normal dancing girls.

There is no really easy way to measure distance that I know. Most squared room tiles are 256 units. I suggest lining up a bunch of dock pieces with grid snap set to 128. Each dock piece is 256 units, and there is a half-length one with 128 in the name. Snap them together until you get the length you need, position them to be sure, and do some math. 256 and/or 128 times the amount of respective pieces used with some addition if you used both kinds.

There isn't a script on the dancing girl's though is the thing, they only have the dancing animation attached to them.
Here's a screenshot: http://tinypic.com/r/ejj0pe/7
However, in the "Animation" button beside Ai and Dialogue, there is a thing for Idle9 , with stuff about loop?
I don't know...

As for the way to measure distance, thanks! I figure i'll be using alot of unit's if that's how small they are haha.
User avatar
jessica sonny
 
Posts: 3531
Joined: Thu Nov 02, 2006 6:27 pm

Post » Sat Jan 23, 2010 9:56 pm

That is interesting. I thought that the quotes were for the compiler and I didn't think the compiled form differed between quoted and unqutoed strings. I know for a fact it doesn't with function arguments.

perhaps it's something in the MWedit compiler, as the error only ever cropped up when compiling the script with quoted player references in MWedit. because the references were before a fix, maybe MWedit's compiler replaced the quoted string with one that had more arguments than i could supply on a given line because of the other things i was doing that line. it could be that the unquoted player reference points to a different thing without as many levels of recursiveness. it would eplain why i got such a rare error usually caused by having too many operators to a line.

i've recently been working in python, and i've come to a similar issue where i passed something a little too deep and got variables mismatched.

then again, my hypothesis has a lot of "maybe", "perhaps", and "could be". perhaps it's just the normal morrowind finickyness that relies on the moons of jupiter being aligned in a certain position. who knows?
User avatar
saxon
 
Posts: 3376
Joined: Wed Sep 19, 2007 2:45 am

Post » Sat Jan 23, 2010 4:10 pm

There isn't a script on the dancing girl's though is the thing, they only have the dancing animation attached to them.
Here's a screenshot: http://tinypic.com/r/ejj0pe/7
However, in the "Animation" button beside Ai and Dialogue, there is a thing for Idle9 , with stuff about loop?
I don't know...

As for the way to measure distance, thanks! I figure i'll be using alot of unit's if that's how small they are haha.

Oh, sorry about the script thing, I see what to do now. I haven't done a lot with NPCs, and I was thinking of playing animations on objects, which does need a script. Look at the AI of the dancing girls. You need to set the idle chances of you NPCs like theirs. You can change them if you like, but only Idle9 is the dancing animation. The animation button just gives info on what is used. You can't change anything from there.

I knew this already, but kinda forgot, until it just dawned on me.
User avatar
Averielle Garcia
 
Posts: 3491
Joined: Fri Aug 24, 2007 3:41 pm

Post » Sat Jan 23, 2010 8:09 pm

Oh, sorry about the script thing, I see what to do now. I haven't done a lot with NPCs, and I was thinking of playing animations on objects, which does need a script. Look at the AI of the dancing girls. You need to set the idle chances of you NPCs like theirs. You can change them if you like, but only Idle9 is the dancing animation. The animation button just gives info on what is used. You can't change anything from there.

I knew this already, but kinda forgot, until it just dawned on me.

Oh, How simple haha. Thanks, its appreciated as always :intergalactic:
User avatar
-__^
 
Posts: 3420
Joined: Mon Nov 20, 2006 4:48 pm

Post » Sat Jan 23, 2010 2:34 pm

New Question!
So i've written my little script:
begin 01mc_impishwardrumTshort getactivateif ( activate == 1 )	if ( getactivate == 1)		return	endif	else	if ( getactivate == 0)		activate		"player"->PositionCell 4314 5449 15577 0 "Kleffin's Family Home, Basemant"		Journal "mc_dissidentpriest" 280		Addtopic "Impish War Drum"		set getactivate to 1	endifendifend	


When you pick up the drum, you get a journal update, and it teleport's you to a part of the room that is upside down, simulating that the player is upside down themselves. However, when i pick the object up to activate the script, the game freezes and CTD's. I have no idea why. any suggestions?
User avatar
KRistina Karlsson
 
Posts: 3383
Joined: Tue Jun 20, 2006 9:22 pm

Post » Sat Jan 23, 2010 9:51 pm

When you pick up the drum, you get a journal update, and it teleport's you to a part of the room that is upside down, simulating that the player is upside down themselves. However, when i pick the object up to activate the script, the game freezes and CTD's. I have no idea why. any suggestions?

You need to use OnActivate, not getactivate, and you don't declare it as a variable. OnActivate is a function. Isn't this similar to the problem you had with thee book? So if you are picking it up, why not just use OnPCAdd?
User avatar
Reven Lord
 
Posts: 3452
Joined: Mon May 21, 2007 9:56 pm

Post » Sat Jan 23, 2010 10:44 pm

That is interesting. I thought that the quotes were for the compiler and I didn't think the compiled form differed between quoted and unqutoed strings. I know for a fact it doesn't with function arguments.


It doesn't, it's just for compiler clarity. All IDs are handled the same, too, so quoting one won't magically break things.

Two posts down says:
i've since gotten it working. the broken functionality was caused by me having both MWedit and the default CS open at the same time, MWedit with an updated and working version of the script, and the CS open with updated and working dialog. saving in one overwrote the save from the other. silly mistake, and since corrected.

Which I'm more inclined to believe was the issue and solution.

perhaps it's something in the MWedit compiler, as the error only ever cropped up when compiling the script with quoted player references in MWedit. because the references were before a fix, maybe MWedit's compiler replaced the quoted string with one that had more arguments than i could supply on a given line because of the other things i was doing that line. it could be that the unquoted player reference points to a different thing without as many levels of recursiveness. it would eplain why i got such a rare error usually caused by having too many operators to a line.

IDs aren't recursive and Python's nonsense isn't at play in MWScript (or I wouldn't touch the stuff :P). I've checked a few of my MWSE scripts and have quoted references to player which worked fine.

What do you mean by a quoted reference before a fix? Were you using
xSetRef "player"

or setting a variable to the reference of "player"?

MW doesn't do recursion, an ID is an ID, all quoted IDs are treated identically by the compiler and resolved pretty simply (prolly just stricmp). That's why player and PlayerSaveGame can be used in script and still refer to the in-game player.

The too-many-operations in a line is linked to why using functions in a line fails; the default compiler and MWSE to a lesser extent just choke. Neither is a high-end compiler using a full lexer or anything, so you can't expect too much. The MW bytecode is also pretty simple and I'm not sure how many registers are in use, or if it allocates temps, but it's not meant for huge problems. Split it to multiple lines and they work fine, though.
User avatar
Lovingly
 
Posts: 3414
Joined: Fri Sep 15, 2006 6:36 am

Post » Sat Jan 23, 2010 10:55 pm

peachy, about my post you quoted, it's taken out of context. the problem of removing the quotes working as a fix for the script was not being applied because i had the same esp open in two editors. test the script if you like, i'm fairly certain the final version of it is floating around in my scripting woes thread a page or so from the back. it was confirmed across multiple machines to behave this way. quoted player references cause "no room for zero pointers" on save game load, unquoted does not. what's more, references outside of setx statements were affected as well, if i remember. it was a real pain in the rear debugging that one.

when i say, "before a fix", i mean immediately preceding one of these - "->"

i freely admit my ignorance on how MW compiles its scripts, but i do find it quite odd, with my rudimentary knowledge of compiling and related tasks, that quotes around a reference take up room for pointers. yet, according to the results of my experience, this is the only conclusion that i can draw.

if you can find some other reason for this behavior, i'll gladly revise my work, it bugs me i had to write my MWSE scripts in a different "style" than my usual scripts.
User avatar
GabiiE Liiziiouz
 
Posts: 3360
Joined: Mon Jan 22, 2007 3:20 am

Post » Sat Jan 23, 2010 7:49 pm

IDs aren't recursive and Python's nonsense isn't at play in MWScript (or I wouldn't touch the stuff :P). I've checked a few of my MWSE scripts and have quoted references to player which worked fine.

Slightly OT. But Pythons nonsense?
User avatar
Steph
 
Posts: 3469
Joined: Sun Nov 19, 2006 7:44 am

Post » Sat Jan 23, 2010 7:11 pm

You need to use OnActivate, not getactivate, and you don't declare it as a variable. OnActivate is a function. Isn't this similar to the problem you had with thee book? So if you are picking it up, why not just use OnPCAdd?

So, this is right then?
begin 01mc_impishwardrumTif ( onactivate == 1 )    returnendif    elseif ( onactivate == 0)                activate                "player"->PositionCell 4314 5449 15577 0 "Kleffin's Family Home, Basemant"                Journal "mc_dissidentpriest" 280                Addtopic "Impish War Drum"                set onactivate to 1endifend 


And no, this is crashing my game, the book just wouldn't pick up. I'll try it that way to though.

So, this would work better?
begin 01mc_impishwardrumTshort doneshort OnPCAddif ( OnPCAdd == 1 )        if ( done == 0 )                Set done to 1                "player"->PositionCell 4314 5449 15577 0 "Kleffin's Family Home, Basemant"                Journal "mc_dissidentpriest" 280                Addtopic "Impish War Drum"        endifendifEnd

User avatar
Fiori Pra
 
Posts: 3446
Joined: Thu Mar 15, 2007 12:30 pm

Post » Sat Jan 23, 2010 6:21 pm

the first script crashes? it saves and compiles in the Cs without problem?

i ask, because there is an "else" floating around after an "if" that has already has an "endif".
if ( onactivate == 1 )    returnendif    elseif ( onactivate == 0).....


should be

if ( onactivate == 1 )    returnelseif ( onactivate == 0).....


or perhaps just

if ( onactivate == 1 )    returnelse        ....


it's been a while since i used "else" and even "endif"..... and all the things ive recently been learning in python are jumbling together with what i've learned about MW scripting =D
User avatar
Gen Daley
 
Posts: 3315
Joined: Sat Jul 08, 2006 3:36 pm

Post » Sat Jan 23, 2010 11:06 pm

the first script crashes? it saves and compiles in the Cs without problem?

i ask, because there is an "else" floating around after an "if" that has already has an "endif".
if ( onactivate == 1 )    returnendif    elseif ( onactivate == 0).....


should be

if ( onactivate == 1 )    returnelseif ( onactivate == 0).....


or perhaps just

if ( onactivate == 1 )    returnelse        ....


it's been a while since i used "else" and even "endif"..... and all the things ive recently been learning in python are jumbling together with what i've learned about MW scripting =D

Well I just learned scripting so I'm not very good at it, thanks for the explanation :D and yea it compiled fine, but crashed ingame
User avatar
Lloyd Muldowney
 
Posts: 3497
Joined: Wed May 23, 2007 2:08 pm

Post » Sat Jan 23, 2010 2:08 pm

Remember, OnActivate is a function, not a variable. Unlike a variable you cannot set a functions value. Also the value of OnActivate is 1 for exactly one frame when the player actives the object.
User avatar
Ashley Campos
 
Posts: 3415
Joined: Fri Sep 22, 2006 9:03 pm

PreviousNext

Return to III - Morrowind