Contain text with choice function within one animation SOLVED

ABK

Well-known member
Hey guys ive got this script with text function working and choosing fighting or talking with left/right but its not what i want in the end , i mean i want it to be super compact and use just one animation for entire negotiation so i can just switch to other animation for other negotiations instead of using new txt files for each, now i had to split this into a couple of animations because i was getting infinite loop issue if i pressed let/right quickly a couple of times and engine crashed.Now it does not crash how i set it up.
Any clue how to do it in one animation ? Theres 3 or 4  options, one is highlighted "fight" , other one is highlighted "talk" and last two are confirmations of the ones above that are activated with attack button.So ideally it would use 4 frames of animation, maybe five because first frame would be sound of menu appearing.
I tried updateframe and one animation but im getting infinite loop, also with "delay -1" detecting keys pressed does not work, delay has to be quite low, 10 or 20.
Its a quick test to try if it works, it does work but i dont want to make new entity for every conversation/negotiation onscreen.
8d27b5da.gif

Code:
name    	dial
type    	text
subject_to_minz 0
subject_to_maxz 0
subject_to_wall 0
subject_to_hole 0


anim idle
	loop	1 2 
	delay	5
				@script
                void self = getlocalvar("self");
                int iPIndex = getentityproperty(self,"playerindex"); //Get player index
                void p2 = playerkeys(iPIndex, 0, "moveleft");
				 void at = playerkeys(iPIndex, 0, "attack");
		if ( frame > 1 && p2 ){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
                }
								if (frame > 1 && at){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
                }
	@end_script
	
	OFFSET 1 1
		SOUND  DATA/sounds/LASER2.wav
				frame	NONE
					frame	NONE
			@cmd	settextobj 1 420 300 0 -1 "MAKE_A_CHOICE_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 2 700 400 1 -1 "FIGHT_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 3 200 400 0 -1 "TALK_! " openborvariant("elapsed_time")+150
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
		frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE


anim follow1
	loop	1 2
	delay	5
				@script
                void self = getlocalvar("self");
                int iPIndex = getentityproperty(self,"playerindex"); //Get player index
                void p1 = playerkeys(iPIndex, 0, "moveright");
				 void at = playerkeys(iPIndex, 0, "attack");
		if (frame > 1 && p1){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
                }
								if (frame > 1 && at){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
                }
	@end_script
	OFFSET 1 1
		SOUND  DATA/sounds/beep.wav
				frame	NONE
						frame	NONE
			@cmd	settextobj 1 420 300 0 -1 "MAKE_A_CHOICE_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 2 700 400 0 -1 "FIGHT_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 3 200 400 1 -1 "TALK_! " openborvariant("elapsed_time")+150
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
		frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE

	
anim FOLLOW2
	loop	1 2 
	delay	5
				@script
                void self = getlocalvar("self");
                int iPIndex = getentityproperty(self,"playerindex"); //Get player index
                void p2 = playerkeys(iPIndex, 0, "moveleft");
				 void at = playerkeys(iPIndex, 0, "attack");
		if (frame > 1 && p2){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
                }
				if (frame > 1 && at){
                changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
                }
	@end_script
	
	OFFSET 1 1
		SOUND  DATA/sounds/beep.wav
				frame	NONE
					frame	NONE
			@cmd	settextobj 1 420 300 0 -1 "MAKE_A_CHOICE_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 2 700 400 1 -1 "FIGHT_! " openborvariant("elapsed_time")+150
			@cmd	settextobj 3 200 400 0 -1 "TALK_! " openborvariant("elapsed_time")+150
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
		frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	
	
	
	anim FOLLOW3
	loop	0
	delay	100
	OFFSET 1 1
	SOUND  DATA/sounds/beep2.wav
	@cmd	settextobj 1 440 300 3 -1 "SUCCESS_! " openborvariant("elapsed_time")+250
	@cmd	settextobj 2 420 400 3 -1 "_ " openborvariant("elapsed_time")+250
	@cmd	settextobj 3 420 500 3 -1 "_ " openborvariant("elapsed_time")+250
	frame	NONE
	frame	NONE
 
i mean i want it to be super compact and use just one animation for entire negotiation so i can just switch to other animation for other negotiations instead of using new txt files
But you don't need to use new txt. Just use multiple follow animations.

