Please note that new user registrations disabled at this time.

Script?!

This forum is to be used for all discussions pertaining to Bethesda Softworks' The Elder Scrolls III: Morrowind and its Tribunal and Bloodmoon expansion packs.
Post Reply
User avatar
Lord Spawn
Posts: 45
Joined: Tue Aug 15, 2006 5:16 am
Location: The 7th Torture of Hell
Contact:

Script?!

Post by Lord Spawn »

OK im pleased you came in... here is tha script:

Code: Select all

Begin <Scriptname>

short VARIABLE

if ( PLAYER->HasItemEquipped "<itemname>" )
	if ( VARIABLE == 0 )		
		set VARIABLE to 1		
		MessageBox, "You have equiped it"
	endif
	if ( VARIABLE == 1 )
		return
	endif	
endif

End <Scriptname>
PAINFULY SIMPLE isn't it?
SHOULD DO: when i equip the ITEM it says:"You have equiped it", then never more say a thing. And it works! But it says the message twice....?????.....Annoiying problem and I just don't know what could be wrong...

please, if you see something in it, then tell me.. I cant sleep because this thing =(

Thank you Stranger. (OH, why cant I see <tabs>?!...Strange -.-)
Life is an accidental chemical process that protected itself ingeniously. It is without purpose.
User avatar
Lord Spawn
Posts: 45
Joined: Tue Aug 15, 2006 5:16 am
Location: The 7th Torture of Hell
Contact:

Post by Lord Spawn »

ok, i know it now, BUT....

I just relized, if I use Global variable in place of the Local one then it works fine......
BUT, the question is still up... : WHY the local didnt work?!
Life is an accidental chemical process that protected itself ingeniously. It is without purpose.
User avatar
fable
Posts: 30676
Joined: Wed Mar 14, 2001 12:00 pm
Location: The sun, the moon, and the stars.
Contact:

Post by fable »

Warning: I don't know a thing about Morrowind scripting. I did all mine for an MMORPG where I worked for several years.

That said, it appears your first endif should be an end. Since it's an endif, you've already had your message and changed your variable to 1; then it loops (if I understand correctly), notes that the variable is set to 1, and repeats the message.
To the Righteous belong the fruits of violent victory. The rest of us will have to settle for warm friends, warm lovers, and a wink from a quietly supportive universe.
User avatar
Greg.
Posts: 1938
Joined: Sun Oct 31, 2004 3:56 pm
Location: Here, now
Contact:

Post by Greg. »

:confused:

I think Chu or ML would know more about this...

Do you need the two 'endif's at the end?
User avatar
Magelord648
Posts: 1668
Joined: Fri Feb 10, 2006 1:54 pm
Location: England
Contact:

Post by Magelord648 »

Don't ask me about scripting. Chu does mine for me. (hopefully) :D Chu would definatly be the one to ask. You can get tutoring at his forum. I'll PM you the link if you want.
[url="http://www.gamebanshee.com/forums/the-elder-scrolls-iii-morrowind-29/tel-uvirith-86692.html"]Uvirith Awakes[/url] - Please leave comments, all help is appreciated.
User avatar
Lord Spawn
Posts: 45
Joined: Tue Aug 15, 2006 5:16 am
Location: The 7th Torture of Hell
Contact:

Post by Lord Spawn »

Thanks for the answers BUT...

1. Sorry Fable but I just cant undersand your answer (probably my fault)
2. GregTheSleeper, thans for answering ( if its no use anyways ) WHO is Chu???
3. MageLord648, thx for your answer but I still dont know who are you talking
about...... im new in this community.....plz give me further directions or something...
4. I STILL DONT KNOW WHY THE <TAB>s DISAPPEARING when i made the post???????? very strange...sry not disappearing, i simply cant use tabs at all
Life is an accidental chemical process that protected itself ingeniously. It is without purpose.
User avatar
Magelord648
Posts: 1668
Joined: Fri Feb 10, 2006 1:54 pm
Location: England
Contact:

Post by Magelord648 »

Chu or Ch85us2001 does scripting and is member of the GB community. His forum is at this address. Chus Mod Forum

I think I know what the cause is. Try looking at Morrowind scripting for dummies. I think it has the answer you are looking for in the sample script.

EDIT: This may help
[QUOTE=MSFD]How local scripts are executed
Every script that is attached to an Object or an NPC (local script) is executed every frame the game displays on screen while the cell with the object is active (indoors only the cell the NPC is currently in is active, outdoors the PC’s cell and all adjacent cells are active). So the complete script (not just one line of it) is executed 10-60 times a second or however fast your computer runs the game! It is best to imagine every local script wrapped in a big “while-loop”:

while (Object is in active Cell)

[Your script code]

endwhile

This is the reason why the following script spits out a continuous stream of messages (if attached to an Object or NPC in the same cell as the player). Try it, if you want:

Code: Select all

Begin Message_script

MessageBox “Thousands of useless Messages”

End Message_script
This example is relatively harmless, but imagine what happens if you would use a line of code that adds an item to the players inventory, or places a monster next to him, etc.!
For this reason, “Do Once” constructions are very essential and something you will probably use a lot while scripting for Morrowind. So, let's go on with our tutorial script: we need to declare a variable and use it to make sure the message is only displayed once. Change the script to the following:

Code: Select all

Begin my_first_script

Short controlvar

If ( OnActivate == 1 )
If ( controlvar == 0)
		MessageBox "Voiceless it cries, wingless flutters, toothless bites, mouthless mutters. What is it?", "Bat", "Old woman", "Wind", "Wraith"
	Set controlvar to 1
endif
endif

End
(Please note that the MessageBox command should be in one line in the editor!)

"Short controlvar" declares a new variable I called "controlvar", of type short. For the moment it's enough to know that this is variable that will contain integers (whole positive or negative numbers). A variable is a "placeholder" that can take on different values. The if command we already know, the set command is new, but simple enough – it sets our variable that had the value 0 before (all variables start out at zero when declared) to 1. This, in connection with the if ( controlvar == 0 ) command provides a do-once condition – the next frame the script is executed after the variable was set to 1 the if condition will be false and the message box will not be displayed again.
[/QUOTE]
You may need the whole document. You can find it at planet elder scrolls.
[url="http://www.gamebanshee.com/forums/the-elder-scrolls-iii-morrowind-29/tel-uvirith-86692.html"]Uvirith Awakes[/url] - Please leave comments, all help is appreciated.
User avatar
Lord Spawn
Posts: 45
Joined: Tue Aug 15, 2006 5:16 am
Location: The 7th Torture of Hell
Contact:

Post by Lord Spawn »

Here I am again....

Thanks for your efforts MageLord648 but I have the full "scripting for dummies".....altough i didnt read it all =) BUT:

