I “borrowed” a script from Vordan’s Hero Creator to enhance weapons on a workbench. There are a couple of scripts to do this but the one I’m trying to change is the item check which makes sure the weapon is valid for crafting.
It’s fine for melee weapons but I want to make it for ranged weapons too. It’s going to put an enhancement bonus on the weapon and I checked that you can do that in the item properties ( you can ) but I can’t remember ever seeing an enhanced bow. Do they exist ? They seem to only have attack bonuses.
Anyway if you can do this ( and it works ) where do I put this ?
I put it straight under the melee weapons part but it didn’t work, put in an or, then an if and an else, but that didn’t work either. Then I copied the whole bit in the { brackets about melee weapons and stuck that below it in more brackets but that didn’t work either. I’m completely guessing here and it’s not working which isn’t very surprising ! If anybody knows how to add this so my anvil will allow bows to get an enhancement bonus then please let me know.
I wasn’t going to bother but it’s not really fair on the archers when everybody else has enhanced weapons.
Hmm, maybe this is not the correct way to do this script. I’m a bit unsure, but maybe try it? I’m sure one of the other script wizards here will tell me if it’s wrong, like they usually do:
EDIT2: Maybe my script isn’t wrong after all? I’m still not that good with while loops and starting conditionals so I have to look at other scripts and compare to see how it’s done (both stock scripts and things I’ve done myself with others’ help. Thankfully I succeed a lot more often nowadays, since I understand these things quite a bit more than four years ago).
Vordan’s script is checking not only if the item on the bench is melee/ranged, but also that there is only ONE item on the bench. Hence this line: && GetNextItemInInventory(oWorkbench) == OBJECT_INVALID)
andgalf… Thanks for the script but I think I’d have to do a double condition on the conversation with an “or” as it looks like it only checks for one type.
travus… AAAAAAHHHHH ! I wiped that bit off the script so it just did melee weapons ! I just found it !!!
Thing is that the party can only enhance four weapons the first time, then they get some magic bows and next time they can boost them but I didn’t want them enhancing bows and then getting the same sort of thing a little while later,
Shallina… Thanks for the script does this mean that || is an either or thing ?
andgalf… Thanks, I would never have guessed that !
I wrote “or” in exactly the same place. What’s the difference and why didn’t the people making the code just use or ? They’re both two characters and the word doesn’t need a shift button to be pressed !
Is the logical OR (as opposed to a single | which is bitwise OR) operator taken from the ‘C’ family of programming languages. See these 3 tutorials of mine -
Tarot_Redhand… Thanks for that, but calling || the logical or when to me or is the logical or has just fried my brain
ps I forgot to say I used Shallina’s script because I couldn’t face going back and using the Vordan one after I forgot it and chopped it up before… And it works just as it should, my archers will be happy now !
NWN script is actually something build on C++, in C++ “or” is written ||, “and” is written &&
Somme languages use “or”, “and”. It’s a syntax choice. Somme use something else.
If you want to be more proficient with NWN script check C and C++ tutorials. They share many thing, and C and C++ beginner tutorials are very well done and easy to find.
Shallina… Thanks, I always wondered what that && was, I thought one & cancelled the other making it the opposite. Does this mean that the bit wise and was & just like the or when || was | ? I might actually understand more now I know doubles don’t cancel each other and just mean one thing.
The one that I always wonder about is ! Why does that just appear, is it an isn’t or an opposite ?
eg. if (!GetIsPC(oPC)) return means get whoever did what and if it’s not the player then forget it.
In this case it means: If oPC is not a player character then don’t do anything.
So if oPC is the entering object like (object oPC= GetEnteringObject()), and it’s not a player character, the script shouldn’t run. An NPC could run through a trigger for example and the script wouldn’t run until the PC (player character) runs through it.
Here are a list of other signs used in scripts that you may wonder about (from kevL_s Basic Scripting document):
Operators (in no particular order):
= assign value
== equivalent to
!= not equivalent to
> greater than
< less than
>= greater than or equal to
<= less than or equal to
&& boolean AND
& bitwise AND (both bits true)
&= bitwise AND and assign
|| boolean OR
| bitwise OR (either bit true)
|= bitwise OR and assign
^ bitwise XOR (either bit true but not both)
^= bitwise XOR and assign
~ bitwise NOT (invert bits)
. dot-accessor
! boolean NOT
+ addition or string concatenation
++ pre or post increment
+= addition or string concatenation and assign
- subtraction
-- pre or post decrement
-= subtraction and assign
* multiplication
*= multiplication and assign
/ division
/= division and assign
% modulo
%= modulo and assign
>> bitwise shift right
>>= bitwise shift right and assign
<< bitwise shift left
<<= bitwise shift left and assign
?: ternary conditional operator
andgalf… Thank you, my suspicions were correct about the ! and I just realised I use it all the time with ints and conditions on conversations.
I think my scripting problem is that after all these years with the toolset all I’ve ever really done is worked out what I can make with what I have in front of me and I didn’t want to deviate from that. I’d rather work out ways around things to get what I want to happen. If it’s not there or possible I make the story fit.
All my scripting and actions mainly come from conversations that have scripts where I just fill in the gaps but in the module I’m making at the moment I’ve needed more scripts to do things. Still not loads but more than all my other mods.
Really I just need a computer that I tell what I want to happen and it can convert it into computer speak because I get fed up when I miss some tiny detail and everything goes wrong.
But my main priority still remains a kitchen robot that can cook etc. I’d give it lots of time off to go out with it’s robot mates, it would only need to do a couple of hours work a day and I’d be happy to play computer games with it so it wouldn’t be a slave… How about that for going off topic !
Yeah, I’ve always wished something like this too. It took me 4 whole years to get the tiny amount of scripting I’m able to do now. So with this I’ve been an extremely slow learner. My brain is not fit for coding. I’m too scatterbrained and illogical I think. I like creating stuff, like stories, characters and music but coding with all its very exact logic frustrates me. Still, now that I’ve finally learned some of the basics and can understand a bit of it, it can actually be quite fun sometimes. Especially when one can figure out problems together with people here on the vault and even (in some rare cases) help out with scripts.