Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   problem w/ setmap & startswith() (https://forums.graalonline.com/forums/showthread.php?t=25596)

haunter 03-13-2002 09:46 AM

problem w/ setmap & startswith()
 
I'm having some trouble with this map code i made for a quest, i want the quest "complex" to have a map, but i don't want it to affect the main overworld map. here is what is have, the filenames are just examples

overworld.png & overworld.txt are the files for the overworld

quest.png & quest.txt are the files for the quest complex.

NPC Code:
// NPC made by Shadowless Warrior
if (playerenters) {setmap quest.png,quest.txt,playerx,playery;}
if (playerenters) {toweapons -questmap;

}
if (isweapon && startswith(#L, quest_)) {setmap quest.png,quest.txt,playerx,playery;
}
else if (isweapon) {setmap overworld.png,overworld.txt,playerx,playery;
}



When ever i try it, it sets the map to the overworld map... even when im in a level that the file name starts with "quest_". I hope someone can help.

darkriders_p2p 03-13-2002 10:05 AM

not to sure if it matters but isn't it:
NPC Code:

if (isweapon && startswith(quest_,#L)) {
setmap quest.png,quest.txt,playerx,playery;
}


happyme 03-13-2002 10:22 AM

Quote:

// NPC made by Shadowless Warrior
if (playerenters) {setmap quest.png,quest.txt,playerx,playery;}
if (playerenters) {toweapons -questmap;

}
if (isweapon && startswith(#L, quest_)) {setmap quest.png,quest.txt,playerx,playery;
}
else if (isweapon) {setmap overworld.png,overworld.txt,playerx,playery;
}
ehh... wouldnt it be simpler to put setmap quest.png,quest.txt,playerx,playery; in the quest lv and then on the first outside lv put
setmap overworld.png,overworld.txt,playerx,playery;

haunter 03-13-2002 10:25 AM

i tried
 
Quote:

Originally posted by happyme

ehh... wouldnt it be simpler to put setmap quest.png,quest.txt,playerx,playery; in the quest lv and then on the first outside lv put
setmap overworld.png,overworld.txt,playerx,playery;

i tried that, but it wouldn't work, i hadta put it in a weapon 0.o

neomaximus2k 03-13-2002 03:39 PM

Re: i tried
 
Quote:

Originally posted by haunter


i tried that, but it wouldn't work, i hadta put it in a weapon 0.o

i had that prob with tiledefs but online they worked fine

konidias 03-13-2002 05:49 PM

Re: problem w/ setmap & startswith()
 
NPC Code:

if (playerenters) {
setmap quest.png,quest.txt,playerx,playery;
toweapons -questmap;
}
if (isweapon && startswith(quest_,#L)) {
setmap quest.png,quest.txt,playerx,playery;
}else if (isweapon && !startswith(quest_,#L)) {
setmap overworld.png,overworld.txt,playerx,playery;
}



"else if (isweapon && !startswith(quest_,#L)) {"

You had it basically saying "If you have the weapon, set the map to overworld.png" that is why it kept setting to overworld.. you have to define that it only sets overworld.png when you have the weapon and the levels dont start with quest.

You could simplify this by having something like "if (isweapon)" then have an "if startswith blahblah" here and then just have an else for it instead of having an else if !startswith blahblah" but what I posted should work fine lol.

cell424 03-13-2002 07:16 PM

Here is what I did, in the system NPC of the server I made a mini system inside it. I only have 2 maps, the Mining Caves and the Overworld. SO this is what you do.

if (isweapon) {
//Map Systems
if (!startswith(quest_,#L)) {
setmap quest.png,quest.txt,playerx,playery;
}
else setmap overworld.png,overworld.txt,playerx,playery;
}

haunter 03-14-2002 03:13 AM

Re: Re: problem w/ setmap & startswith()
 
Quote:

Originally posted by konidias
NPC Code:

if (playerenters) {
setmap quest.png,quest.txt,playerx,playery;
toweapons -questmap;
}
if (isweapon && startswith(quest_,#L)) {
setmap quest.png,quest.txt,playerx,playery;
}else if (isweapon && !startswith(quest_,#L)) {
setmap overworld.png,overworld.txt,playerx,playery;
}



"else if (isweapon && !startswith(quest_,#L)) {"

You had it basically saying "If you have the weapon, set the map to overworld.png" that is why it kept setting to overworld.. you have to define that it only sets overworld.png when you have the weapon and the levels dont start with quest.

You could simplify this by having something like "if (isweapon)" then have an "if startswith blahblah" here and then just have an else for it instead of having an else if !startswith blahblah" but what I posted should work fine lol.

Thanks alot! That worked... I'm sure some of the other things the others suggested would've worked as well, thanks to them too... :)

konidias 03-14-2002 02:06 PM

I love being good enough at scripting to have things work that I never actually tested once. :)


All times are GMT +2. The time now is 05:33 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.