Jump to content

Looping in scripting


jonesjoshuar

Recommended Posts

I know scripting in oblivion is different than c++, but has anyone figured out how to make a while or a for loop?

 

I know in essence that on gamemode is essentially a loop. It runs every so many frames (or is it every frame?) So in sense it cane be treated as a loop. I suposed that you can use the getscript variable and setscript variable and the start and stop script commands to access and moddify it. I just wandering if there was an easier way.

 

Part of a thieving quests and mercenary quests (possibly at this stage) is that for a rather high cost you can clear your infamy and crime. I was going to script it that everytime you use it, the cost the next time grows. (it takes more money too smooth over) so say you have 20000 crim gold , you could be paying 200000 gold to make it go away. So you do and the next time you get another 20000 crimgold. You pay 300000 gold or such etc etc. There are several ways i could do this, a loop, if possible sprung to mind first.

Link to comment
Share on other sites

Looping within a single pass of a script can cause severe problems since almost nothing else gets run (other scripts/processing) until it's resolved. Since scripts run every frame, this sort of thing is also not normally needed. In the case of your mod, the solution might be as simple as making it formula based, with each successive use changing components of that formula. For instance;

 

if makeuse == 1
set usagecount to usagecount + 1
set offset to 3
set usecost to ((usagecount * 10) * (offset / 2)) * 1000
set makeuse to 0
if player.getgold < usecost
 set usagecount to usagecount - 1
 Messagebox "You do not have enough gold."
else
player.removeitem ff usecost
endif
endif

And then whenever you want to enact that effect, just change the <questname>.makeuse to 1. No looping needed, no multiple entries needed, just a formula.

Link to comment
Share on other sites

I didnt think about the waiting until it is resolved issue.

I swear sometimes knowing c++ makes scripting harder. ;) Yoda: you must unlearn what you have learned.

would offset need to be a float? I know sometimes remainers can be funning things. I know they can just be dropped off. (3/2) cold in effect = 1. rather than 1.5.

 

By the way, thanks as always Vagrant0

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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