Aller au contenu

Photo

New @ scripting & failing hard.


  • Veuillez vous connecter pour répondre
15 réponses à ce sujet

#1
Amberwall

Amberwall
  • Members
  • 4 messages
I am trying to set up an NPC  to give an item called Kebur's Key (Tag: keburskey, ResRef: item) to the PC interacting with it to further a quest.  I have no prior scripting experience.  Despite staring at multiple script referrences for the last two days it still looks like gibberish and so far I'm stuck here:

1   void main ()
2   {
3   object oTakeFrom;
4   object oItem;
5   oTakeFrom = GetLastSpeaker();
6   oItem = keburskey;
7  ActionTakeItem(oItem, oTakeFrom);
8  }

I am still recieving this error message:
4/24/2011 4:06:23 AM: Error. 'skolakey001' did not compile.
skolakey001.nss(6): ERROR: VARIABLE DEFINED WITHOUT TYPE

Any help would be appreciated.

#2
Clyordes

Clyordes
  • Members
  • 300 messages
I'm sure one of the uber scripters will jump in soon & help, but in the mean time, I'm a really rubbish scripter, so tend to use Lilac Soul's script creator instead - there's not much I've not been able to do with it - so if you haven't tried it already, I'd definitely recommend it - http://nwvault.ign.c...r.detail&id=625

#3
Amberwall

Amberwall
  • Members
  • 4 messages
Thanks I haven't seen this before will give it a try.

#4
Amberwall

Amberwall
  • Members
  • 4 messages
I can't find a way to change the ResRef on the key and "item" seems like it would become a problem as more are created. How do I change this?

#5
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Amberwall wrote...

I can't find a way to change the ResRef on the key and "item" seems like it would become a problem as more are created. How do I change this?


Right click on the blueprint in the list, select "Copy Blueprint" ---> "Module" - that will create a new copy of the blueprint where you can change all it's properties including its ResRef.

Also, I highly suggest my scripting tutorial, it is written for the beginning scripter. Link is in my sig below.

If you still need help with your script, we will be happy to do that. Let us know.

Modifié par _Knightmare_, 24 avril 2011 - 12:25 .


#6
Shaughn78

Shaughn78
  • Members
  • 637 messages
If this is being done in a conversation use one of these two global scripts: ga_destroy_item or ga_take_item.

The issue you are running into is line #6, you are not properly identifing oItem. There are several ways of doing this if you want to write your own script.
oItem = GetItemPossessedBy(oTakeFrom,"keburskey"); if you are using companions you will need to loop through all factions members checking for the key.

I would suggest opening the above mentioned scripts to see how the game handles these situation and their include script NW_I0_PLOT. Reading the tutorials and reading through scripts is going to be your best bet. Hope this helped and good luck.

#7
Amberwall

Amberwall
  • Members
  • 4 messages
Lilac's Scriptor is working wonderfully. I believe I spent a couple hours going through your Intro to Scripting Knightmare, my mind is just failing to turn it over right now. Will review it again and see if practice helps me understand theory.
Again, thanks, both of you.

#8
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
In addition to KM's tutorial, I found NWN2Scripting.com to be helpful. If the website is down, you can download the pages from the vault as well.

#9
Clyordes

Clyordes
  • Members
  • 300 messages
Nice one Amberwall! Glad I could help for once instead of being helped by the elders around here :-)
How's the rest of your project coming along?

#10
The Fred

The Fred
  • Members
  • 2 516 messages
If you spend about 5 years just looking at the scripts, you suddenly understand everything. It's amazing! ;-)

#11
Morbane

Morbane
  • Members
  • 1 883 messages

The Fred wrote...

If you spend about 5 years just looking at the scripts, you suddenly understand everything. It's amazing! ;-)


Lilac Soul's is a great way to learn basic scripting - after using it enough times you will begin to see patterns to the code.

Happy Building!

#12
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Morbane wrote...

The Fred wrote...

If you spend about 5 years just looking at the scripts, you suddenly understand everything. It's amazing! ;-)


Lilac Soul's is a great way to learn basic scripting - after using it enough times you will begin to see patterns to the code.

Happy Building!


Agreed, that was my main "teacher" while learning to script.

