Jump to content

Scripting (variables) - Dialogue - Question


Korodic

Recommended Posts

Assuming the character donates a specific amount of scrap metal (say you donated 11)

then you should be rewarded 1000 karma (for testing purposes it was set this high)

 

My issue is that it doesn't work.

 

Am I declaring the value here wrong? Or does dialogue scripts just default variables to zero no matter what? (or not acknowledge it's declaration?)

 

help?

 

short numOthings
set numOthings to player.getitemcount SpareParts

if (numOthings < 10)
player.removeitem SpareParts numOthings
RewardKarma 1000
endif
if (numOthings > 10)
player.removeitem SpareParts numOthings
RewardKarma 10
endif

Link to comment
Share on other sites

Is this the whole script? Is it in a result script box on a dialog topic or something?

I have never tried declaring a variable in one of those boxes and would be surprised if it worked.

Make numothings a variable in a quest script, and then

 

set myquest.numothings to player.getitemcount spareparts

 

I also don't think you can use a variable name as a parameter of removeitem. I'm pretty sure I tried that a long time ago and it needs to be an integer.

Link to comment
Share on other sites

I also don't think you can use a variable name as a parameter of removeitem. I'm pretty sure I tried that a long time ago and it needs to be an integer.

you definitely can, got scripts that do so.

what you can't do though is stuff like removeitem ( getitemcount...etc) 10

Link to comment
Share on other sites

Assuming the character donates a specific amount of scrap metal (say you donated 11)

then you should be rewarded 1000 karma (for testing purposes it was set this high)

My issue is that it doesn't work.

well one reason for this not to work would be you conditioned it the wrong way around.

like the script is now, you give out 10 karma for MORE than 10 items and 1000 karma for LESS than 10 items.

in addition, the 1000 karma would also be awarded it player has NONE of the items (0 is LESS (your condition) than 10!)

plus, if player has exactly 10 items, _nothing_ would happen (MORE or LESS than 10 condition!!)

aaaaaand the numOthings variable never resets, so if player gives all items and tries again with 0 items, he would still get rewarded forever.

 

next: if you use two following up closed if-endif-blocks, they will BOTH be processed, no matter what the outcome of the ifs is.

if you want EITHER of them processed, use else or elseif.

 

and one more: i'm not sure if there's a limit to the karma-value, but 1000 looks pretty high for me, maybe try a lower one (don't know it that's actually necessary though)

 

and, like Quetzlsacatanango already stated, i can't see where this script is going (no begin or end), is that a result script or what is this...?

 

so anyway, apart from begin/end-questions, something like this should do what you want:

int numOthings

if player.GetItemCount SpareParts > 0                                 ; check if player has any
    set numOthings to player.GetItemCount SpareParts
    if numOthings <= 10                                                      ; up to ten items (including! 10)
         RewardKarma 10                          
    elseif numOthings > 10                                                  ; 11+ items
         RewardKarma 100
    endif
    player.removeitem SpareParts numOthings
    set numOthings to 0                                                      ; reset variable for next use!
endif

Edited by stevie70
Link to comment
Share on other sites

Don't declare variables in any kind of result script (info or quest).

If you do, they over-write the variables on the subject actor, if they happen to have a script. This will cause strange bugs in your mod.

So declaring Num0things will cause the variable at index 1 of the NPC to be overwritten when the result script runs. Do like Q said and place all your variables in a quest or object script.

Link to comment
Share on other sites

yes it is a result script. I'm new to the terminology. Sooo yeah, I'll try your code and test it.

well then if it's a result script, best do the variable declaration on the calling actor's, quest's ...whatever script, and the rest can go as your result script

Link to comment
Share on other sites

yes it is a result script. I'm new to the terminology. Sooo yeah, I'll try your code and test it.

well then if it's a result script, best do the variable declaration on the calling actor's, quest's ...whatever script, and the rest can go as your result script

The script you have given me will suffice (worked great, as intended, there really aren't bugs, as this doesn't alter outside objects). I don't know why exactly my previous script didn't function properly... Though the way the variables were handled may make all the difference.

 

thanks.

Link to comment
Share on other sites

I don't know why exactly my previous script didn't function properly... Though the way the variables were handled may make all the difference.

maan, i thought i'd explained that lengthy enough in the same post i posted the script, did you just copy that out without ever reading the rest...? :-)

Link to comment
Share on other sites

I don't know why exactly my previous script didn't function properly... Though the way the variables were handled may make all the difference.

maan, i thought i'd explained that lengthy enough in the same post i posted the script, did you just copy that out without ever reading the rest...? :-)

wellllllllllllllllllllllll I read the comments in the code, and thought it made enough sense to where I wouldn't have to read more. Sorry, I was just rushing through, as I was making progress and didn't feel like slowing down for anything :P

 

Though when I finish my product I'll gladly put you, and a few other members in the forum under a special thanks section dedicated to the many names that actually took the time to write out stuff for things like this, and even gave links or examples in simplistic terms for a confused kid such as myself. ;)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...