Code: Select all

Begin <Scriptname>

short VARIABLE

if ( PLAYER->HasItemEquipped "<itemname>" ) ---> [i]first if[/i]	
     if ( VARIABLE == 0 ) ---> [i];this is the DoOnce system if you like..(first 'sub' if)[/i]		
          set VARIABLE to 1---> [i];change the value	[/i]		
          MessageBox, "You have equiped it"
     endif --->[i] first 'sub' if end[/i]	
     if ( VARIABLE == 1 ) ---> ; [i]In the next 'frameRunning' this will execute instead of 'VARIABLE = 0' part(second 'sub' if)[/i]		
          return
     endif ---> [i]second 'sub' if end	
[/i]endif ---> [i]first if end[/i]

End <Scriptname>
but something is still wrong because the 'VARIABLE = 0' part runs not only in the first frame but in the second frame as well and that is my BIG problem...
When i equip it it tells me the message twice instead of one-times.........
I am constantly thinking on it but it is so simple...it should work. I just cant understands why not?!

Well, thanks again for your help, i hope we will find solution soon :confused:
Life is an accidental chemical process that protected itself ingeniously. It is without purpose.
User avatar
fable
Posts: 30676
Joined: Wed Mar 14, 2001 12:00 pm
Location: The sun, the moon, and the stars.
Contact:

Post by fable »

endif ---> first 'sub' if end
if ( VARIABLE == 1 ) ---> ; In the next 'frameRunning' this will execute instead of 'VARIABLE = 0' part(second 'sub' if)


This is the part I was referring to. The endif concludes the condition based on the variable being 1, but immediately another if appears asserting the same condition (if variable = 1) to start a new action. So two actions, both stating "You have equiped it," have been predicated on the same condition: variable = 1.

At least, that's how I read it. If I'm still not making any sense, I'll fade into the background so far that only my faint smile is visible. :)
To the Righteous belong the fruits of violent victory. The rest of us will have to settle for warm friends, warm lovers, and a wink from a quietly supportive universe.
User avatar
Magelord648
Posts: 1668
Joined: Fri Feb 10, 2006 1:54 pm
Location: England
Contact:

Post by Magelord648 »

Hasn't it got something to do with the contolvar? I'm sure the answer lays there.
[url="http://www.gamebanshee.com/forums/the-elder-scrolls-iii-morrowind-29/tel-uvirith-86692.html"]Uvirith Awakes[/url] - Please leave comments, all help is appreciated.
User avatar
Lord Spawn
Posts: 45
Joined: Tue Aug 15, 2006 5:16 am
Location: The 7th Torture of Hell
Contact:

Post by Lord Spawn »

ok Fable...

alrighty Fable, you sounds like a person who knows what he says. Here is what I think the script does (or should):

in morrowind the script runs once in every frame