This is something so simple that I would avoid to use an updateframe for that because, like the same says, it will be constantly updated and that consumes more resource than using a simple animation.
 
Your working script above is similar to mine except that I use global key capture script instead of local key capture script like this

Anyways, as for wrapping it into one animation .... hmmm... try using entity variable to store menu state. Say, 0 for when TALK is highlighted, 1 for FIGHT highlighted and so on. Then text function and select function will run based on stored menu state

That's my suggestion
 
bWWd
give the dial entity its own keyscript file to capture inputs and change animation. When you spawn the dial entity use a alias and make a script in spawn animation to change to the animation set to the alias here is a example.

example level spawn:
Code:
spawn dial
alias     ani_follow1
at          0

example entity spawn animation:
Code:
anim spawn
loop  0
delay 3 #this is the minimum delay between first frame and any scripts to avoid bugs.
frame	NONE
@cmd name2ani
frame	NONE

example animation script:
Code:
void name2ani()
{// msmalik681 animation changer based on name.

	void self = getlocalvar("self"); //get caller.
	char name = getentityproperty(self, "name"); //get current alias.
	char dname = getentityproperty(self, "defaultname"); //get model name.

	if(name != dname) { //check if a alias was used.
	 changeentityproperty(self, "animation", openborconstant(name)); //Change the animation.
	}
}

When using keyscript you can identify your current animation using getentityproperty(self, "animation") "animation" - The handle of current animation. HTH.

This is just a personal recommendation but any time you are tempted to use @script make a animationscript so you can use @cmd instead.  "frame NONE" is new to me I will be making use of that thank you.

Bloodbane  Sorry but could you give a example of a global key capture versus a local key capture please. Also I know its a bit late but Eid Mubarak.
 
Thanks, i did it with variables, it works but id like to have sounds when i change the option ,i want to use beep.wav thats loaded by openbor , i dont want to load it again , is there any way to acquire it from the engine without loading?Also im getting loop for awhile when i playsample, plays it about 3 times in a row .
Code:
anim idle
	loop	1 2
	delay	5
				@script
                void self = getlocalvar("self");
                int iPIndex = getentityproperty(self,"playerindex"); //Get player index
				void p2 = playerkeys(iPIndex, 0, "moveright");
                void p1 = playerkeys(iPIndex, 0, "moveleft");
				 void at = playerkeys(iPIndex, 0, "attack");
				 												if ( frame == 1 ){
 			setglobalvar("dial", 1); 
                }
						if ( frame > 2 && p1 ){
              setglobalvar("dial", 2); 
                }
										if ( frame > 2 && p2 ){
              setglobalvar("dial", 1); 
                }
		if ( frame > 2 && getglobalvar("dial")== 1  ){
				 settextobj(1, 420 , 300, 0, -1, "MAKE_A_CHOICE_! " ,openborvariant("elapsed_time")+150);
				 settextobj(2, 700 , 400, 1, -1, "FIGHT_! " ,openborvariant("elapsed_time")+150);
				 settextobj(3, 200 , 400, 0, -1, "TALK_! " ,openborvariant("elapsed_time")+150);
                }
								if ( frame > 2 && getglobalvar("dial")== 2    ){
				 settextobj(1, 420 , 300, 0, -1, "MAKE_A_CHOICE_! " ,openborvariant("elapsed_time")+150);
				 settextobj(2, 700 , 400, 0, -1, "FIGHT_! " ,openborvariant("elapsed_time")+150);
				 settextobj(3, 200 , 400, 1, -1, "TALK_! " ,openborvariant("elapsed_time")+150);
                }
												if ( frame > 20 ){
 				 settextobj(1, 420 , 300, 0, -1, "_ " ,openborvariant("elapsed_time")+150);
				 settextobj(2, 700 , 400, 0, -1, "_ " ,openborvariant("elapsed_time")+150);
				 settextobj(3, 200 , 400, 1, -1, "_" ,openborvariant("elapsed_time")+150);
                }
						if ( at && getglobalvar("dial")== 1  ){

				 settextobj(1, 420 , 300, 3, -1, "LETS_FIGHT_! " ,openborvariant("elapsed_time")+150);
				 settextobj(2, 700 , 400, 1, -1, "_" ,openborvariant("elapsed_time")+150);
				 settextobj(3, 200 , 400, 0, -1, "_ " ,openborvariant("elapsed_time")+150);
				   killentity(self);
                }
										if ( at && getglobalvar("dial")== 2  ){

				 settextobj(1, 420 , 300, 3, -1, "LETS_TALK_! " ,openborvariant("elapsed_time")+150);
				 settextobj(2, 700 , 400, 1, -1, "_" ,openborvariant("elapsed_time")+150);
				 settextobj(3, 200 , 400, 0, -1, "_ " ,openborvariant("elapsed_time")+150);
				   killentity(self);
                }
	@end_script
	OFFSET 1 1
	SOUND  DATA/sounds/LASER2.wav
	frame	NONE
	frame	NONE
	SOUND  DATA/sounds/mine.wav
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
 
