I've made a script...

Post » Mon Dec 21, 2009 11:26 am

I've made this script to replace an empty cup of tea by a full one when the tea pot is activated.
The script works but I'm pretty sure it needs polishing to make it efficient and problem free.

I feel bad because it's like asking you to check my homework, but.... can you check my homework script, please?

On the tea pot

Begin aa_pour_tea        if ( OnActivate == 1 )        if ( aaTeaControl == 0 )            Messagebox " You pour yourself a cup of tea."            set aaTeaControl to 1	        endif            endifend


On the empty cup
Begin aa_teacup_empty            if ( aaTeaControl == 1 )        Disable	        set doonce to 1    else        Enable        set doonce to 0    endif        if ( Onactivate > 0 )        if ( aaTeaControl == 0 )            MessageBox "The cup is empty."        endif    endif    End


On the hot cup of tea
Begin aa_teacup_script            if ( aaTeaControl == 0 )        Disable    else        Enable    endif            if ( OnActivate == 1 )        if ( aaTeaControl == 1 )            MessageBox "You drink the hot cup of tea."            Cast "aa_teacup_spell" Player            set aaTeaControl to 0            Disable        endif    endif        End


Thanks for any help/advice you can give :)
User avatar
Chenae Butler
 
Posts: 3485
Joined: Sat Feb 17, 2007 3:54 pm

Post » Mon Dec 21, 2009 7:25 pm

I think this is perfect.
I'm not sure if you need the doonce on the empty teacup, and you might want to check it in menumode, and see if it works too.

Oh, by the way, I love your Board Games. :)
User avatar
Laura-Jayne Lee
 
Posts: 3474
Joined: Sun Jul 02, 2006 4:35 pm

Post » Mon Dec 21, 2009 7:41 pm

I've made this script to replace an empty cup of tea by a full one when the tea pot is activated.
The script works but I'm pretty sure it needs polishing to make it efficient and problem free.

Nice idea.

You do not appear to declare doonce in the script attached to the empty cup (unless it is another global variable). Presumably is it intended to prevent repeated Enables and Disables (of the sort that occurs for the hot cup of tea) - a wise practice.

Begin aa_teacup_empty	short doonce		if ( aaTeaControl == 1 )		if ( doonce == 1 )			Disable				set doonce to 0		endif	else; this is set up for empty cup to be enabled at start		if ( doonce == 0 )			Enable				set doonce to 1		endif	endif		if ( Onactivate > 0 )		if ( aaTeaControl == 0 ); this check should not be necessary			MessageBox "The cup is empty."		endif	endif	End

Begin aa_teacup_scriptshort doonce			if ( aaTeaControl == 0 ); this is set up for hot cup of tea to be disabled at start		if ( doonce == 0 ); to prevent disabling every frame			Disable			set doonce to 1	else		if ( doonce == 1 )			Enable				set doonce to 0		endif	endif		if ( OnActivate == 1 )		if ( aaTeaControl == 1 ); again unnecessary since aaTeaControl == 0 means it is disabled			MessageBox "You drink the hot cup of tea."			Cast "aa_teacup_spell" Player			set aaTeaControl to 0			Disable; unnecessary since aaTeaControl == 0 will disable		endif	endif	End

User avatar
Kevin Jay
 
Posts: 3431
Joined: Sun Apr 29, 2007 4:29 am

Post » Mon Dec 21, 2009 1:48 pm

Thanks you both for you replies.
Glad you like the board games Mantriel, I've had loads of fun making the Morropoly :)

Corrected script with explantions is great, thank you some much CyranO!
User avatar
quinnnn
 
Posts: 3503
Joined: Sat Mar 03, 2007 1:11 pm

Post » Mon Dec 21, 2009 11:39 am

My home work

Pot ( ID: Pot )
short doonceshort stateshort emptyshort doemptyif ( doonce == 0 )	Fullcup->Disable	; setting cup;	EmptyCup->Enable 	set empty to 1	set doonce to 1endifif ( OnActivate == 1 )	if ( empty == 1 )		MessageBox,		set empty to 0		set state to 1	else		MessageBox, 	endifendifif ( state == 1 )	Emptycup->Disable	Fullcup->Enable	set state to 0endifif ( doempty == 1 )	Fullcup->Disable	Emptycup->Enable	set doempty to 0endif


