Jump to content

How to change item values like weight with a script?


Recommended Posts

Ah that makes sense, after changing the weight the only thing the runBatchScript does is to change the variable, but not the weight.

 

Hm, now my script looks like this

Scn ItemValueChangerScript

float WeapSilverLongswordWeight

Begin GameMode

if GetGameRestarted == 1

if (fileExists "Data\Item Value Changer.ini" == 1)
runBatchScript "Data\Item Value Changer.ini"

;Silver Longsword
SetWeight WeapSilverLongswordWeight WeapSilverLongsword

endif
endif

End

I switched both parts and in the .ini it is still "set ItemValueChangerScript.WeapSilverLongswordWeight to 2". But it still doesn't work...

Link to comment
Share on other sites

You need to use the "quest's" name in the INI file, not the name of the "script". Quest script variables can be accessed from everywhere, also inside these INI files, as the quests serve as global references, but they need to be accessed through the quest names, not the scripts'.

Link to comment
Share on other sites

It is the same with all scripts as well, you never pass variables direct to a script when doing it from outside it as it is always to the object that has the script, either a quest that Drake wrote or if it is an object script, then it is the Object or rather the reference to that object that holds the variables, not the script. One example does not hurt I guess:

 

Object Altar is placed in game and is set as a persistent Reference with the name AltarRef and it has a script call AltarSCR attached with a variable AltarIsAvaialable. If we wanna check from a quest script if the altar is available, then we must check that specific reference and the reason for it is that 1 script can be used in several references but a reference must always be unique. A Questscript can be used more than ones in different quests but a quest must be unique as well, so therefor it is the references that holds the variables, not the scripts, even if the variables are declared in them, you declare them for each reference they will be used for. Lets just do that example now:

If ( AltarRef.AltarsIsAvailable )

If you have 3 altars in game, each of them can have the same script but the values in the variables for each of them will differ. Well an Altar is not the best example to use as I think they check a Global Variable but not in this example.

 

Lets put 3 altars in game, called AltarRef0x that uses the exact same script:

If ( AltarRef01.AltarsIsAvailable )
ElseIf ( AltarRef02.AltarsIsAvailable )
ElseIf ( AltarRef03.AltarsIsAvailable )
EndIf

That variable is unique for each reference and will differ as soon as you use one of those 3 altars.

Edited by Pellape
Link to comment
Share on other sites

It works! I changed the line in my .ini-file from

"set ItemValueChangerScript.WeapSilverLongswordWeight to 2"

to

"set ItemValueChangerQuest.WeapSilverLongswordWeight to 2"

and it just works. In the future I will only reference quests/objects/spells from an .ini-file and not scripts. For my understanding: When I made my quest I noticed that you can only put one script in it. I have to reference my quest in my .ini-file because my script could be used by more than one quest (but a quest can only have one script).

 

Thank you all four your help!

 

Now I'll fill my script with every item whose weight I want to change :)

Link to comment
Share on other sites

Cool. Good luck :)

 

If you want to be able to use more scripts from one script or references rather, lets say it grows so big that it exceed the size limit, you can use the function call and call other scripts. I could make an example if you wish or when you need it. Backside with user defined functions is that they cannot hold any variables, just use what is passed to them for the moment or use variables from other references, like reference.thisvariable.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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