Just run the loadsample function on the beep file as if you were loading a new sound. That will get you the sample number, and then you use that for the sound playing functions.

I remember telling you this before, loadsample knows if a sound file exists already and won't try to reload it - it will just tell you the ID that file already has.

DC
 
yeah ive got that workin fine but now i cant rid of the loop without complicating script too much, im wrestling with ideas for now.
----
I got rid of sample loop but now i cant switch options immediately, have to wait for certain frame.Works ok, feels crap.
----
Ok after awhile i think ive got it done, feel free to make it more copact, its contained within one animation, so if you want to make different scenario/conversation then just switch to different follow animation for entire dialogue, this way you can use just one text entity for all dialogues in game.
The only quirk i have is when you go left/right for a couple of times quite fast then fight and talk options disappear for awhile,  but then comes back ok after animation loops.
Thanks guys for suggestions and Bloodbane for mentioning variables.
Code:
type    	text
subject_to_minz 0
subject_to_maxz 0
subject_to_wall 0
subject_to_hole 0


anim idle
	loop	1 2
	delay	4
				@script
                void self = getlocalvar("self");
                int iPIndex = getentityproperty(self,"playerindex"); //Get player index
				int beep = loadsample("data/sounds/mine.wav");
				int beep2 = loadsample("data/sounds/beep2.wav");
				void counter;
				void dial;
				void p2 = playerkeys(iPIndex, 0, "moveright");
                void p1 = playerkeys(iPIndex, 0, "moveleft");
				 void at = playerkeys(iPIndex, 0, "attack");
if ( frame == 1 ){
 	        setglobalvar("dial", 1); 
	         setglobalvar("counter", 0);
		 	 settextobj(1, 420 , 300, 0, -1, "MAKE_A_CHOICE_! " ,openborvariant("elapsed_time")+550);
			 settextobj(2, 700 , 400, 1, -1, "FIGHT_! " ,openborvariant("elapsed_time")+150);
			 settextobj(3, 200 , 400, 0, -1, "TALK_! " ,openborvariant("elapsed_time")+150);
                }
if ( getglobalvar("counter")!= 1 && frame > 2 && p1 && getglobalvar("dial")!= 2 ){
					 setglobalvar("counter", 1);
					  playsample(beep);
					  setglobalvar("dial", 2); 
		                }
if (  getglobalvar("counter")!= 1 &&  frame > 2 && p2 && getglobalvar("dial")!= 1 ){
					setglobalvar("counter", 1);
					playsample(beep);
					setglobalvar("dial", 1); 
	               }
if ( getglobalvar("counter")!= 1 && frame > 2 && getglobalvar("dial")== 1  ){
			 settextobj(1, 420 , 300, 0, -1, "MAKE_A_CHOICE_! " ,openborvariant("elapsed_time")+550);
			 settextobj(2, 700 , 400, 1, -1, "FIGHT_! " ,openborvariant("elapsed_time")+150);
			 settextobj(3, 200 , 400, 0, -1, "TALK_! " ,openborvariant("elapsed_time")+150);
				     
                }
if (  getglobalvar("counter")!= 1 && frame > 2 && getglobalvar("dial")== 2    ){
			 settextobj(1, 420 , 300, 0, -1, "MAKE_A_CHOICE_! " ,openborvariant("elapsed_time")+550);
			 settextobj(2, 700 , 400, 0, -1, "FIGHT_! " ,openborvariant("elapsed_time")+150);
			 settextobj(3, 200 , 400, 1, -1, "TALK_! " ,openborvariant("elapsed_time")+150);
				
                }
