Jump to content

Photo

Flower Script Request


  • Please log in to reply
26 replies to this topic

#16 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 16 April 2016 - 10:48 PM

It's just... you asked for this to be global.

 

Flowers already change whenever they're struck. Normally, this is to the undercombo. To make it be anything else, the script has to know what that is. At an ffc level, we can store that via arguments. At a global level, it's a little more difficult.

 

I edited the script above because of a potential error that could occur.

 

Edit: Never mind. I thought of a way. This is theoretical, but reference the above script.

 

Sorry, I know very little about scripting and thought that ffc might be helpful for a global.



#17 ywkls

ywkls

    Master

  • Members

Posted 16 April 2016 - 10:59 PM

Doing something globally means not having to set up an ffc on every screen. But it also means having to cover anything that can possibly happen anywhere in the game.

 

And now that I'm looking at my script, I just realized that tweaking it slightly would allow you to create pots that make a sound when broken without the use of ffcs. (Which is what I'd been doing until now.) Just to goes to show how things can change over time as you learn more scripting tricks.



#18 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 16 April 2016 - 11:54 PM

I just thought of another potential complication.

int ScreenCombos[176];//Array to store combos in.
int OldScreen;//Tracks what screen you're on.

const int FLOWER_UNDER_COMBO = 0;//Set to whatever combo is used by the flowers as an undercombo.
//Note: Does not currently support multiple undercombos for flowers that look different.
//While that can be done, it is significantly more complex.

global script Active{
	void run(){
		while(true){
			UpdateFlowers();//Handles the flowers->Next stuff. 
			Waitdraw();
			if(OldScreen != Game->GetCurScreen())OldScreen= Game->GetCurScreen();//Save what screen you're on if it changes.
			Waitframe();
		}
	}
}

void UpdateFlowers(){
	int i;//Iterative variable.
        //The current screen has changed.
	if(OldScreen!=Game->GetCurScreen()){
                //Reset the array.
		for (i = 0; i < 175; i++ ){
                        ScreenCombos[i]= 0;
			if(Screen->ComboD[i]==CT_FLOWERS )ScreenCombos[i]= Screen->ComboD[i];
                }
	}
        //Keep track of all combos.
        //If they were flowers and changed, make them the right under combo.
	for (i = 0; i < 175; i++ ){
		if(ScreenCombos[i] !=0 && Screen->ComboD[i]!=CT_FLOWERS){
                       Screen->ComboD[i]= ScreenCombos[i]++;
                       ScreenCombos[i]=0;
               }
        }
}
The first version of this script wouldn't actually clear the array when the screen changed. So it would register combos from previous screens. This one should work as intended.

 

 
It compiled, and I set "const int FLOWER_UNDER_COMBO = 897;" but when I play the quest file and slash flowers I just get combo 0- even when I set the default undercombo to a non-0 number. Maybe I missed a step in setting it up?
 

Doing something globally means not having to set up an ffc on every screen. But it also means having to cover anything that can possibly happen anywhere in the game.

 
 
It sounds like a non-global is simpler. Would it perhaps be much easier if I made Flag 98 inherent to my flower combos, and Flag 98 was scripted to say that:
 

(Example 1A)
when this combo changes it becomes [next combo in the list]
 
or:
 

(Example 1B)
when this combo is slashed it becomes [next combo in the list]
 
another option would be:
 

(Example 2A)
if this is combo [insert combo number here] when it changes it becomes [insert combo number here]

if this is combo [insert combo number here] when it changes it becomes [insert combo number here]

if this is combo [insert combo number here] when it changes it becomes [insert combo number here]

 
or:

 

(Example 2B) 
if this is combo [insert combo number here] when it's slashed it becomes [insert combo number here]

if this is combo [insert combo number here] when it's slashed it becomes [insert combo number here]

if this is combo [insert combo number here] when it's slashed it becomes [insert combo number here]

 

