[HELP} Need help with simple scripting

Post » Sat Feb 19, 2011 6:11 am

Have you used http://cipscis.com/fallout/tutorials/menu.aspx multi level menu tutorial?



yes i've tried that one didn't work
i've changed it after and it still doesn't work
User avatar
Claire Lynham
 
Posts: 3432
Joined: Mon Feb 12, 2007 9:42 am

Post » Sat Feb 19, 2011 7:12 am

after i go into either one of those sub menus .. all buttons stop functioning


Obviously, as you explicitly disable them at that point, you check the buttons once and then never again after setting iMenuLevel to 1



A bit tedious to anolyze with the lack of structure, but this is how it should work properly.


scn AlexSquadRadioScript    short ibutton short iMenuLevel Begin OnEquip          showmessage AlexSquadSummonMenu        	set iMenulevel to 1		   end      Begin GameMode  	if iMenuLevel == 0		return	endif                set iButton to GetButtonPressed   	if iButton == -1        ;Wait until button was pressed 		return 	endif 	if iButton == 0 	;cancel the menu		set iMenulevel to 0  		playsound WPNAlienBlasterFire2D  	elseif iMenuLevel == 1		set iMenulevel to 0		if iButton == 1     ;summon the squad  			set AlexSquadDismis to 0 			placeatme AlexSquadVertibird 1 			set AlexSquadToManySummoned to 3                      		elseif iButton == 2     ;Dismiss the squad 			set AlexSquadDismis to 1             ;Dismiss the squad 			PlaceAtMe AlexSquadVertibird 1  		elseif iButton == 3  ;Tell your squad to use silent weapons			set AlexSquadweaponchange to 1                		elseif iButton == 4 ;tell your squad to use primary weapons			set AlexSquadweaponchange to 0		elseif iButton == 5			ShowMessage AlexWaitOptions			set iMenuLevel to 2		elseif iButton == 6			ShowMessage AlexFollowOptions			set iMenuLevel to 3		endif		elseif iMenuLevel == 2 		set iMenulevel to 0		if iButton == 1			set AlexSquadholdposition to 1                     		elseif iButton == 2			set AlexSquadWaitRelax to 1		endif	elseif iMenuLevel == 3		set iMenulevel to 0		if iButton == 1			set AlexSquadFollowClose to 1		 		elseif iButton == 1			set AlexSquadFollowLong to 1		elseif		endif		end

User avatar
Rebecca Dosch
 
Posts: 3453
Joined: Thu Jan 18, 2007 6:39 pm

Post » Fri Feb 18, 2011 11:50 pm

You have an identical thread at newvegasnexus. Please focus the discussion at one or the other.
User avatar
Zualett
 
Posts: 3567
Joined: Mon Aug 20, 2007 6:36 pm

Post » Sat Feb 19, 2011 8:35 am

yes ... but i'm having discussion with several people ... sometimes is the problem solved there and sometimes here ... i'm keeping an eye on both of them .. saw you posting there too
thanks
User avatar
Daddy Cool!
 
Posts: 3381
Joined: Tue Aug 21, 2007 5:34 pm

Post » Fri Feb 18, 2011 11:36 pm

Obviously, as you explicitly disable them at that point, you check the buttons once and then never again after setting iMenuLevel to 1



A bit tedious to anolyze with the lack of structure, but this is how it should work properly.


scn AlexSquadRadioScript    short ibutton short iMenuLevel Begin OnEquip          showmessage AlexSquadSummonMenu        	set iMenulevel to 1		   end      Begin GameMode  	if iMenuLevel == 0		return	endif                set iButton to GetButtonPressed   	if iButton == -1        ;Wait until button was pressed 		return 	endif 	if iButton == 0 	;cancel the menu		set iMenulevel to 0  		playsound WPNAlienBlasterFire2D  	elseif iMenuLevel == 1		set iMenulevel to 0		if iButton == 1     ;summon the squad  			set AlexSquadDismis to 0 			placeatme AlexSquadVertibird 1 			set AlexSquadToManySummoned to 3                      		elseif iButton == 2     ;Dismiss the squad 			set AlexSquadDismis to 1             ;Dismiss the squad 			PlaceAtMe AlexSquadVertibird 1  		elseif iButton == 3  ;Tell your squad to use silent weapons			set AlexSquadweaponchange to 1                		elseif iButton == 4 ;tell your squad to use primary weapons			set AlexSquadweaponchange to 0		elseif iButton == 5			ShowMessage AlexWaitOptions			set iMenuLevel to 2		elseif iButton == 6			ShowMessage AlexFollowOptions			set iMenuLevel to 3		endif		elseif iMenuLevel == 2 		set iMenulevel to 0		if iButton == 1			set AlexSquadholdposition to 1                     		elseif iButton == 2			set AlexSquadWaitRelax to 1		endif	elseif iMenuLevel == 3		set iMenulevel to 0		if iButton == 1			set AlexSquadFollowClose to 1		 		elseif iButton == 1			set AlexSquadFollowLong to 1		elseif		endif		end