if ( frame > 20 ){											  
 				settextobj(1, 420 , 300, 0, -1, "MAKE_A_CHOICE_! " ,openborvariant("elapsed_time")+550);
			    settextobj(2, 700 , 400, 0, -1, "_ " ,openborvariant("elapsed_time")+150);
			    settextobj(3, 200 , 400, 1, -1, "_" ,openborvariant("elapsed_time")+150);
			    setglobalvar("counter", 0);
                }
if ( getglobalvar("counter")!= 1  && at && getglobalvar("dial")== 1  ){
						
               playsample(beep2);
               setglobalvar("counter", 1);
	 		   settextobj(1, 420 , 300, 3, -1, "LETS_FIGHT_! " ,openborvariant("elapsed_time")+150);
			   settextobj(2, 700 , 400, 1, -1, "_" ,openborvariant("elapsed_time")+150);
			   settextobj(3, 200 , 400, 0, -1, "_ " ,openborvariant("elapsed_time")+150);
			   killentity(self);
                }
if ( getglobalvar("counter")!= 1  && at && getglobalvar("dial")== 2  ){
				
                  playsample(beep2);
                 setglobalvar("counter", 1);
	 			 settextobj(1, 420 , 300, 3, -1, "LETS_TALK_! " ,openborvariant("elapsed_time")+150);
				 settextobj(2, 700 , 400, 1, -1, "_" ,openborvariant("elapsed_time")+150);
				 settextobj(3, 200 , 400, 0, -1, "_ " ,openborvariant("elapsed_time")+150);
				 killentity(self);
                }
	@end_script
	OFFSET 1 1
	SOUND  DATA/sounds/LASER2.wav
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
	frame	NONE
		frame	NONE
	frame	NONE
	frame	NONE





	
	anim FOLLOW3
	loop	0
	delay	100
	OFFSET 1 1
	SOUND  DATA/sounds/beep2.wav
	@cmd	settextobj 1 440 300 3 -1 "SUCCESS_! " openborvariant("elapsed_time")+250
	@cmd	settextobj 2 420 400 3 -1 "_ " openborvariant("elapsed_time")+250
	@cmd	settextobj 3 420 500 3 -1 "_ " openborvariant("elapsed_time")+250
	frame	NONE
	frame	NONE
 
bWWd
I have a idea but it is too much to explain here is a example demo find "Data\CHARS\misc\APPLE.TXT" it has everything you need only annoying thing was I had to play selection samples though frame data and playsample would not work by script so you hear a selection chime when the entity is spawned.

Download example demo: https://www.mediafire.com/file/hb5nce4b0w5wyvy/choice_selection_test.zip/file

APPLE.TXT:
Code:
name	Apple
type	text
subtype	noskip
shadow	0


anim idle
	loop	0
	delay	5
	offset	8 14
@script
	void self = getlocalvar("self");
	int iPIndex = getentityproperty(self,"playerindex"); //Get player index
	void right = playerkeys(iPIndex, 0, "moveright");
	void left = playerkeys(iPIndex, 0, "moveleft");
	void pick = playerkeys(iPIndex, 0, "attack");
	int	Cframe = getentityproperty(self,"animpos");
	
	if(frame>=1)
	{
	//settextobj(5,20,20,3,999999999,""+Cframe);
	if(Cframe==3 && right) {updateframe(self,4);}
	if(Cframe==6 && left) {updateframe(self,0);}
	
	if(Cframe==3 && pick) {updateframe(self,7);}
	if(Cframe==6 && pick) {updateframe(self,8);}
	}