LOGICALLY:
first frame:
1.-equiped->yes
2.-var = 0 ->yes
3.-sequence: write message, set var to 1
4.-end
second frame:
1.-equiped->yes
2.-var = 0 ->NO...var = 1->YES
3.-sequence: 'return'(tells the script to start over again, as far as I know)
4.-end

if you find the mistake in this then tell me, otherwise if the mistake what you have said before was syntacticaly than tell me what should i type in your opinion.....thank you guys to react this topic, it means much to me =)

EDIT: strage.....I have added some voice to the script and i hear it only once, as if only the messagebox function runs twice.......

LOGICALLY:
first frame:
1.-equiped->yes
2.-var = 0 ->yes
3.-sequence: write message, set var to 1, play sound <voice>
4.-end
second frame:
1.-equiped->yes
2.-var = 0 ->NO...var = 1->YES
3.-sequence: 'return'(tells the script to start over again, as far as I know)
4.-end

and what I get is two messages and one voice.....even more-and-more mysterious moment-to-moment.......

EDIT: I dicided to make a frame counter and I find out that the voice is played twice as well. Before it sunded like one voice but with 20 frame differece i can hear clearly two voices
Life is an accidental chemical process that protected itself ingeniously. It is without purpose.
User avatar
Lord Spawn
Posts: 45
Joined: Tue Aug 15, 2006 5:16 am
Location: The 7th Torture of Hell
Contact:

Post by Lord Spawn »

I dont know but its OK...

Ok everyone, I made the script. I have used a global variable and some local variables for 'memory' so i could use the global var for more 'goals'. I also added some minior changes...... I still dont know why the local vars didnt work but it doesnt matters now :D

Thank all of you for your assistance. it was very kind. :cool:

EDIT: If anyone thinks he has some problems with scripting, feel free to post here. Who knows? maybe someone will help you.... bye ;)
Life is an accidental chemical process that protected itself ingeniously. It is without purpose.
User avatar
ch85us2001
Posts: 8748
Joined: Wed Apr 13, 2005 7:53 pm
Location: My mind dwells elsewhere . . .

Post by ch85us2001 »

Lord Spawn wrote:WHO is Chu???
I am. Worship me. :cool:

Alrighty here. To preserve spacing, use the tag [ code][ /code] (Without spaces)


*Cracks Knuckles*



Found your problem. It has to do with you using "HasItemEquipped" instead of OnPCEquip

Plus, the Syntax wasn't sexy enough.

Code: Select all

Begin MessageScript

Short DoOnceChu ;Do Once Call

Short OnPCEquip ;Actually a function, declared as Local Short


If ( OnPCEquip == 1 )
     If ( DoOnceChu == 0 )
           MessageBox "Item was equipped"
           Set DoOnceChu to 1 
     Else
            Return
     Endif
Endif


End
Tinker around with that to get your desired result. :)

We all start somewhere. :) If you really wanna see where I started, look here!!! I was a total n00b!!!!!! :laugh: Now I know a Programming language (Other than Morrowind)!


Lastly, come chat at Spa . . . er Speak, Your Mind. :)
[url=tamriel-rebuilt.org]Tamriel Rebuilt and,[/url] [url="http://z13.invisionfree.com/Chus_Mod_Forum/index.php?"]My Mod Fansite[/url]
I am the Lord of Programming, and your Mother Board, and your RAR Unpacker, and Your Runtime Engine, can tell you all about it
User avatar
Lord Spawn
Posts: 45
Joined: Tue Aug 15, 2006 5:16 am
Location: The 7th Torture of Hell
Contact:

Post by Lord Spawn »

Hello Chu....

Code: Select all

[i][b]first:[/b][/i] thx for the <tab> problem, acually i didn't tried it,
     but hey! it COULD work if ya say so  :) 
[i][b]second:[/b][/i] I found the 'box' (your script was in one) sweet. how could i make one?
[i][b]third:[/b][/i] your script  was very logical but if you se mine again it acually the same one except
     the onEquip thing....ya know i tried it with that as well but that didn't work, for me.
     Anyways, what the hell is the difference between OnEquip and HasItemEquipped?
     and dont tell me hasitemequipped is function and Onequip is variable coz i know that
     already......i just dont get it WHY  does the TESCS nedds two thing for 
     the same reason?
[i][b]fourth:[/b][/i] im a student from Central Europe, Hungary, and I also know a language, even if it
     is an old piece of s*** (pascal), so I dont think i am that NOOB as I could be  :) 
[i][b]last:[/b][/i] I only worship '1' and '0', and as I see your name you are not either of them  :) 

well, i feel pleased that you find me, and i hope you will answer me.
EDIT:ok i know about the box, and the <tabs> now LOL
Life is an accidental chemical process that protected itself ingeniously. It is without purpose.
Post Reply