thanks JOG .. you're saviour ..
User avatar
Rhi Edwards
 
Posts: 3453
Joined: Fri Jul 28, 2006 1:42 am

Post » Fri Feb 18, 2011 9:21 pm

btw .. is there any way to learn c++ without going to school for it ???
i mean .. a book or site ?/

thanks
User avatar
Petr Jordy Zugar
 
Posts: 3497
Joined: Tue Jul 03, 2007 10:10 pm

Post » Sat Feb 19, 2011 1:20 am

btw .. is there any way to learn c++ without going to school for it ???
i mean .. a book or site ?/

thanks



The TES/FO scripting language doesn't really have much in common with C, it's more like a very rudimentary basic dialect with the standard C variable types.

The best way to learn programming is by writing your own scripts and examining similar scripts writen by others to get some hints on scripting techniques. Of course there are books and tutorials to be found with google, but most of the time one isn't patient enough to follow them properly.

If you really want to learn a programming language by books and tutorials, I'd go for Microsofts Visual Basic as used in Excel / Word Macros. It can be very useful in any office-job even if you don't plan to become a programmer and loose interest in modding. Once you know one programming language, it's rather easy to learn the other ones.


I was bored, so here is how I would write the above script in a C dialect:

scn AlexSquadRadioScript    int ibutton; int iMenuLevel; Begin OnEquip{          showmessage(AlexSquadSummonMenu);  	iMenulevel = 1;}Begin GameMode{          if (iMenuLevel == 0) return;                iButton = GetButtonPressed;           if (iButton == -1) return;         if (iButton == 0)	{                iMenulevel = 0;                  playsound(WPNAlienBlasterFire2D);	}	else	{		ibutton += iMenuLevel*10;		imenulevel=0;		switch(ibutton)		{			case 11:        AlexSquadDismis = 0; 					placeatme(AlexSquadVertibird,1);                 	        	AlexSquadToManySummoned = 3;					break;			case 12:	AlexSquadDismis = 1;             // Dismiss the squad         	                	PlaceAtMe(AlexSquadVertibird,1);					break;  			case 13:	AlexSquadweaponchange=1; break;			case 14:	AlexSquadweaponchange=0; break;				case 15:	showMessage(AlexWaitOptions);	        	                iMenuLevel = 2;					break;			case 16:	showMessage(AlexFollowOptions);         	                	iMenuLevel = 3;					break; 			case 21:	AlexSquadholdposition = 1; break; 				case 22:	AlexSquadWaitRelax = 1; break; 			case 31:	AlexSquadFollowClose = 1; break; 				case 32:	AlexSquadFollowLong = 1; break; 				}         	}}

User avatar
Jason King
 
Posts: 3382
Joined: Tue Jul 17, 2007 2:05 pm

Post » Sat Feb 19, 2011 2:40 am

thanks for the reply .. i'll start with simple codes then
User avatar
Brandon Wilson
 
Posts: 3487
Joined: Sat Oct 13, 2007 1:31 am

Post » Sat Feb 19, 2011 12:50 am

btw .. i was trying to assign the summon menu to NVSE button press .. but the menu is not working at all .. i've done something similar with (add item) on button press in the past for FO3 .. but .. it seems that menu needs something else ... does it need a token to function ???
User avatar
cassy
 
Posts: 3368
Joined: Mon Mar 05, 2007 12:57 am

Post » Sat Feb 19, 2011 3:40 am

btw .. i was trying to assign the summon menu to NVSE button press .. but the menu is not working at all .. i've done something similar with (add item) on button press in the past for FO3 .. but .. it seems that menu needs something else ... does it need a token to function ???



Do you mean http://cs.elderscrolls.com/constwiki/index.php/IsKeyPressed so that you can make a keyboard hotkey for your menu? Should work fine, but you need to check for the key in gamemode block
Begin GameMode           if IsKeypressed 47  ;V for Vertibifd                   showmessage AlexSquadSummonMenu                    set iMenulevel to 1          endif         if iMenuLevel == 0                return        endif                set iButton to GetButtonPressed          [...]


A "Token" in TES/FO scripting usually means an item you use instead of a variable. If you need to set a flag on a random NPC give him an item and check for the item to determine if the flag is set. You don't need this here.

Generally, a "token" means a placeholder to make talking with the computer easier. The computer only knows numbers, so each script command needs to be split up into a sequence of numbers. In the compiled script that actually runs in the game, "if IsKeypressed 47" might be the numeric sequence 16, 8778, 44 (just an example). In this case "If" is the token for the script command #16 and "IsKeyPressed" is the token for the script command #8778. Even the 47 as we see it here, is just a token, we need to write it with two digits, but translated to a number it is only one byte / char long, (well, depending on the script interpreter it might be actually two or four bytes long, but additional bytes would contain 0s)
User avatar
Michelle Chau
 
Posts: 3308
Joined: Sat Aug 26, 2006 4:24 am

Post » Fri Feb 18, 2011 5:58 pm

aha .. i see .. thanks
User avatar
Amie Mccubbing
 
Posts: 3497
Joined: Thu Aug 31, 2006 11:33 pm

Post » Fri Feb 18, 2011 8:12 pm

i've managed to script way pointer .. or what you would call it .. placing activators and telling your squad members move to them .. and many other handy things ...
the whole mod is starting to coming together nicely ...

thanks again JOG
User avatar
Soph
 
Posts: 3499
Joined: Fri Oct 13, 2006 8:24 am

Post » Sat Feb 19, 2011 9:53 am

so it seems that i have cheered a bit too early ... the squad seems responding with no problems to the vanilla markers .. but the custom ones placed with the command place on do not seem to work

... i have set up an activater with a code

scn AlexSquadAssaultStealthToScriptFloat Timershort doOnceBegin OnLoad     	if doOnce == 0          Set timer to 30          PlaceAtMe AlexSquadMarker 1                  set AlexSquadAssaultStealthToMarker to 1          ShowMessage AlexMoveInStealthIsWorking		set doOnce to 1	endif	EndBegin GameMode	if timer > 0		set timer to timer - getsecondspassed        	else           set AlexSquadAssaultStealthToMarker to 0           		disable		MarkForDelete	endifEnd

which activates a varriable in another script and another script adds a scriptpackage in which MYmarker is specified as a reference
works fine with the vanilla markers .. has anyone any idea how i can force the npc move to the newly spawned marker ??

thanks
Alex
User avatar
Ridhwan Hemsome
 
Posts: 3501
Joined: Sun May 06, 2007 2:13 pm

Post » Sat Feb 19, 2011 9:27 am

You can't use placeatme objects as the target of a script package. What you can do is to link your script package to markers you place in a holding cell, then use moveto to move the marker to a location you need. So if it's the activators location you want them to move to, move the xmarker, or xmarkerheading (that is the target of your script package) to the activator.
User avatar
Thomas LEON
 
Posts: 3420
Joined: Mon Nov 26, 2007 8:01 am

Post » Fri Feb 18, 2011 6:25 pm

so if i have linked the script package to the custom xmarker (AlexSquadMarker) located in a custom cell

then what would the code look like ?

Begin OnLoad

if doOnce == 0
Set timer to 30
move AlexSquadMarker to activator

set AlexSquadAssaultStealthToMarker to 1
ShowMessage AlexMoveInStealthIsWorking
set doOnce to 1
endif
User avatar
Juanita Hernandez
 
Posts: 3269
Joined: Sat Jan 06, 2007 10:36 am

Post » Sat Feb 19, 2011 5:54 am

the geck seems to be allergic to this line
AlexSquadMarker.moveto AlexSquadStealthToMarker
User avatar
Stryke Force
 
Posts: 3393
Joined: Fri Oct 05, 2007 6:20 am

Post » Fri Feb 18, 2011 5:24 pm

First off you will need to create a reference to the activator. You are placing the activator using placeatme? If so where ever you call that placeatme call it like so...

set MyActivator to placeatme ;whatever you are using

you will need to add ref MyActivator to that script.

Then the xmarker you used needs to have a referenceid in case you are using the name of the object. Right click it in the render window and select edit, then fill in a name in the reference id field.

Then after you call the above line call this like so...

set MyActivator to placeatme ;whatever you are using
myMarkerRef.moveto MyActivator

It may be possible to use the getself function to set a reference to the activator from it's own script. Not sure as I don't remember if getself returns a reference for an activator. If it does then something like so...

ref me

Begin OnLoad

if doOnce == 0
set me to getself
Set timer to 30
AlexSquadMarker.move to me ;where AlexSquadMarker is the reference id of the xmarker

set AlexSquadAssaultStealthToMarker to 1
ShowMessage AlexMoveInStealthIsWorking
set doOnce to 1
endif
User avatar
Alina loves Alexandra
 
Posts: 3456
Joined: Mon Jan 01, 2007 7:55 pm

Post » Fri Feb 18, 2011 10:03 pm

no the activator is placed by an explosion from projectile .. from a gun :)
User avatar
Cedric Pearson
 
Posts: 3487
Joined: Fri Sep 28, 2007 9:39 pm

Post » Sat Feb 19, 2011 2:40 am

Well try the last bit of code I posted with the getself function. I think it will work.
User avatar
Lizzie
 
Posts: 3476
Joined: Sun Nov 19, 2006 5:51 am

Post » Fri Feb 18, 2011 10:24 pm

damn ... the geck doesn't want to accept the move command

scn AlexSquadAssaultStealthToScriptref meFloat Timershort doOnceBegin OnLoad     	     if doOnce == 0          set me to getself           AlexSquadMarker.move to me                    ;where AlexSquadMarker is the reference id of the xmarker          Set timer to 30          set AlexSquadAssaultStealthToMarker to 1          ShowMessage AlexMoveInStealthIsWorking		set doOnce to 1endif	EndBegin GameMode	if timer > 0		set timer to timer - getsecondspassed        	else           set AlexSquadAssaultStealthToMarker to 0           		disable		MarkForDelete	endifEnd

User avatar
Brad Johnson
 
Posts: 3361
Joined: Thu May 24, 2007 7:19 pm

Post » Sat Feb 19, 2011 1:24 am

AlexSquadMarker.moveto me

geck: only object references and reference variables are allowed in this context

EDIT: done that too

doesnt seem to work ...but thanks for trying anyway :)
User avatar
Ymani Hood
 
Posts: 3514
Joined: Fri Oct 26, 2007 3:22 am

Post » Sat Feb 19, 2011 2:48 am

Typo should be moveto not move to, all one word.
User avatar
louise hamilton
 
Posts: 3412
Joined: Wed Jun 07, 2006 9:16 am

Post » Sat Feb 19, 2011 2:05 am

AlexSquadMarker.moveto me

geck: only object references and reference variables are allowed in this context

EDIT: done that too

doesnt seem to work ...but thanks for trying anyway :)
User avatar
Kat Ives
 
Posts: 3408
Joined: Tue Aug 28, 2007 2:11 pm

Post » Sat Feb 19, 2011 7:03 am

That's what I was afraid of. Just saw on the wiki that getself fails on objects created dynamically. Still should work if you set a reference to the activator when it is placed by your explosion, and use that reference to move the xmarker to from the explosion script. Does the explosion script not place the activator using placeatme?
User avatar
Antony Holdsworth
 
Posts: 3387
Joined: Tue May 29, 2007 4:50 am

Post » Sat Feb 19, 2011 12:33 am

just gave it a ref id .. by double clicking on it in the world window and adding one
AlexSquadAssaultMarker.moveto me

the script can be saved now .. but still doesn't work ...

no the explosion is using the game's default function .. you can choose to leave after the explosion .. like bits of canister or something
User avatar
Lou
 
Posts: 3518
Joined: Wed Aug 23, 2006 6:56 pm

PreviousNext

Return to Fallout: New Vegas