Emptycup
if ( OnActivate == 1 )	MessageBox, endif


Fullcup
short stateif ( OnActivate == 1 )	MessageBox, 	set state to 1endifif ( state == 1 )	set Pot.empty to 1 ; Pot is ItemID	set Pot.doempty to 1	set state to 0endif

User avatar
Richard Dixon
 
Posts: 3461
Joined: Thu Jun 07, 2007 1:29 pm

Post » Mon Dec 21, 2009 2:50 pm


Although this is off topic (I mean I'm just curious), I don't get it why do you use the "short state" variable on the teapot? You could have added that part into the block above:

if ( OnActivate == 1 )	if ( empty == 1 )		MessageBox,		set empty to 0		Emptycup->Disable		Fullcup->Enable	else		MessageBox,	endifendif


and why do you have 2 msg boxes on the teapot? Danae wanted only 1?
User avatar
Jessica Nash
 
Posts: 3424
Joined: Tue Dec 19, 2006 10:18 pm

Post » Mon Dec 21, 2009 4:33 pm

My home work

Pot ( ID: Pot )
short doonceshort stateshort emptyshort doemptyif ( doonce == 0 )	Fullcup->Disable; setting cup;	EmptyCup->Enable 	set empty to 1	set doonce to 1endifif ( OnActivate == 1 )	if ( empty == 1 )		MessageBox,		set empty to 0		set state to 1	else		MessageBox, 	endifendifif ( state == 1 )	Emptycup->Disable	Fullcup->Enable	set state to 0endifif ( doempty == 1 )	Fullcup->Disable	Emptycup->Enable	set doempty to 0endif


Emptycup
if ( OnActivate == 1 )	MessageBox, endif


Fullcup
short stateif ( OnActivate == 1 )	MessageBox, 	set state to 1endifif ( state == 1 )	set Pot.empty to 1; Pot is ItemID	set Pot.doempty to 1	set state to 0endif


Thank you very much! You homework looks a lot tidier than what I came up with.
User avatar
Astargoth Rockin' Design
 
Posts: 3450
Joined: Mon Apr 02, 2007 2:51 pm

Post » Mon Dec 21, 2009 6:21 pm

Once again I need to call on your wisdom...

My script worked fine until I decided to add a timer and a fade out/in so the hot cup of tea doesn't appear out of thin air.
Here's what I did:

Begin aa_pour_tea        float TimePassed        if ( menumode == 1 )        return    endif        if ( OnActivate == 1 )        if ( aaTeaControl == 0 )            FadeOut, 2            FadeIn, 1.0            set TimePassed to (TimePassed + GetSecondsPassed)            if ( TimePassed > 2 )                Messagebox " You pour yourself a cup of tea."                set aaTeaControl to 1            endif        endif        endif    end


When I activate my tea pot, I do get the fade in/out but that's it.
Please, tell me what I'm doing wrong.
User avatar
X(S.a.R.a.H)X
 
Posts: 3413
Joined: Tue Feb 20, 2007 2:38 pm

Post » Mon Dec 21, 2009 1:29 pm

Try this
Begin aa_pour_tea        float TimePassed        if ( menumode == 1 )        return    endif        if ( OnActivate == 1 )        if ( aaTeaControl == 0 )            FadeOut, 2            set aaTeaControl to 2        endif        endif    if ( aaTeaControl == 2 )            set TimePassed to ( TimePassed + GetSecondsPassed )            if ( TimePassed > 2 )                set TimePassed to 0  ; timers should be reset, else they will be skipped on second run                FadeIn, 1.0                Messagebox " You pour yourself a cup of tea."                set aaTeaControl to 1            endif    endif    end
Morropoly ?! I need it! :clap:
[EDIT]removed extra endif
User avatar
Amy Masters
 
Posts: 3277
Joined: Thu Jun 22, 2006 10:26 am

Post » Mon Dec 21, 2009 8:11 pm

Try this
Begin aa_pour_tea        float TimePassed        if ( menumode == 1 )        return    endif        if ( OnActivate == 1 )        if ( aaTeaControl == 0 )            FadeOut, 2            set aaTeaControl to 2        endif        endif    if ( aaTeaControl == 2 )            set TimePassed to ( TimePassed + GetSecondsPassed )            if ( TimePassed > 2 )                set TimePassed to 0  ; timers should be reset, else they will be skipped on second run                FadeIn, 1.0                Messagebox " You pour yourself a cup of tea."                set aaTeaControl to 1            endif    endif    end
Morropoly ?! I need it! :clap:
[EDIT]removed extra endif


Thank you Abot, I've given it a try: good news, the scripts runs but the hot cup of tea still appear before the fadeout is complete. I've tried increasing the timepassed : if ( TimePassed > 15 ) to see what would happen, the cup still appear instantly while the fadein normally happens 15 seconds later. Am I missing something?
User avatar
Da Missz
 
Posts: 3438
Joined: Fri Mar 30, 2007 4:42 pm

Post » Mon Dec 21, 2009 3:00 pm

Oops, we should also change the other scripts to skip the aaTeaControl == 2 case ... better avoid to enable/disable each frame also
Begin aa_teacup_empty	short doonceif ( GetDisabled )	if ( aaTeaControl == 0 )		enable	endifelseif ( aaTeaControl == 1 )	disableendif	if ( onactivate )	if ( aaTeaControl == 0 ); this check should not be necessary		MessageBox "The cup is empty."	endifendif	End
Begin aa_teacup_script	if ( GetDisabled )	if ( aaTeaControl == 1 )		enable	endifelseif ( aaTeaControl == 0 )	disableendif	if ( onactivate )	if ( aaTeaControl == 1 )		MessageBox "You drink the hot cup of tea."		Cast "aa_teacup_spell" Player		set aaTeaControl to 0		Disable	endifendif		End

User avatar
darnell waddington
 
Posts: 3448
Joined: Wed Oct 17, 2007 10:43 pm

Post » Mon Dec 21, 2009 4:09 pm

Oops, we should also change the other scripts to skip the aaTeaControl == 2 case ... better avoid to enable/disable each frame also

Thanks I'll try that :))

EDIT: works perfectly, thank you very much!
User avatar
Stacey Mason
 
Posts: 3350
Joined: Wed Nov 08, 2006 6:18 am

Post » Mon Dec 21, 2009 4:53 pm

Hello, me again, in dire need of your help with a script acting out...

This script is attached to a door and has worked very well till now. While I was walking around in the cell where the door is, the script suddenly fired up a few times... It's very rare considering how often I've been testing my mod but still, it's a puzzler for me.

Begin aa_chapel_door        short button    short messageOn    short reset        If ( MenuMode == 1 )        Return    Endif        if ( OnActivate == 1 )        MessageBox "What faith do you follow?" "The Imperial cult" "The Temple" "Daedra worship" "I simply wish to mediate" "None right now"        set messageOn to 1    endif        if ( messageOn == 1 )                set button to GetButtonPressed                if ( button >= 0 )            set messageOn to 0        endif                ;Imperial        if ( button == 0 )            Player->PositionCell 4299, 4102, 12227, 270 " Imperial Chapel"            playsound "conjuration hit"            set reset to 1                          ;Temple        elseif ( button == 1 )            playsound "conjuration hit"            Player->PositionCell 4290, 4097, 12212, 270 " Temple"            set reset to 1                          ;Daedra shrine        elseif ( button == 2 )            playsound "conjuration hit"            Player->PositionCell 4284, 4099, 15667, 270 " Daedric Shrine"            set reset to 1            return                        ;pagan        elseif ( button == 3 )            playsound "conjuration hit"            Player->PositionCell 4448, 3664, 2878, 270 " Place of Comtemplation"            set reset to 1            return                    elseif ( button == 4 )            set reset to 1            return        endif    endif    End


What say you? I'm not sure about the reset variable but I'm honestly clueless.
User avatar
Nicholas C
 
Posts: 3489
Joined: Tue Aug 07, 2007 8:20 am

Post » Mon Dec 21, 2009 6:44 pm

Try this:

Begin aa_chapel_door        short button    short messageOn        If ( MenuMode == 1 )        Return    Endif        if ( onactivate == 1 )        MessageBox "What faith do you follow?" "The Imperial cult" "The Temple" "Daedra worship" "I simply wish to mediate" "None right now"        set messageOn to 1	return    endif        if ( messageOn == 1 )                set button to GetButtonPressed	if ( button == - 1 )		return        	elseif ( button == 0 )            Player->PositionCell 4299 4102 12227 270 "Imperial Chapel"            playsound "conjuration hit"            set messageOn to 0              return            ;Temple        elseif ( button == 1 )            playsound "conjuration hit"            Player->PositionCell 4290 4097 12212 270 "Temple"            set messageOn to 0            return                        ;Daedra shrine        elseif ( button == 2 )            playsound "conjuration hit"            Player->PositionCell 4284 4099 15667 270 "Daedric Shrine"            set messageOn to 0            return                        ;pagan        elseif ( button == 3 )            playsound "conjuration hit"            Player->PositionCell 4448 3664 2878 270 "Place of Comtemplation"            set messageOn to 0            return                    elseif ( button == 4 )            set messageOn to 0            return        endif    endif    End


You need to reset the messageOn variable after the player has made their choice. Also, the spaces in the beginning cell name shouldn't be there unless you put them there when naming the cell. That menu mode test probably doesn't need to be needed since the script doesn't do anything unless you activate the door. If you're having problems with being transported somewhere after you've made your choice, take it out and see if it's interfering with the script recognizing what button you've pressed.
User avatar
electro_fantics
 
Posts: 3448
Joined: Fri Mar 30, 2007 11:50 pm

Post » Mon Dec 21, 2009 2:59 pm


You need to reset the messageOn variable after the player has made their choice. Also, the spaces in the beginning cell name shouldn't be there unless you put them there when naming the cell. That menu mode test probably doesn't need to be needed since the script doesn't do anything unless you activate the door. If you're having problems with being transported somewhere after you've made your choice, take it out and see if it's interfering with the script recognizing what button you've pressed.


Once again thank you! :cookie:
So the reset was wonky (my scripting senses were all tinlgy... ahem, no, I just didn't see what it did...)
The cells indeed have a space before their name, it doesn't really show ingame and it's a lot easier to work in the CS.
So you say that the menu mode test doesn't need to be if the script starts upon activation? (If so, I got a bit a spring cleaning to do!)
The actual teleportation works even when the script starts of its own accord. I've been trying to make it happen all day without succes though.
Anyway thanks again, no doubt I'll be back with more homework scripts to check.
User avatar
MatthewJontully
 
Posts: 3517
Joined: Thu Mar 08, 2007 9:33 am

Post » Mon Dec 21, 2009 7:10 am

You're weclcome. :)

Menu mode checks are mainly for scripts that shouldn't be doing anything if the player is in dialog, has their inventory screens open or has the escape menu open. It probably won't affect this script because I don't think message boxes count as menus, but I could be wrong. I'll have to remember that about the cell names...Anyway, let us know if you're having any more problems. :)
User avatar
Beth Belcher
 
Posts: 3393
Joined: Tue Jun 13, 2006 1:39 pm

Post » Mon Dec 21, 2009 9:50 pm

Hello again, I have another script, it's bigger, longer and meaner.
It works (now, it took me 3 days) but as usual, there's a pretty high chance I've added useless stuff and miss some important one, so please, can you check my homework again??

Here's what the scripts do:

It's a piece of clothing called "music sheet".
When I equip it, I don't want to have it equipped (I used skipequio, not sure I did it right).
Then, if I have one of the 4 lutes (they are weapons) , and if it's drawn, the music is streamed.

But also! I want a spell to be given depending on which lute is equipped and only as long as the lute is equip (but not drawn) and the music sheet in the inventory.

Begin aa_sheetmusic04_script        short OnPCEquip    short PCSkipEquip        set PCSkipEquip to 1    if ( OnPCEquip == 1 )          if ( player->HasItemEquipped "aa_lute_weap_play" == 1 )            If ( Player -> GetWeaponDrawn )                StreamMusic, "Bard\Lute4.mp3"                set gamehour to ( gamehour + 1 )                set aaBardExp to ( aaBardExp + 1 )                fadeout, 10                fadein, 10                StartScript "aa_RemoveSheetMusic04"            endif        elseif ( player->HasItemEquipped "aa_EBlute_weap_play" == 1 )            If ( Player -> GetWeaponDrawn )                StreamMusic, "Bard\Lute4.mp3"                set gamehour to ( gamehour + 1 )                set aaBardExp to ( aaBardExp + 1 )                fadeout, 10                fadein, 10                StartScript "aa_RemoveSheetMusic04"            endif        elseif ( player->HasItemEquipped "aa_KOlute_weap_play" == 1 )            If ( Player -> GetWeaponDrawn )                StreamMusic, "Bard\Lute4.mp3"                set gamehour to ( gamehour + 1 )                set aaBardExp to ( aaBardExp + 1 )                fadeout, 10                fadein, 10                StartScript "aa_RemoveSheetMusic04"            endif        elseif ( player->HasItemEquipped "aa_PJMlute_weap_play" == 1 )            If ( Player -> GetWeaponDrawn )                StreamMusic, "Bard\Lute4.mp3"                set gamehour to ( gamehour + 1 )                set aaBardExp to ( aaBardExp + 1 )                fadeout, 10                fadein, 10                StartScript "aa_RemoveSheetMusic04"            endif        endif        set OnPCEquip to 0    endif        if ( player->HasItemEquipped "aa_lute_weap_play" == 1 )        If ( ( player->GetItemCount, "aa_lute_sheetmusic04" ) != 0 )            If ( ( ScriptRunning, "aa_scorespell04acontrol" ) != 1 )                If ( MenuMode == 0 )                    player->AddSpell, "aa_scorespell04a"                    StartScript, "aa_scorespell04acontrol"                endif            endif        endif      elseif ( player->HasItemEquipped "aa_EBlute_weap_play" == 1 )        If ( ( player->GetItemCount, "aa_lute_sheetmusic04" ) != 0 )            If ( ( ScriptRunning, "aa_scorespell04bcontrol" ) != 1 )                If ( MenuMode == 0 )                    player->AddSpell, "aa_scorespell04b"                    StartScript, "aa_scorespell04bcontrol"                endif            endif        endif    elseif ( player->HasItemEquipped "aa_KOlute_weap_play" == 1 )        If ( ( player->GetItemCount, "aa_lute_sheetmusic04" ) != 0 )            If ( ( ScriptRunning, "aa_scorespell04ccontrol" ) != 1 )                If ( MenuMode == 0 )                    player->AddSpell, "aa_scorespell04c"                    StartScript, "aa_scorespell04ccontrol"                endif            endif        endif    elseif ( player->HasItemEquipped "aa_PJMlute_weap_play" == 1 )        If ( ( player->GetItemCount, "aa_lute_sheetmusic04" ) != 0 )            If ( ( ScriptRunning, "aa_scorespell04dcontrol" ) != 1 )                If ( MenuMode == 0 )                    player->AddSpell, "aa_scorespell04d"                    StartScript, "aa_scorespell04dcontrol"                endif            endif        endif        endif    end


This is the first global script used when a song is played to avoid the duplication of the music sheet (it's a glove btw) if used from a quick key
Begin aa_RemoveSheetMusic04        short frameCounter        set frameCounter to ( frameCounter + 1 )        if ( frameCounter < 2 ) ; let music script finish executing        return    else        player->RemoveItem "aa_lute_sheetmusic04" 1        player->AddItem "aa_lute_sheetmusic04" 1        set frameCounter to 0        StopScript "aa_RemoveSheetMusic04"    endif    End

And finally, this script removes the spell if the conditions aren't met anymore. There are 4 variants of this script (a, b, c and d) for each variant of the spell.
begin aa_scorespell04acontrol         If ( ( player->GetItemCount, "aa_lute_sheetmusic04" ) == 0 )        If ( MenuMode == 0 )              player->RemoveSpell, "aa_scorespell04a"            StopScript, aa_scorespell04acontrol        endif    elseif ( player->HasItemEquipped "aa_lute_weap_play" == 0 )          If ( MenuMode == 0 )              player->RemoveSpell, "aa_scorespell04a"            StopScript, aa_scorespell04acontrol        endif    endifEnd


PHEW!
So, what do you think? Do I have a potential CTD sympathiser?
User avatar
Matt Bigelow
 
Posts: 3350
Joined: Sun Sep 30, 2007 6:36 pm

Post » Mon Dec 21, 2009 10:34 am

Menu mode checks are mainly for scripts that shouldn't be doing anything if the player is in dialog, has their inventory screens open or has the escape menu open. It probably won't affect this script because I don't think message boxes count as menus, but I could be wrong. I'll have to remember that about the cell names...Anyway, let us know if you're having any more problems. :)

Yus they do, and whenever you have a messagebox that needs to wait for a reply, you should always use a MenuMode return at the top of the script. It greatly simplified debugging the responses and can help with speed and a few other bugs.
There are a few exceptions, but those are usually only when you need a short snippet processed every frame and the reaction processed out of menus.

Hello again, I have another script, it's bigger, longer and meaner.
It works (now, it took me 3 days) but as usual, there's a pretty high chance I've added useless stuff and miss some important one, so please, can you check my homework again??
-snip-

PHEW!
So, what do you think? Do I have a potential CTD sympathiser?

I'm not sure, need to reread it a few more times, but I think you over-complicated that a lot. I would've used one global script to handle all of it.
User avatar
Krystina Proietti
 
Posts: 3388
Joined: Sat Dec 23, 2006 9:02 pm

Post » Mon Dec 21, 2009 4:34 pm

I'm not sure, need to reread it a few more times, but I think you over-complicated that a lot. I would've used one global script to handle all of it.


I tried to use a variable (aaLuteOn) but I must have made a mistkae somewhere, the script did nothing at all (I had a few messageboxes here and ther to see how far the script went, and it went.... nowhere, so I stuck to what I (roughly) understand

The first part of the script was pretty much the same but I added : set aaLuteon to 1 through 4 when checking what lute is equipped and adding the spell, then simply have : if aaLuteon > 0 froce the part that handles playing the song.

I also wondered if I could have a seperate global script that continuously keeps track of which lute is equipped and then only use values of aaLuteOn in the other scripts.
The truth is, I'm way over my head. I just wanted to try and make something by that works myself rather than ask you guys to do it for me.
Bottom line is, any help you can offer is more than welcome ;)
User avatar
Crystal Birch
 
Posts: 3416
Joined: Sat Mar 03, 2007 3:34 pm

Post » Mon Dec 21, 2009 8:04 am

Well... I'm not sure how well this will work, but this is what I have in mind for a similar effect. ;)

You need to use a global script.
When the player equips a sheet of music, set a global variable ( music_type ) to a value for that piece. For example:
if ( "player"->HasItemEquipped "music1" )    Set music_type To 1elseif ( "player"->HasItemEquipped "music2" )    Set music_type To 2elseif ( "player"->HasItemEquipped "music3" )    Set music_type To 3elseif ( "player"->HasItemEquipped "music4" )    Set music_type To 4endif


Now, when they equip a lute and have it drawn, you'll want to trigger the singing, but only once (this also handles the spells):
short doOnceif ( "player"->HasItemEquipped "lute1" )    if ( "player"->HasWeaponDrawn )        if ( doOnce != 1 )           if ( music_type == 0 )                ; play song 1                set doOnce To 1            endif        endif    else        if ( "player"->GetSpell "spell1" == 0 )            "player"->AddSpell "spell1"        endif    endifelseif ( lute2 .... repeat for all )else ; no lute    if ( "player"->HasWeaponDrawn == 0 )        set doOnce to 0    endif    "player"->RemoveSpell "spell1"    ... repeat for other spellsendif


You may need to remove the spell when they draw the lute, but that's the general idea. It all would go in one global script, too, so it might read simpler. Like I said, it needs more work and just some tweaking to make it work right (this is a very small box to be typing that much code and have it visibly fit together), but it's my take on that.
User avatar
rebecca moody
 
Posts: 3430
Joined: Mon Mar 05, 2007 3:01 pm

Post » Mon Dec 21, 2009 11:40 am

Thank you Peachykeen. If I understand this right, having the music sheet 1 sets the global music to 1 which in turn allows to play the song and get the spell.

The thing is, there are up to 40 music sheets to collect, the more sheets you have the greater choice of spells. That's why my failed attempt at using a global script was to detect the lute equipped because there can only be one (sounds like something I know...) equipped at a time. I'll see if I can use the same principle as in your scripts but the other way round...

At this point I would kill for the possibility to OR in a script.

I've been play testing with my lengthy scripts, changing lutes and droping music sheets furiously without problems but I'll try to streamline those scripts.

Thanks again for the scripts PK!

Edit: typos
User avatar
asako
 
Posts: 3296
Joined: Wed Oct 04, 2006 7:16 am

Post » Mon Dec 21, 2009 12:12 pm

Elseif is as close as we to an OR operator. But it would have been nice if Bethesda had the foresight to include Boolean operators like AND and OR and even NOT.
User avatar
Kaley X
 
Posts: 3372
Joined: Wed Jul 05, 2006 5:46 pm

Post » Mon Dec 21, 2009 7:37 pm

Elseif is as close as we to an OR operator. But it would have been nice if Bethesda had the foresight to include Boolean operators like AND and OR and even NOT.


I'm not demanding, just the OR operator would do ;) all these elseif are bloating my scripts!
User avatar
Rob Smith
 
Posts: 3424
Joined: Wed Oct 03, 2007 5:30 pm

Post » Mon Dec 21, 2009 6:48 pm

....


Aw, I totally missed your post Peachykeen... I'll need to read carefully (and ever so slowly) the scripts you've suggested. Thank you for your help, especially since thare was quite a bit of reading and thinking to do ;)
I'll let you know how it worked when I next find the courage to look at my lengthy scripts.

And here I come with another plea for help.
I've made a script (all by myself!!), it works but... you know the rest. (On the bright side I become a little wiser every time I read posts (in this thread or not) on this forum :spotted owl:

This script is attached to a cloak hanging. Activating the cloak give the PC the real cloak, make them equip it and disable the activator.
Here's the code:
Begin aa_PEcloak_get        Short doonce        If ( aaCloakTaken == 0 )        If ( doonce == 1 )            Enable             Set doonce To 0        EndIf    Else        If ( doonce == 0 )            Disable             Set doonce To 1        EndIf    EndIf        If ( OnActivate == 1 )        If ( aaCloakTaken == 0 )            Player->AddItem, "aa_PE_cloak_a" 1            Player->Equip "aa_PE_cloak_a" 1            Set aaCloakTaken To 1        EndIf    EndIf    End

At first my var was local but then I realised I needed a way to hang the cloak back on, so here comes the script attched to the hook:
Begin aa_PEcloak_tidy        If ( OnActivate == 1 )        If ( aaCloakTaken == 1 )        If ( Player -> GetItemCount aa_PE_cloak_a >= 1 )             Player->RemoveItem, "aa_PE_cloak_a" 1            Set aaCloaktaken To 0        EndIf    EndIfEndIf     End

Like I said, it works but I have anagging feeling I'm cluttering MW with global, scripts that don't stop etc...
Should I use doOnce? or StopScript?

As ever, thanks for any advice you may provide.
User avatar
Adrian Powers
 
Posts: 3368
Joined: Fri Oct 26, 2007 4:44 pm

Post » Mon Dec 21, 2009 7:41 pm

I am supposing you have a coat rack with a cloak hanging on it (two separate objects). This can be accomplished without a global variable or global script. The following script is attached to the cloak hanging from the coat rack:

Begin aa_HangingCloak_Script    if ( OnActivate == 1 ) ; must already be enabled or this would not be possible    player->AddItem "aa_PE_cloak_a" 1    DisableendifEnd aa_HangingCloak_Script

This script is attached to the coat rack. Since it references the cloak hanging on it that cloak needs to be marked references persist. For the purpose of this example the ID of the hanging cloak is aa_HangingCloak

Begin aa_CoatRack_Script    if ( OnActivate == 1 )    if ( ( player->GetItemCount "aa_PE_cloak_a" ) >= 1 )         player->RemoveItem "aa_PE_cloak_a" 1        "aa_HangingCloak"->Enable      endIfendIf End aa_CoatRack_Script

These scripts have not been tested.
User avatar
Stace
 
Posts: 3455
Joined: Sun Jun 18, 2006 2:52 pm

Next

Return to III - Morrowind