1A and 1B would be automated to find the right undercombo, but if we went with 2A or 2B I wouldn't mind if I had to keep adding and filling out cases in the script.


Edited by Cukeman, 17 April 2016 - 01:14 AM.


#19 ywkls

ywkls

    Master

  • Members

Posted 16 April 2016 - 11:57 PM

Update the example quest and I'll see if you have it set up correctly.



#20 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 17 April 2016 - 12:16 AM

updated: https://drive.google...eDVGbE5hRm0wZ2M



#21 ywkls

ywkls

    Master

  • Members

Posted 17 April 2016 - 12:43 AM

Found the problem.

import "std.zh"
import "string.zh"
int ScreenCombos[176];//Array to store combos in.
int OldScreen = -1;//Tracks what screen you're on.

global script Active{
	void run(){
		while(true){
			UpdateFlowers();//Handles the flowers->Next stuff. 
			Waitdraw();
			if(OldScreen != Game->GetCurScreen())OldScreen= Game->GetCurScreen();//Save what screen you're on if it changes.
			Waitframe();
		}
	}
}

void UpdateFlowers(){
	int i;//Iterative variable.
        //The current screen has changed.
	if(OldScreen!=Game->GetCurScreen()){
                //Reset the array.
		for (i = 0; i < 175; i++ ){
                        ScreenCombos[i]= 0;
			if(Screen->ComboT[i]==CT_FLOWERS )ScreenCombos[i]= Screen->ComboD[i]+1;
                }
	}
        //Keep track of all combos.
        //If they were flowers and changed, make them the right under combo.
	for (i = 0; i < 175; i++ ){
		
		if(ScreenCombos[i] !=0 && Screen->ComboT[i]!=CT_FLOWERS){
                       Screen->ComboD[i]= ScreenCombos[i];
                       ScreenCombos[i]=0;
               }
        }
}

First, I had it checking for ComboD when it should have been ComboT since we're looking at combo Type.

 

Second, arrays don't like doing things like other variables apparently. Ended up storing the value of whatever combo is next in the combo list in the array, then changing the onscreen combo to that when it is hit.

 

Third- the OldScreen variable has to be initialized as negative one or it won't work on the very first screen you load.


Edited by ywkls, 17 April 2016 - 12:44 AM.


#22 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 17 April 2016 - 01:14 AM

That’s very cool, and almost perfect!
 
When I slash a flower it changes to combo 0 for a split second (just a flash) before changing to the desired undercombo. I also noticed that the desired undercombo is drawn with CSet 0 (the flower combos I placed onscreen with the mouse use CSet 2). I guess the script doesn’t identify/match the CSet of the original flower combo. The example quest file has been updated if you want to see it.


Edited by Cukeman, 17 April 2016 - 01:28 AM.


#23 ywkls

ywkls

    Master

  • Members

Posted 17 April 2016 - 01:18 AM

Matching Csets isn't too hard. It'd just require another array to store the data for that in. As for showing Combo zero for a frame, you could always set Combo zero to be blank since that's not going to be used by ffcs.



#24 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 17 April 2016 - 01:26 AM

Setting combo 0 to blank means that it will still flash whatever color combo 0 is set to (black in this case) the transparent effect doesn't work if there's no combo beneath it (tested).


Edited by Cukeman, 17 April 2016 - 01:28 AM.


#25 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 17 April 2016 - 01:33 AM

Have you tried putting UpdateFlowers() after Waitdraw()?

#26 ywkls

ywkls

    Master

  • Members

Posted 17 April 2016 - 01:34 AM

Well, it is only for a frame...

 

Try putting the UpdateFlowers() function after Waitdraw and see what happens.

 

Edit: Ninja'd.


Edited by ywkls, 17 April 2016 - 01:35 AM.


#27 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 17 April 2016 - 02:51 AM

Have you tried putting UpdateFlowers() after Waitdraw()?

 

That worked :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users