Jump to content

Photo

Learning to combine scripts


  • Please log in to reply
69 replies to this topic

#16 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 15 April 2016 - 12:11 AM

If you put it in the "// Before while" space, it will run once when you start your game, and won't run again until you hit Continue or Retry/Save/reset. Only the stuff within while (true)'s braces will run continuously while you're playing the quest. As for whether to put it before or after Waitdraw()...well, for this script it doesn't really matter. It should function either way. The global script you've got there should work.

 

So "//Before while" is for stuff that happens only once per quest? Does it happen again each time you reset, but not if you save it happening?



#17 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 15 April 2016 - 12:21 AM

It happens every time you load the quest. Init, as opposed to Active, is where you want to put stuff that only happens once per quest save.
  • Cukeman likes this

#18 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 15 April 2016 - 12:28 AM

Okay, this is strange. I tried to compile the script, and I got a compiling error in a line that comes after my new content?

 

"Line 81: syntax error, unexpected script, expecting identifier, on token script

fatal error p00: can't parse input file!"

 

EDIT: Everything under line 75 is previously existing/already working content.

 

script


Edited by Cukeman, 15 April 2016 - 12:59 AM.


#19 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 15 April 2016 - 12:33 AM

Add another closing brace at line 75. I can't say that's the only error, just the first one I saw skimming through it.

Do you use Notepad++? It can match braces/brackets/parentheses and make these kinds of errors easier to spot.

Edited by Lejes, 15 April 2016 - 12:34 AM.


#20 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 15 April 2016 - 12:45 AM

Gah! I forgot to count braces in my new script before adding it!

I didn't realize an error wouldn't necessarily be in the line the compiler mentions.

 

I'm on a Mac, but a Google search popped up some Notepad++ alternatives I can check out.

 

Anyway I added a brace at line 75 and got an error at line 68:

    if(enem->Id == NPC_BIGDEATHANIM && enem->HP == 0) {

"tmp, line 68: error t29: that pointer does not have a variable ID"

 

EDIT: Changed "Id" to "ID". Compiled successfully


Edited by Cukeman, 15 April 2016 - 12:49 AM.


#21 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 15 April 2016 - 01:43 PM

Okay, today I'd like to combine these scripts:

ffc script CreateEnemy{
    void run(int enemyID, int enemyX, int enemyY){
        npc enemy = CreateNPCAt(enemyID, enemyX, enemyY);
    }
}
ffc script AbeiUndying
{
	void run()
	{
		Waitframes(4);
		npc abei = Screen->LoadNPC(1);
		while (true)
		{
			abei->HP = 32767;
			Waitframe();
		}
	}
}

I simply want to spawn an enemy with unlimited HP (I don't want to turn on all its defenses because I want it to react to being struck with the sword). So, I'll give this try:

ffc script CreateEndlessHPEnemy{
    void run(int enemyID, int enemyX, int enemyY){
        npc enemy = CreateNPCAt(enemyID, enemyX, enemyY);
		while (true)
		{
			enemy->HP = 32767;
			Waitframe();
		}
    }
}


#22 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 15 April 2016 - 02:05 PM

Yes, that'll work. Remember to make it Other type in the enemy editor so it doesn't get knocked by when hit.
  • Cukeman likes this

#23 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 15 April 2016 - 02:52 PM

Great :) ! Can D3 be mage to trigger the screen secret when the enemy is struck?


Edited by Cukeman, 15 April 2016 - 03:10 PM.


#24 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 15 April 2016 - 04:04 PM

Sure. You want the screen secret to be permanent?

#25 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 15 April 2016 - 04:26 PM

No



#26 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 15 April 2016 - 05:38 PM

ffc script CreateEndlessHPEnemy{
    void run(int enemyID, int enemyX, int enemyY, int trigger_secrets){
        npc enemy = CreateNPCAt(enemyID, enemyX, enemyY);
		enemy->HP = 32767;
		while (true)
		{
			if (enemy->HP < 32767 && trigger_secrets != 0){
				Screen->TriggerSecrets();
				Game->PlaySound(SFX_SECRET);
			}
			enemy->HP = 32767;
			Waitframe();
		}
    }
}
Set D3 to any number other than 0 to make it trigger secrets.
  • Cukeman likes this

#27 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 15 April 2016 - 06:05 PM

Cool! But Link should only be able to trigger the secret once per screen visit. Right now it triggers every time the enemy is struck.

 

EDIT: Or maybe the secret is only triggered once, but the secret SFX is playing each time the enemy is struck?


Edited by Cukeman, 15 April 2016 - 06:12 PM.


#28 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 15 April 2016 - 06:09 PM

There I fixed it (maybe).

ffc script CreateEndlessHPEnemy{
void run(int enemyID, int enemyX, int enemyY, int trigger_secrets){
npc enemy = CreateNPCAt(enemyID, enemyX, enemyY);
        enemy->HP = 32767;
        while (true)
        {
            if (enemy->HP < 32767 && trigger_secrets != 0){
                Screen->TriggerSecrets();
                Game->PlaySound(SFX_SECRET);
                trigger_secrets = 0;
            }
            enemy->HP = 32767;
            Waitframe();
        }
}
}

  • Cukeman likes this

#29 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 15 April 2016 - 06:15 PM

Perfect! :D

 

EDIT: deleted the line "Game->PlaySound(SFX_SECRET);" for use on a specific screen


Edited by Cukeman, 15 April 2016 - 06:25 PM.


#30 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 16 April 2016 - 04:59 AM

Gah! I forgot to count braces in my new script before adding it!

I didn't realize an error wouldn't necessarily be in the line the compiler mentions.

 

I'm on a Mac, but a Google search popped up some Notepad++ alternatives I can check out.

 

Anyway I added a brace at line 75 and got an error at line 68:

    if(enem->Id == NPC_BIGDEATHANIM && enem->HP == 0) {

"tmp, line 68: error t29: that pointer does not have a variable ID"

 

EDIT: Changed "Id" to "ID". Compiled successfully

 

 

For MacOSX, I suggest Coda.

 

Preprocessing, Syntax and Token errors are usually prior to the line in question, as they occur when the lexer encounters erroneous syntax. They can occasionally be on the line in question , such as floating closiing braces, brackets, and curly braces. Identifier errors, such a pointer, Function, and Variable errors, and lexical errors, on the other hand, are always on the line number specified in the error.


Edited by ZoriaRPG, 16 April 2016 - 05:07 AM.

  • Cukeman likes this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users