@end_script
	frame	none #0
	sound	data/sounds/1up.wav
	frame	none #1
	@cmd	settextobj 0 100 50 0 999999999 "MAKE_A_CHOICE_!"
	@cmd	settextobj 1 50 150 1 999999999 "FIGHT_!"
	@cmd	settextobj 2 200 150 0 999999999 "TALK_!"
	frame	none #2
	@cmd	updateframe getlocalvar("self") 2
	frame	none #3
	sound	data/sounds/1up.wav
	frame	none #4
	@cmd	settextobj 0 100 50 0 999999999 "MAKE_A_CHOICE_!"
	@cmd	settextobj 1 50 150 0 999999999 "FIGHT_!"
	@cmd	settextobj 2 200 150 1 999999999 "TALK_!"
	frame	none #5
	@cmd	updateframe getlocalvar("self") 5
	frame	none #6
	sound	data/sounds/1up.wav
	@cmd	cleartextobj 0
	@cmd	cleartextobj 1
	@cmd	settextobj 2 160 120 1 999999999 "YOU_PICKED_FIGHT!" 1500
	@cmd	killentity getlocalvar("self")
	frame	none #7
	sound	data/sounds/1up.wav
	@cmd	cleartextobj 0
	@cmd	cleartextobj 1
	@cmd	settextobj 2 160 120 1 999999999 "YOU_PICKED_TALK!" 1500
	@cmd	killentity getlocalvar("self")
	frame	none #8
 
Thats cool and compact,  can it be modified to blink ? Mine blinks, without it its a bit plain.
Also on first appearance of the menu im using different soun than later sound with left/right press.
Anyway i think ill use it, i like it better than mine , also i fixed soem stuff, you killed entity too soon before it could display text
I still would like it to blink, i see it is possible with animpos but would make the animation much longer just for the blink and separate script lines to avoid sound looping.

Code:
anim idle
	loop	0
	delay	5
	offset	8 14
@script
	void self = getlocalvar("self");
	int iPIndex = getentityproperty(self,"playerindex"); //Get player index
	void right = playerkeys(iPIndex, 0, "moveright");
	void left = playerkeys(iPIndex, 0, "moveleft");
	void pick = playerkeys(iPIndex, 0, "attack");
	int	Cframe = getentityproperty(self,"animpos");
	
	if(frame>=1)
	{
	//settextobj(5,20,20,3,999999999,""+Cframe);
	if(Cframe==2 && right) {updateframe(self,4);}
	if(Cframe==5 && left) {updateframe(self,1);}
	
	if(Cframe==2 && pick) {updateframe(self,7);}
	if(Cframe==5 && pick) {updateframe(self,8);}
	}
@end_script
	sound	data/sounds/laser2.wav
	frame	none #0
	
	sound	data/sounds/beep.wav
	frame	none #1
	@cmd	settextobj 0 420 250 0 -1 "MAKE_A_CHOICE_!"
	@cmd	settextobj 1 700 150 0 -1 "FIGHT_!"
	@cmd	settextobj 2 200 150 1 -1 "TALK_!"
	frame	none #2
	@cmd	updateframe getlocalvar("self") 2
	frame	none #3
	
	sound	data/sounds/beep.wav
	frame	none #4
	@cmd	settextobj 0 420 250 0 -1 "MAKE_A_CHOICE_!"
	@cmd	settextobj 1 700 150 1 -1 "FIGHT_!"
	@cmd	settextobj 2 200 150 0 -1 "TALK_!"
	frame	none #5
	@cmd	updateframe getlocalvar("self") 5
	frame	none #6
	
	sound	data/sounds/beep2.wav
	@cmd	settextobj 3 400 120 1 -1 "YOU_PICKED_TALK!" openborvariant("elapsed_time")+250
	@cmd	settextobj 0 400 220 1 -1 "_" 1500
	@cmd	settextobj 1 400 220 1 -1 "_" 1500
	@cmd	settextobj 2 400 220 1 -1 "_" 1500
		@cmd	killentity getlocalvar("self") 
	frame	none #7
	sound	data/sounds/beep2.wav
	@cmd	settextobj 3 400 120 1 -1 "YOU_PICKED_FIGHT!" openborvariant("elapsed_time")+250
	@cmd	settextobj 0 400 220 1 -1 "_" 1500
	@cmd	settextobj 1 400 220 1 -1 "_" 1500
	@cmd	settextobj 2 400 220 1 -1 "_" 1500
		@cmd	killentity getlocalvar("self") 
	frame	none #8
 
@cmd commands execute in the order they are written there was no need to move killentity to the next frame.

Glad you found that useful. You could make it blink by adding a longer delay after the text objects then looping back to the frame the text objects were made also you may have to extend the frame range for key inputs.
 
