Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Need help with tile editor npc... (https://forums.graalonline.com/forums/showthread.php?t=56448)

greenarrow 12-17-2004 02:15 AM

Need help with tile editor npc...
 
Since nobody else will help me I decided to consult the NPC Scripting board, please help me with this script...

NPC Code:

// NPC made by Samurai X
if (created) {
}
if (playerenters) {
hide;
}
if (compusdied) {
show;
}
if (playertouchsme) {
toweapons Terrain Alterator;
say2 Use this to save yourself!;
}
if(weaponfired && !this.on == 1){
initialise();
timeout = 0.1;
}

if(timeout){
freezeplayer 1;
setani idle,;
if(keydown(1) && (this.tileX - this.tileIncrease) >= 0) this.tileX -= this.tileIncrease;
else if(keydown(3) && (this.tileX + this.tileIncrease) <= (2048-this.setX)) this.tileX += this.tileIncrease;
else if(keydown(0) && (this.tileY - this.tileIncrease) >= 0) this.tileY -= this.tileIncrease;
else if(keydown(2) && (this.tileY + this.tileIncrease) <= (512-this.setY)) this.tileY += this.tileIncrease;
showtiles();
// setplayerprop #c,#v(this.getx),#v(this.gety)|#v(this.putx),#v(th is.puty);
timeout = 0.1;
}

if(leftmousebutton && this.on == 1){
if(mousescreenx in |this.screenx,this.screenx+this.setX|
&& mousescreeny in |this.screeny,this.screeny+this.setY|){
this.getx = int( int(mousescreenx) / 16) + int(this.tileX / this.tileIncrease);
this.gety = int( int(mousescreeny) / 16) + int(this.tileY / this.tileIncrease);
}else {

this.placex = int(mousex);
this.placey = int(mousey);

this.putx = int(this.getx % 16);
this.puty = (32 * int(this.getx / 16)) + this.gety;

this.newtile = this.putx + this.puty * 16;

tiles[this.placex,this.placey] = this.newtile;
updateboard this.placex,this.placey,16,16;

a = aindexof(this.placex,this.chBoard);
b = aindexof(this.placey,this.chBoard);
if(!b == a + 1){
this.change += 2;
setarray this.chBoard,this.change;
this.chBoard[this.change-2] = this.placex;
this.chBoard[this.change-1] = this.placey;
}

}
}

if(playerchats && strequals(#c,/reset)){
// reset board to original tiles
for(p = 0; p < arraylen(this.chBoard); p += 2;){
tiles[this.chBoard[p],this.chBoard[p+1]] = this.boardOrigin[this.chBoard[p]+this.chBoard[p+1]*64];
updateboard this.chBoard[p],this.chBoard[p+1],16,16;
}
setarray this.chBoard,0;
}


// --FUNCTIONS--

function initialise(){ // main
this.on = 1;
setarray this.boardOrigin,64 * 64; // old board vars
for(iy = 0; iy < 64; iy ++)
for(ix = 0; ix < 64; ix ++)
this.boardOrigin[ix+iy*64] = tiles[ix,iy]; // for resetting
this.blockWidth = 8; // the amount of tiles to show from left to right
this.blockHeight = 10; // the amount of tiles to show from top to bottom
this.tileIncrease = 16; // increase by 16 pixels
this.screenx = 1;
this.screeny = 1;
}

function showtiles(){
this.setX = this.blockWidth * this.tileIncrease;
this.setY = this.blockHeight * this.tileIncrease;
showimg 200,pics1.png,this.screenx,this.screeny;
changeimgpart 200,this.tileX,this.tileY,this.setX,this.setY;
changeimgvis 200,10;
}



I need to know, once I fire the weapon I can edit tiles and everything but I cant figure out how to turn it off and go back to playing, can you people read the script and tell me how, or add to the script to make it work and tell me how to work it?

Slash-P2P 12-17-2004 02:34 AM

Quote:

Originally Posted by greenarrow
Since nobody else will help me I decided to consult the NPC Scripting board, please help me with this script...
I need to know, once I fire the weapon I can edit tiles and everything but I cant figure out how to turn it off and go back to playing, can you people read the script and tell me how, or add to the script to make it work and tell me how to work it?

As of now, it looks like theres no way to turn it off besides reconnecting. Also, you shouldn't post full scripts.

Kaimetsu 12-17-2004 02:41 AM

Quote:

Originally Posted by Slash-P2P
Also, you shouldn't post full scripts.

You're right, but possibly for the wrong reasons. There is a certain degree of confusion over some of the rules, you see. Posting complete scripts is only forbidden when they are being given as prepackaged solutions to a person's problem. The forum exists with the objective of helping scripters to help themselves, after all.

However, 'greenarrow' did make an error of judgement, in that he posted the whole thing instead of isolating the part that was giving him problems. It could be that this is what you were talking about, but I wanted to cover both possibilities just in case.

zokemon 12-17-2004 02:51 AM

Use code or php tags.

greenarrow 12-17-2004 03:03 AM

uh
 
Now can you 3 try ANSWERING the question?

Kaimetsu 12-17-2004 03:09 AM

Personally, I ain't gonna help you until you conform to KSI-GS and put the script in a legible, non-bloated form.

greenarrow 12-17-2004 03:16 AM

omg
 
Omg, how can I tell you what part of the code is bothering me IF I DONT KNOW WHICH PART IS THE PROBLEM, i dont know what button to press to turn the npc off, all i asked is for someone to tell me which button does it

Kaimetsu 12-17-2004 03:21 AM

So you didn't even write this code? You're just asking us how it works? Why don't you ask the author?

Lance 12-17-2004 04:55 AM

The code does not seem to provide a method to turn it off.

That said, the code is horrible, by the way, and its author would do well to read KSI-GS.

Slash-P2P 12-17-2004 06:20 AM

NPC Code:
if(weaponfired && !this.on == 1){
initialise();
timeout = 0.1;
}


That is the on/off function, but its only scripted to go on.
You can use an algorithim for making a 1 and 0 toggle for the this.on variable with something such as:
this.on = abs(this.on-1);
Plug that in there. Make sure initialise() only happens if this.on is '1'. If this.on is '0', make an end function such as end() that unsets everything that happening (one thing in that function could be hideimg 200)

Lance 12-17-2004 07:14 AM

Quote:

Originally Posted by Slash-P2P
NPC Code:
this.on = abs(this.on-1);


That's unnecessarily complicated - try this:

NPC Code:
this.on = 1 - this.on;


Skyld 12-17-2004 01:45 PM

NPC Code:
if (created) {
}


Eep.

calum 12-17-2004 03:11 PM

After looking at your script I want to vomit profusely! Ever heard of KSI-GS?

zokemon 12-17-2004 08:56 PM

Quote:

Originally Posted by Skyld
NPC Code:
if (created) {
}


Eep.

The whole script is an "Eep."

protagonist 12-17-2004 11:07 PM

The code, gents, is like me. I don't turn off.

Gman4pwnu 12-22-2004 12:03 AM

I made one if anyone wants it pm me, ill see if i can find it.

DarkShadows_Legend 12-28-2004 05:03 AM

I made that earlier this year and posted it on graal.net. I don't use the name Samurai X, either. Only Criminal X and PrinceDark.
http://graal.net/snippet/detail.php?type=snippet&id=25

I am very messy too when scripting, sorry.

Oh yeah, stealing scripts and putting your name on it is .... bad. :\


All times are GMT +2. The time now is 01:20 AM.

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