#13
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages

The Fred wrote...

If you spend about 5 years just looking at the scripts, you suddenly understand everything. It's amazing! ;-)


Darn. That hasn't worked for me. I must be slow.

I cannot believe that the original NWN and NWN2 develop teams did not have standard scripting guidelines that they followed. If they had just released those it would make things a whole lot easier.  As it is, I think everyone does a lot of guessing and testing.  I know I still do.

#14
The Fred

The Fred
  • Members
  • 2 516 messages
Well, I must have been doing this for quite a worrying lot of years now... that's kinda scary. I didn't use Lilac's, though, I don't trust computers to program themselves. Mostly it was just staring at existing scripts and gradually picking up the syntax (and I don't remember how it happened - I remember not understanding ANYTHING about scripting, and my first failed script*, but not the time between then and now).

*Incidentally, it may cheer up anyone learning to script to know that this was my first attempt:
void main()
{
    ActionCastFakeSpellActionAttack
}

Unsurprisingly, that didn't work.

Modifié par The Fred, 26 avril 2011 - 10:42 .


#15
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
The problem is that experience is not the best teacher. Experience only teaches what works within a context. What we need is context-independent scripting advice and only the vendors could have provided that. Since they haven't what we have is people who have experience only within specific context and no broad guidelines. A script generator, no matter how cleverly written, is no substitute for documented standards. The only official documentation I have seen are the NWN and NWN2 Scripting guides published by Brady Games and they were very basic.

#16
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages

Kaldor Silverwand wrote...

The problem is that experience is not the best teacher. Experience only teaches what works within a context. What we need is context-independent scripting advice and only the vendors could have provided that. Since they haven't what we have is people who have experience only within specific context and no broad guidelines. A script generator, no matter how cleverly written, is no substitute for documented standards. The only official documentation I have seen are the NWN and NWN2 Scripting guides published by Brady Games and they were very basic.


Hmm, i don't really buy that. Best way to learn a language is to speak it, and programming is actually a language.

The longer people script, the more their methods start to look the same. When i hear other experienced giving advice, well most often it's exactly what i would say. If there is a consensus like this, i suspect there is some truth involved. The longer you do nwscript, the more you learn, the more you oops, and eventually you start realizing some things work and some don't. I have my own preferences as to the correct way to do things, and while those are my personal preferences i have noticed they are shared by quite a few others. This makes me think there is a correct way to do things, but i do not presume to be doing that myself yet.

I also don't see the "official" rubber stamp as valuable. That is a myth, the "source" is seen as the arbiter of value instead of the actual quality involved. This game does not have the best reputation with regards to quality from the get go. We have folks in our community who can program circles around the developers, and in fact the developers often went to them seeking help - note that some of the major bugs the devs tried to fix in patch after patch were patched in via xp_bugfix and the client extender. Just compare kaedrins classes to the official ones and despite him being not able to add things to the engine his results are a lot more polished. He even fixed quite a few of the developer bugs like the spirit shaman/sorceror double spell book. I really wished they hired him to do the next expansion, it would have been sweet. If you look at the official code, well i would never ever recommend that as how you should program -- the number of bugs and issues which were not fixed until rpgplayer1, TonyK and skywing rewrote quite a few things. I personally have been forced to completely remove ANY reference to official code to side step major issues in the official libraries.

I would suggest instead looking for those who make quality bug free code, and those who are do programming for a living, and use them as a resource. I would ask for advice from more learned programmers, especially those who speak from experience. The fact is the problems a new scripter is going to encounter, are basically the same things now as it was when i started. Some who listen can short circuit that learning curve, but if they really want to do it all themselves, so be it. I am pretty sure after you've spent as many hours coding as i have, your opinions on what is correct and incorrect will for the most part be similar to mine. I would actually look for the ones whose experience dates back to the beginning of NWN1, who are even wiser than me after many more hours.

I would also of course say you need to communicate with your peers who are just a little better than you, who are still struggling. We are not just individuals, we are a community here and that cannot be forgotten. We all need to help each other, both here in the forums, but also by sharing code and making sure what we write is well documented and easy for both new and old scripters to understand, and communicating issues we find in others code to improve the game for all the players.