yeah but that makes the scrtipt  alot more convoluted just for the blink, its good how it is right now, thanks a lot !
Youre right, killentity was last and all above it was executing, I had to do modifications because in your original "you picked talk" was not showing, also i had problem with text not showing sometimes randomly , probably  both because of  cleartext but after extensive testing ive got it working without stuff disappearing.
 
TLDR

msmalik681  : Eid Mubarak :D

Example of global key event capture script can be found in Map demo. The script uses keyall.c .
The purpose is to capture key press and key release event. Usage example is Arthur's NPC summon uses key press capture to move the cursor when NPC menu appears. The script can also be used for other purposes such as personal inventory and NPC dialogue
I didn't capture key hold cause it could cause cursor (in example above) to move too quickly and skipped selection in between.

bWWd's dialogue only has 2 options so holding left or right won't move highlight or whatever too far

As for which one is better, I can't say for sure. I only know for sure that if I want to capture key press/release, I use that global key capture script. OTOH if I want to capture key hold, I use this for example: playerkeys(iPIndex, 0, "moveleft")
 
I have one more question, im using this for 3 option menu but when i want to cancel then text entity is still activeand its pausing the game despite changing it to type enemy on canceling, any clue how to cancel the menu and unpause without killing entity? I just switch animations when its canceled and wait for awhile then make the entity active again so menu will open again.
Or maybe some other idea how to cancel and disable it until player goes away then comes back or something...
6269e557.jpg

Code:
anim	follow7
	loop	0
	delay	5
	offset	8 14
@script
	void self = getlocalvar("self");
	int iPIndex = getentityproperty(self,"playerindex"); //Get player index
	void right = playerkeys(iPIndex, 0, "moveright");
	void left = playerkeys(iPIndex, 0, "moveleft");
		void down = playerkeys(iPIndex, 0, "movedown");
			void up = playerkeys(iPIndex, 0, "moveup");
	void pick = playerkeys(iPIndex, 0, "attack");
	int	Cframe = getentityproperty(self,"animpos");

	if(frame>=1)
	{
	//settextobj(5,20,20,3,999999999,""+Cframe);
		if(Cframe==2 && right) {updateframe(self,4);}
	if(Cframe==5 && left) {updateframe(self,1);}
	if(Cframe==2 && down) {updateframe(self,9);}
	if(Cframe==5 && down) {updateframe(self,9);}

                if(Cframe==10 && up) {updateframe(self,4);}


	if(Cframe==2 && pick) {updateframe(self,7);}
	if(Cframe==5 && pick) {updateframe(self,8);}
	if(Cframe==10 && pick) {updateframe(self,12);}
	}
	@end_script
	@cmd	changeentityproperty getlocalvar("self") "type" openborconstant("TYPE_TEXTBOX")
	@cmd	changeentityproperty getlocalvar("self") "subtype" openborconstant("SUBTYPE_NOSKIP")
	sound	data/sounds/laser2.wav
	frame	none #0
	sound	data/sounds/beep.wav
	frame	none #1
	@cmd	settextobj 0 420 260 2 -1 "MAKE_A_CHOICE:"
	@cmd	settextobj 1 700 150 0 -1 "BACK TO MAP"
	@cmd	settextobj 2 160 150 1 -1 "RESET ALL PROGRESS"
	@cmd	settextobj 4 460 180 0 -1 "CANCEL"
	frame	none #2
	@cmd	updateframe getlocalvar("self") 2
	frame	none #3
	sound	data/sounds/beep.wav
	frame	none #4
	@cmd	settextobj 0 420 260 2 -1 "MAKE_A_CHOICE:"
	@cmd	settextobj 1 700 150 1 -1 "BACK TO MAP"
	@cmd	settextobj 2 160 150 0 -1 "RESET ALL PROGRESS"
	@cmd	settextobj 4 460 180 0 -1 "CANCEL"
	frame	none #5
	@cmd	updateframe getlocalvar("self") 5
	frame	none #6
	sound	data/sounds/select.wav
	@cmd	settextobj 3 400 220 2 -1 "LETS_RESET_!" openborvariant("elapsed_time")+250
	@cmd	settextobj 0 400 220 1 -1 "_" 50
	@cmd	settextobj 1 400 220 1 -1 "_" 50
	@cmd	settextobj 2 400 220 1 -1 "_" 50
	@cmd	clearglobalvar()
	@cmd	jumptobranch "Nam" 1
	frame	none #7
	sound	data/sounds/select.wav
	@cmd	settextobj 3 400 220 2 -1 "LETS_GO_BACK_!" openborvariant("elapsed_time")+250
	@cmd	settextobj 0 400 220 1 -1 "_" 50
	@cmd	settextobj 1 400 220 1 -1 "_" 50
	@cmd	settextobj 2 400 220 1 -1 "_" 50
	@cmd	jumptobranch "mapb" 1
	frame	none #8

	sound	data/sounds/beep.wav
	frame	none #9
	@cmd	settextobj 0 420 260 2 -1 "MAKE_A_CHOICE:"
	@cmd	settextobj 1 700 150 0 -1 "BACK TO MAP"
	@cmd	settextobj 2 160 150 0 -1 "RESET ALL PROGRESS"
	@cmd	settextobj 4 460 180 1 -1 "CANCEL"
	frame	none #10
	@cmd	updateframe getlocalvar("self") 10
	frame	none #11

	sound	data/sounds/beep.wav
	frame	none #12
	@cmd	settextobj 0 400 220 1 -1 "_" 50
	@cmd	settextobj 1 400 220 1 -1 "_" 50
	@cmd	settextobj 2 400 220 1 -1 "_" 50
	@cmd	settextobj 4 400 220 1 -1 "_" 50
	@cmd	changeentityproperty getlocalvar("self") "type" openborconstant("TYPE_ENEMY")
	@cmd	performattack getlocalvar("self") openborconstant("ANI_FOLLOW8")
	frame	none #13
