Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-14-2002, 11:25 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
New Scripters: Read!

If you're new to scripting, there is one major thing you need to keep in mind. It is better to use variables instead of definitive values. Let me explain:
NPC Code:

if (timeout)
{ if (keydown(0) && strequals(#s(client.string),1))
{ setstring client.string,2;}
if (keydown(0) && strequals(#s(client.string),2))
{ setstring client.string,3;}
if (keydown(0) && strequals(#s(client.string),3))
{ setstring client.string,4;}
if (keydown(0) && strequals(#s(client.string),4))
{ setstring client.string,1;}
timeout=0.1;
}


take THAT where you are setting it to a certain value, which makes editing a SUPER BISH or this:
NPC Code:

if (timeout)
{ if (keydown(0)
{ setstring client.string,#v(#s(client.string)+1);}
if (strtofloat(#s(client.string))=>5)
{ setstring client.string,1;}
timeout=0.1;
}


that makes it so that you have a LOT less coding, and can change things. I put that if the tsring is equal to OR GREAT THAN for a reason. If by some MISHAP or something you end up with 6 or something, then it wouldn't work. I try and build in 'extra protection' so incase something crazy happens and you have a glitch, it still works And when you're doing things, and the same actions will be repeated by more than one event, I find it best to use functions. If you need help with strings and/or this.vars read www.projectshifter.com more coming soon
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #2  
Old 09-14-2002, 11:37 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
I really hate that format/style.

I knew that, but thanks anyway.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #3  
Old 09-14-2002, 11:47 AM
Graal2001_NAT Graal2001_NAT is offline
Registered User
Join Date: Sep 2002
Posts: 241
Graal2001_NAT is on a distinguished road
if you wanted to be a nut about shortening, you could just do
test = (strtofloat(#s(client.string))+1)%6;
setstring client.string,#v(test);
__________________
GONE, BAI
Reply With Quote
  #4  
Old 09-14-2002, 12:58 PM
R0b1n-NPC R0b1n-NPC is offline
Registered User
Join Date: Sep 2002
Posts: 397
R0b1n-NPC is on a distinguished road
eheheheh
__________________
- R0bin
Reply With Quote
  #5  
Old 09-14-2002, 03:06 PM
WanDaMan WanDaMan is offline
Master Tux
WanDaMan's Avatar
Join Date: Aug 2002
Location: England, United Kingdom
Posts: 5,571
WanDaMan is a jewel in the roughWanDaMan is a jewel in the rough
Send a message via MSN to WanDaMan
Quote:
Originally posted by R0b1n-NPC
eheheheh
<3 sig!
__________________
V$:CONFL16T
Reply With Quote
  #6  
Old 09-14-2002, 09:21 PM
Graal2001_NAT Graal2001_NAT is offline
Registered User
Join Date: Sep 2002
Posts: 241
Graal2001_NAT is on a distinguished road
Quote:
Originally posted by Kaimetsu


But of course that'd only be shorter, and not necessarily more efficient or readable.
i myself consider whatever is shorter, more efficent, as long is there isnt any noticable processing time, which I don't think there is =x
__________________
GONE, BAI
Reply With Quote
  #7  
Old 09-14-2002, 10:59 PM
gokux33 gokux33 is offline
Registered User
gokux33's Avatar
Join Date: Jul 2002
Location: Florida
Posts: 785
gokux33 is on a distinguished road
Send a message via ICQ to gokux33 Send a message via AIM to gokux33 Send a message via Yahoo to gokux33
Quote:
Originally posted by Kaimetsu


Efficiency and shortness of code are completely different things. Shortness does not imply efficiency. And yeah, the different might not add up to much, but the readability factor is important too.
Unless you don't want people stealing things from your scripts.
__________________

Name: Wind Seablaze
E-Mail: [email protected]
10/4/02 My last day on the forums. Don't forget me. <3
Reply With Quote
  #8  
Old 09-15-2002, 04:05 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Quote:
Originally posted by Kaimetsu


Well, the solution there is to just code things too complicated for stupid people to understand, even with readable code.

Well if they understood it then they could make it themselves and that really isn't stealing is it? hmm.... Well I suppose stealing an idea for a script is possible. but I wouldnt' care as long as they were capable of doing it all on thier own.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #9  
Old 09-15-2002, 05:44 AM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
test = strtofloat(#s(client.string))+1;
if(test>=6) test=0;
setstring client.string,#v(test);

there, compromise.
Modules in this case do unnessisary math.
__________________

subliminal message: 1+1=3
Reply With Quote
  #10  
Old 09-16-2002, 11:32 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
Heh, I get confused by my own script 90% of the time, LMAO. Like my new class selection script for my PW. It spins and you can only see one at a time, fades, all leet cool uber stuff :P Keydown, all the greats in it But I just TOTALLY got confused after sleeping... if I don't do a script 90% or more in one sitting, I usually never finish it, lmao
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:31 AM.


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