gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfxgfx
 
Members, please note that our guidelines are located here.
 
gfx gfx
gfx
484576 Posts in 28410 Topics by 2464 Members - Latest Member: austinrobert February 28, 2020, 02:37:46 PM
*
gfx* Home | Help | Calendar | Login | Register | gfx
gfx
The Gaming Universe  |  The Archives  |  Archived Projects  |  Open Zelda  |  OZ Help (Moderator: red_team316)  |  String/Variable stills exist???
gfx
gfxgfx
 

Author Topic: String/Variable stills exist???  (Read 873 times)

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
String/Variable stills exist???
« on: January 02, 2011, 07:45:46 PM »
I'm not going to use this actual script but for some reason when I used the key word "new" the Quest designer gave me an error.
When I removed it compiled but it didn't draw the NPC.

Code: [Select]
//----------------------------------------
// Name: main()
//----------------------------------------
main()
{
if (FirstRun())
{
// Set some general parameters
SetActiveDist("this",1000);
SetActiveInGroups("this",true);
SetType("this", npcType);
AllocateStrings("this", 10, 400);   
SetSpeed( "this", 40 );
param = GetParam("this");

for(new n = 0; n < 4; n++)
CreateAnim(8, walk[n] );


if(param >= 'b' && param <= 'f')
{
head[0] = "htownxheadn";
head[1] = "htownxheade";
head[2] = "htownxheads";
head[3] = "htownxheadw";
stand[0] = "htownbbodyn";
stand[1] = "htownbbodye";
stand[2] = "htownbbodys";
stand[3] = "htownbbodyw";

for(new n; n < 4; n++)
head[n][5] = param;

AddAnimframe(walk[0], 0, 0, "htownbbodyn");
AddAnimframe(walk[0], 0, 0, "htownbbodynb");
AddAnimframe(walk[0], 0, 0, "htownbbodync");
AddAnimframe(walk[1], 0, 0, "htownbbodye");
AddAnimframe(walk[1], 0, 0, "htownbbodyeb");
AddAnimframe(walk[2], 0, 0, "htownbbodys");
AddAnimframe(walk[2], 0, 0, "htownbbodysb");
AddAnimframe(walk[2], 0, 0, "htownbbodysc");
AddAnimframe(walk[3], 0, 0, "htownbbodyw");
AddAnimframe(walk[3], 0, 0, "htownbbodywb");
}
else if((param == 'a') || (param >= 'g' && param <= 'i'))
{
for(new n; n < 4; n++)
{
new stands[2][20] = {"htownxheadx","htownxbodyx"};
new walks[2][20] = {"htownxbodyx","htownxbodyxb"};
new dirs[4][2] = {"n","e","s","w"};

stands[0][5] = param;
stands[0][10] = dirs[n][0];
stands[1][5] = param;
stands[1][10] = dirs[n][0];
walks[0][5] = param;
walks[0][10] = dirs[n][0];
walks[1][5] = param;
walks[1][10] = dirs[n][0];

head[n] = stands[0];
stand[n] = stands[1];
AddAnimframe(walk[n], 0, 0, walks[0]);
AddAnimframe(walk[n], 0, 0, walks[1]);
}
if(param == 'a')
headDist = 8;
}
else if(param == 'j')
{
                        //Everything below should of gave an error but didn't
for(n = 0; n < 4; n++)
{
stands[0] = "htownxheadx";
stands[1] = "htownxbodyx";
walks[0] = "htowngbodyx";
walks[1] = "htowngbodyxb";
stands[0][5] = param;
stands[0][10] = dirs[n][0];
stands[1][5] = param;
stands[1][10] = dirs[n][0];
walks[0][10] = dirs[n][0];
walks[1][10] = dirs[n][0];
head[n] = stands[0];
stand[n] = stands[1];
AddAnimframe(walk[n], 0, 0, walks[0]);
AddAnimframe(walk[n], 0, 0, walks[1]);
}
}
}

if(!isActive("this"))
{
ClearCollisionRect("this", 0);
return false;
}

CallFunction("l_npclib", true, "CheckForTalk", "NULL");

// Call a function for the NPC depending on its state
switch( GetState("this") )
{
case standing:
Stand(true);
case waiting:
Stand(false);
case sitting:
Sitting();
case walking:
Walk();
}
}

I'm not going to use this actual script. Most of the NPCs so far had their own body, but this lastest NPC shares the same sprites as some other NPCs. So I'll change things around to get it to work the way I want. As I create more NPCs the script will probably be changed again.

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
String/Variable stills exist???
« Reply #1 on: January 02, 2011, 08:15:57 PM »
For me it compiled with no problem. I just had to remove the switch/case thing and add this at the top:

Code: [Select]
new param
new head[4][20]
new stand[4][20]
new walk[4]
new headDist

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Re: String/Variable stills exist???
« Reply #2 on: January 02, 2011, 10:32:38 PM »
However you admit that you had to change things around for it to fix itself?

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
String/Variable stills exist???
« Reply #3 on: January 03, 2011, 04:17:28 PM »
Yes, it always gives errors if a value isn't initialized.

The Gaming Universe  |  The Archives  |  Archived Projects  |  Open Zelda  |  OZ Help (Moderator: red_team316)  |  String/Variable stills exist???
 

gfxgfx
gfx
SMF 2.0.17 | SMF © 2019, Simple Machines Page created in 0.15 seconds with 21 queries.
Helios Multi © Bloc
gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!