Is the a simple variable to change ? OR do i have to switch anim, spawn its copy into stall animation and destroy original ? THen it becomes active when stall anim ends
WEll i cant spawn anthing when game is still paused, i can spawn after text entity is killed so im stuck.
 
There is an openborvariatn (in fact, two) which is related to pause
"pause", - detects if the game is paused
"game_paused", detects if the game is paused

I don't know what is the difference between both, but try to set it off.
You can acquire the value first just to check if it returns a boolean value or an int value and then reset it.
 
@cmd changeopenborvariant "pause" 1 or @cmd changeopenborvariant "pause" 0 are crashing the engine, and the orher one is no use, i knwo that game is paused, i need to change the pause...
Ah.. so whats other way to do it? I need to have mother entity or something and kill its child that spawns menu? Then after some time mother entity spawns the child again ?
I didnt know that text entity is so hard to modify
 
bWWd said:
@cmd changeopenborvariant "pause" 1 or @cmd changeopenborvariant "pause" 0 are crashing the engine, and the orher one is no use, i knwo that game is paused, i need to change the pause...
Ah.. so whats other way to do it? I need to have mother entity or something and kill its child that spawns menu? Then after some time mother entity spawns the child again ?
I didnt know that text entity is so hard to modify

Pause isn't open to write, only read. It's a simple oversight and an easy fix in next update, but until you'll need to use some tricks to pause the action. Can't say which one is best, the two main ones are boosting the think time or putting a freeze on all entities, and there is also the text entity method.

DC
 
YEah thats what i suspected i have to use ugly workaround which works, i just used parent entity to make menu reappear if globalvar "nomen" is 1 after menu entity  killeditself and changed globalvar "nomen" to 1 to release pause.
Not a big deal but i was hoping for prettier and more compact code. ;D
Code:
nim	follow7
	loop	0
	delay	5
	offset	8 14
