Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   [EZ] This script makes me insane. (https://forums.graalonline.com/forums/showthread.php?t=82078)

Vima 09-30-2008 03:33 PM

[EZ] This script makes me insane.
 
Hi! I'm making a script for the Cherry Guildhouse.
I can't get the script working, what's wrong with it?
Thanks!

// NPC made by SwedishKing -Y-
function onCreated(){
setshape(1,32,32);
}
function onWarp(){
setlevel2("cherrytown_2c.nw",30,30);
}

//#CLIENTSIDE
function onPlayertouchsme()
{
if (player.guild == "Cherry")
{
triggerAction(this.x+.5,this.y+.5,"warp",null);
}
else
{
this.chat = "Only Cherry Members!";
}
}

Vulcan 09-30-2008 03:55 PM

You don't need to use a trigger for this. You can set the chat and check the guild all on the serverside.

Luigi203 09-30-2008 04:16 PM

Vulcan was right, but triggers are recieved by 'function onAction<name>, so your function would be onactionwarp. That should fix it

Vima 09-30-2008 05:51 PM

Ahh Thanks! I'm kind of new with GS2 so yeah :P

cbk1994 09-30-2008 11:10 PM

I don't know if your styling was destroyed by posting it, but try to indent, and use [PHP] tags when posting code.

Besides that, you can just remove the //#CLIENTSIDE and add onWarp() to when the player touches the object.

Raeiphon 11-09-2008 11:09 PM

I wish GS2 required proper indentation to work, similar to Python or Lua

Makes life a whole lot easier when developing proper scripting habits

Loriel 11-09-2008 11:32 PM

Quote:

Originally Posted by Raeiphon (Post 1440756)
I wish GS2 required proper indentation to work, similar to Python or Lua

lua does not require indentation to work. It does not even require semicolons.

Quote:

Makes life a whole lot easier when developing proper scripting habits
Those languages are designed to be actually used for more than teaching.

cbk1994 11-10-2008 04:35 AM

Quote:

Originally Posted by Raeiphon (Post 1440756)
I wish GS2 required proper indentation to work, similar to Python or Lua

Makes life a whole lot easier when developing proper scripting habits

People have different tastes in what looks good in scripts, though probably 90[percent] of GS2 scripters agree on how they do it.

DustyPorViva 11-10-2008 04:39 AM

Quote:

Originally Posted by Raeiphon (Post 1440756)
I wish GS2 required proper indentation to work, similar to Python or Lua

Makes life a whole lot easier when developing proper scripting habits

The indentation is fine(I'm assuming), it just wasn't closed in php tags so it lost it.

Either way, I usually find the actual indentation of scripts fine, it's usually the placement of brackets and the use of whitespace that differs between scripters. Either way, there is no reason to discriminate those who prefer to indent different. What about those who prefer tabbing instead of the typical two-space of Graal?

This script seems to have two different forms of styling going on, though.

WaDaFack 12-05-2008 02:17 AM

Wait, dosn't setlevel2 not work on Gs2?

Tigairius 12-05-2008 02:28 AM

Quote:

Originally Posted by WaDaFack (Post 1446847)
Wait, dosn't setlevel2 not work on Gs2?

It works.

ApothiX 12-07-2008 01:21 AM

View>Source reveals that the script is formatted (albeit badly), but good ol' HTML ignores whitespace.

PHP Code:

// NPC made by SwedishKing -Y-<br />
function onCreated(){<br />
 
setshape(1,32,32);<br />
}<
br />
function 
onWarp(){<br />
 
setlevel2(&quot;cherrytown_2c.nw&quot;,30,30);<br />
}<
br />
<
br />
//#CLIENTSIDE<br />
function onPlayertouchsme()<br />
  {<
br />
  if (
player.guild == &quot;Cherry&quot;)<br />
    {<
br />
    
triggerAction(this.x+.5,this.y+.5,&quot;warp&quot;,null);<br />
  }<
br />
  else<
br />
    {<
br />
    
this.chat = &quot;Only Cherry Members!&quot;;<br />
  }<
br />




All times are GMT +2. The time now is 07:22 AM.

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