Jump to content

Photo

Layer-Switch Script

script layers layer help

  • Please log in to reply
19 replies to this topic

#1 linkinsphere

linkinsphere

    Junior

  • Members
  • Location:US

Posted 18 September 2016 - 01:35 PM

So still working on my quest and I'm working on desert winds atm. The winds DO push Link and he stops getting pushed if there's a solid tile in his velocity. The problem is though, although he is being pushed, the layers never show up. Here's two scripts working together:

// West winds
void west()
{	
	Screen->DrawLayer(6,5,84,6,160,160,0,0);
	while (true)
	{
		if (Screen->isSolid(Link->X-8,Link->Y+8) || (Screen->isSolid(Link->X-8,Link->Y-8)))
		{
			Waitframe();
			Link->X -= 0;
		}
		else
		{
			Waitframes(pushDist);
			Link->X -= pushDist;
		}
	}
}
// Calls one of the directional winds randomly every 10 seconds	

const int rotInterval = 10; //'x' seconds	

ffc script RotateDWind
{	
	void run()
	{
		while (true)
		{
			int dir = Rand(0,3);
	
			if (dir == 0) { west(); }
			else if (dir == 1) { east(); }
			else if (dir == 2) { north(); }
			else { south(); }
			Waitframes(30*rotInterval);
		}
	}
}

The issue is that the layer isn't showing up. Did I mess up the arguements? It's supposed to show the 6th layer on screen 84 of map 5.



#2 Saffith

Saffith

    IPv7 user

  • Members

Posted 18 September 2016 - 02:52 PM

It only draws for one frame. It needs to be inside the loop.

#3 linkinsphere

linkinsphere

    Junior

  • Members
  • Location:US

Posted 18 September 2016 - 04:24 PM

It only draws for one frame. It needs to be inside the loop.

Oh okay, so the 'x' and 'y' arguments will be an incremental value?



#4 Saffith

Saffith

    IPv7 user

  • Members

Posted 19 September 2016 - 11:08 AM

Not quite sure what you mean, but you shouldn't need to make any changes to the arguments.

#5 linkinsphere

linkinsphere

    Junior

  • Members
  • Location:US

Posted 19 September 2016 - 01:05 PM

Not quite sure what you mean, but you shouldn't need to make any changes to the arguments.

By that, I mean like for every position on the screen. Do they all need to be accounted for? Also, the same problem persists. The layers never showed up, but the script WAS active; Link was getting pushed.



#6 Saffith

Saffith

    IPv7 user

  • Members

Posted 19 September 2016 - 01:20 PM

No, one call covers the whole screen.

I didn't really look at the arguments before, though. You've got 0 for the opacity argument (the last one). I'm not sure what that'll do; it should be OP_OPAQUE or OP_TRANS. Also, do you have the right screen? Screen numbers in ZQuest are presented in hexadecimal, so screen 84 is screen 54 in ZQuest. If you meant 84, write it as 0x84.

#7 linkinsphere

linkinsphere

    Junior

  • Members
  • Location:US

Posted 19 September 2016 - 01:38 PM

No, one call covers the whole screen.

I didn't really look at the arguments before, though. You've got 0 for the opacity argument (the last one). I'm not sure what that'll do; it should be OP_OPAQUE or OP_TRANS. Also, do you have the right screen? Screen numbers in ZQuest are presented in hexadecimal, so screen 84 is screen 54 in ZQuest. If you meant 84, write it as 0x84.

Ahh... Thanks for clearing that up!


Ahh... Thanks for clearing that up!

Okay, so the layer(s) still isn't showing up. Any clue why? I may have messed up one the parameters:

 

 

Screen->DrawLayer(6,5,0x54,6,0,0,0,OP_TRANS); // 6th layer, 5th map, Screen 84


Edited by linkinsphere, 19 September 2016 - 01:38 PM.


#8 linkinsphere

linkinsphere

    Junior

  • Members
  • Location:US

Posted 19 September 2016 - 03:40 PM

Bump (Sorry, I just REALLY want to get this script out of the way...) :whistle:



#9 Saffith

Saffith

    IPv7 user

  • Members

Posted 19 September 2016 - 03:55 PM

... I'm still not sure if you were going for 84 or 54. Whichever it is, use the same number as in ZQuest, preceded by 0x.

#10 linkinsphere

linkinsphere

    Junior

  • Members
  • Location:US

Posted 19 September 2016 - 04:03 PM

... I'm still not sure if you were going for 84 or 54. Whichever it is, use the same number as in ZQuest, preceded by 0x.

84 as Hexadecimal = 0x54, right? So I switched the screen number to '0x54' (Screen 84). 

The layer is on map 5, screen 84. The layers still fail to show up :(



#11 Saffith

Saffith

    IPv7 user

  • Members

Posted 19 September 2016 - 04:09 PM

Changing 84 to 0x54 does nothing because they're the same number. If you want screen 54, use 0x54. If you want screen 84, use 0x84.

#12 linkinsphere

linkinsphere

    Junior

  • Members
  • Location:US

Posted 19 September 2016 - 04:13 PM

Changing 84 to 0x54 does nothing because they're the same number. If you want screen 54, use 0x54. If you want screen 84, use 0x84.

Yep, I've got that. But... why don't the layers show up? Haha, this is starting to bug me a bit. Live and learn, my friend. Live and learn :)



#13 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 19 September 2016 - 04:21 PM

This is why I think screen numbers need to all be in hex or dec. some things use the decimal screen number while others use the hex number. Very confusing.

Go into the editor find the map screen you want to use then place that number in your code. So if the number is 84 then Use 0x84 in your code. ZC will show the screen number in hex while in the editor. Also note if you use the 8x8 screen dmaps then the hex number of the screen might be based off the 8x8 grid and not the 16x8 grid. At least this is what I've noticed while trying to grab screen secrets from other damp screens.

#14 Saffith

Saffith

    IPv7 user

  • Members

Posted 19 September 2016 - 04:22 PM

Could you post the current script so we can see the call in context?

#15 linkinsphere

linkinsphere

    Junior

  • Members
  • Location:US

Posted 19 September 2016 - 05:04 PM

void west()
{	
	while (true)
	{
		Screen->DrawLayer(6,5,0x84,6,0,0,0,OP_TRANS);
		if (Screen->isSolid(Link->X-8,Link->Y+8) || (Screen->isSolid(Link->X-8,Link->Y-8)))
		{
			Waitframe();
			Link->X -= 0;
		}
		else
		{
			Waitframes(pushDist);
			Link->X -= pushDist;
		}
	}
}

Caller:

const int rotInterval = 10; //'x' seconds
		
ffc script RotateDWind
{	
	void run()
	{
		while (true)
		{
			int dir = Rand(0,3);
	
			if (dir == 0) { west(); }
			else if (dir == 1) { east(); }
			else if (dir == 2) { north(); }
			else { south(); }
			Waitframes(30*rotInterval);
		}
	}
}




Also tagged with one or more of these keywords: script, layers, layer, help

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users