@script
	void self = getlocalvar("self");
	int iPIndex = getentityproperty(self,"playerindex"); //Get player index
	void right = playerkeys(iPIndex, 0, "moveright");
	void left = playerkeys(iPIndex, 0, "moveleft");
		void down = playerkeys(iPIndex, 0, "movedown");
			void up = playerkeys(iPIndex, 0, "moveup");
	void pick = playerkeys(iPIndex, 0, "attack");
	int	Cframe = getentityproperty(self,"animpos");
	if(frame>=1)
	{
	//settextobj(5,20,20,3,999999999,""+Cframe);
		if(Cframe==2 && right) {updateframe(self,4);}
	if(Cframe==5 && left) {updateframe(self,1);}
	if(Cframe==2 && down) {updateframe(self,11);}
	if(Cframe==5 && down) {updateframe(self,11);}
        if(Cframe==12 && up) {updateframe(self,4);}

	if(Cframe==2 && pick) {updateframe(self,7);}
	if(Cframe==5 && pick) {updateframe(self,9);}
	if(Cframe==12 && pick) {updateframe(self,14);}
	}
	@end_script
	@cmd	changeentityproperty getlocalvar("self") "type" openborconstant("TYPE_TEXTBOX")
	@cmd	changeentityproperty getlocalvar("self") "subtype" openborconstant("SUBTYPE_NOSKIP")
	sound	data/sounds/laser2.wav
	frame	none #0
	sound	data/sounds/beep.wav
	frame	none #1
	@cmd	settextobj 0 420 260 2 -1 "MAKE_A_CHOICE:"
	@cmd	settextobj 1 680 150 0 -1 "BACK TO MAP"
	@cmd	settextobj 2 140 150 1 -1 "RESET ALL PROGRESS"
	@cmd	settextobj 4 460 180 0 -1 "CANCEL"
	frame	none #2
	@cmd	updateframe getlocalvar("self") 2
	frame	none #3
	sound	data/sounds/beep.wav
	frame	none #4
	@cmd	settextobj 0 420 260 2 -1 "MAKE_A_CHOICE:"
	@cmd	settextobj 1 680 150 1 -1 "BACK TO MAP"
	@cmd	settextobj 2 140 150 0 -1 "RESET ALL PROGRESS"
	@cmd	settextobj 4 460 180 0 -1 "CANCEL"
	frame	none #5
	@cmd	updateframe getlocalvar("self") 5
	frame	none #6
	delay	100
	sound	data/sounds/select.wav
	@cmd	settextobj 3 400 220 2 -1 "LETS_RESET_!" openborvariant("elapsed_time")+250
	@cmd	settextobj 0 400 220 1 -1 "_" 50
	@cmd	settextobj 1 400 220 1 -1 "_" 50
	@cmd	settextobj 2 400 220 1 -1 "_" 50
	frame	none #7
	@cmd	clearglobalvar()
	@cmd	jumptobranch "Nam" 1
	frame	none #8
	delay	100
	sound	data/sounds/select.wav
	@cmd	settextobj 3 400 220 2 -1 "LETS_GO_BACK_!" openborvariant("elapsed_time")+250
	@cmd	settextobj 0 400 220 1 -1 "_" 50
	@cmd	settextobj 1 400 220 1 -1 "_" 50
	@cmd	settextobj 2 400 220 1 -1 "_" 50
	frame	none #9
	@cmd	jumptobranch "mapb" 1
	frame	none #10
	delay	5
	sound	data/sounds/beep.wav
	frame	none #11
	@cmd	settextobj 0 420 260 2 -1 "MAKE_A_CHOICE:"
	@cmd	settextobj 1 680 150 0 -1 "BACK TO MAP"
	@cmd	settextobj 2 140 150 0 -1 "RESET ALL PROGRESS"
	@cmd	settextobj 4 460 180 1 -1 "CANCEL"
	frame	none #12
	@cmd	updateframe getlocalvar("self") 12
	frame	none #13
	sound	data/sounds/select.wav
	frame	none #14
	@cmd	settextobj 0 400 220 1 -1 "_" 50
	@cmd	settextobj 1 400 220 1 -1 "_" 50
	@cmd	settextobj 2 400 220 1 -1 "_" 50
	@cmd	settextobj 4 400 220 1 -1 "_" 50
	@cmd	setglobalvar("nomen", 1)
	@cmd	killentity getlocalvar("self")
	frame	none #15

Anyway.. is there any way to spawn entity with inline script ? You know with only @cmd commands? Tried but its crashing when i use @cmd void e like with normal script
 
I discovered sometimes inline @cmd script works and  @script dont when a lot of action takes place on one frame or first frame , but i dont know the structure of code thats required to spawn entity with inlin script.
Just want simple script to spawn entity without @script tags
 
There is a bug in openbor do not run any scripts on the first frame as soon as a entity is spawned or it will not work or miss behave.  Use a delay of at least 3 on the first frame then any scripts run on the second frame should be fine.

If you want to spawn a entity using @cmd use spawn01 you can find it in most mods even mine.
 
Back
Top Bottom