DOWNLOAD MODS
Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...
trira
-
Posts
12 -
Joined
-
Last visited
Content Type
Profiles
Forums
Downloads
Tutorials
Gallery
Store
Events
Posts posted by trira
-
-
Event OnTriggerEnter(ObjectReference akActionRef) Player = getPlayer() If (akActionRef == Player) ; Limit this trigger to the player only. ;Do my secret Stuff Wait(0.1) ;Give the script time... Increment = 0 Player.TranslateToRef( Point[Increment], 5000 ) GoToState("Moving") Endif EndEvent
Minor adjustment
-
Storing the points for Point's getter in an array would be more efficient; the worst case scenario would execute much faster (no comparisons required vs. maximum of eight comparisons required, or if you want to get technical: O(1) vs. O(n) ). Something like this (note: not sure about array syntax for Papyrus):Try this. Can't guarantee anything, but it might give you a jumping-off point.
Scriptname aaDSosKznarzulchand extends ObjectReference {TOP SECRET.} Import Debug Import Game Import Utility ObjectReference property Point01 Auto ObjectReference property Point02 Auto ObjectReference property Point03 Auto ObjectReference property Point04 Auto ObjectReference property Point05 Auto ObjectReference property Point06 Auto ObjectReference property Point07 Auto ObjectReference property Point08 Auto Int Increment ObjectReference property Point ObjectReference Function Get() If Increment == 1 MyRef = Point01 ElseIf Increment == 2 MyRef = Point02 ElseIf Increment == 3 MyRef = Point03 ElseIf Increment == 4 MyRef = Point04 ElseIf Increment == 5 MyRef = Point05 ElseIf Increment == 6 MyRef = Point06 ElseIf Increment == 7 MyRef = Point07 ElseIf Increment == 8 MyRef = Point08 EndIf Return MyRef EndFunction EndProperty
ObjectReference Function Get() return PointXx[Increment-1] EndFunction
You'd then have to declare an array of ObjectReferences as a property (is that possible? If it's not, you'd have to initialize the array/its elements). Also, this assumes that Increment will have a minimum value of 1 (would be better if it started at 0, since you could eliminate the subtraction (not that it'd make much of a difference)) and that Papyrus arrays use zero-based indexing. Another benefit of doing it this way: adding/removing points requires only modification of the array property. To be honest, you could completely remove the getter and just access the array directly in the OnTranslationComplete() event.Float PlayerPosX = getPlayer().GetPositionX() Float PlayerPosY = getPlayer().GetPositionY() Float PlayerPosZ = getPlayer().getPositionZ()
Wouldn't hurt to store GetPlayer() in a variable, instead of calling the function three times. Save a couple of clock cycles, could make a difference due to Papyrus' multi-threaded nature.If Increment < 9 If PlayerPosX == OBJPosX If PlayerPosY == OBJPosY If PlayerPosZ == OBJPosZ GetPlayer().TranslateToRef(Point, 5000) EndIf EndIf EndIf EndIf If Increment == 9 ;Do my other secret stuff! GoToState ("Finished") EndIf
Setting this up like this:if( Increment < 9) ; do whatever elseif( Increment == 9) ; using just an 'else' is another possibility. Based on what TK posted, I'd recommend it since there's no chance of Increment being larger than 9. ; do whatever, version 2 endif
Would be a minor improvement since only one of the two conditions is ever going to execute.
Hopefully this made sense. Kinda drunk and I make not very much sense when drunk.
-
Why would certain functions not be available in an OnUpdate event? He's getting errors because Container inherits from Form. GetItemCount() is a part of ObjectReference (first error). The compiler can't find the function he's trying to use so it's replacing the result of the call with null (second error).
If TOSInn01CourierSackScript is being attached directly to ContainerTOSInn01CourierSack, you could use self.GetItemCount() (self isn't necessary, I'm just using it to show who's making the call). You also wouldn't need the ContainerTOSInn01CourierSack property that way.
I also second WillieSea's suggestion of using the OnClose event. It was written for these types of scenario and, overall, will be more accurate and less resource-intensive than OnUpdate.
Edit: My grammars. And I accidentally some words.
-
I think SKSE's the only hope for something like that. Another way would be to use Global values and give the user a way to set them in-game (e.g. a spell/item that brings up a message box with possible choices)
-
The ini file you're talking about is only meant to override settings found in SkyrimPrefs.ini and Skyrim.ini. More info here!
-
Papyrus isn't too bad. Like WilliSea said, the most confusing about Papyrus is properties (fragments are annoying as well, but don't show up as frequently as properties). Once you get that down, it really isn't that different from other languages.
-
What you're trying to do should be possible. How far are you getting in the script? By that I mean do you see this in-game: "Debug.Notification("Updating Merchant Prices")"? If you don't, then your script isn't initializing or it's runnning into a run-time error before it reaches that statement. One thing to try would be inserting Debug.Notification() statements at certain parts of your code. See which ones show up.
Also, I don't think you can cast from Form to ObjectReference. It's a one-to-many relation (one Form can have many ObjectReferences pointing to it) so the game probably wouldn't know which reference to choose. I could be wrong though and it might be possible to cast from Form to ObjectReference. Try making an ObjectReference property that points to a specific merchant/merchant's chest and try it out with that merchant.
I hope any of this helps.
-
You're overthinking this. This should work:
Scriptname script_name extends [something] int Property ItemCountInt Auto Ingredient[] Property Imports Auto Ingredient[] Property Base Auto Event OnInit() RegisterForUpdate(0.5) Debug.Notification("Economy Control Script active") EndEvent Event OnUpdate() int i = 0 While( i < Imports.length ) If (Game.getPlayer().getItemCount( Imports[i] ) > 0) ItemCountInt = ( Game.GetPlayer().getItemCount( Imports[i] ) ) Game.getPlayer().RemoveItem(Imports[i], ItemCountInt, true) Game.getPlayer().AddItem (Base[i], ItemCountInt, true) EndIf i += 1 EndWhile EndEvent
Edit: Note that this loop assumes Imports and Base are of equal length. If you want to be safe, there's two things that could be done to avoid potential issues.
1) Compare length of both lists before executing the loop and completely avoid the loop if they're of unequal length (safest)
2) Compare length, if they're unequal, take the smaller of two and have the loop iterate that many times. (less safe)
Edit2: Grammar.
-
This looks really useful. However, I have a newbie-style question.
How would you attach this sort of event (Game.GetPlayer().AddItem(Letter, 1) to a dialogue topic in a quest object? Assuming that this is not part of an actual quest, it's just a script that runs when a player selects a certain dialogue option and it places an item such as a note in their inventory.
The "Topic Info" has a slot for Papyrus fragments that are executed either at the beginning or end of the dialogue line. You can insert that code snippet there. Defining properties in fragments is a bit more annoying than in normal scripts though. I still haven't fully figured out that part. Only got it working once.
-
I'm not really interested in bulk manipulation, rather I wanted to compile a list of items to which I could refer back to a specific item on the list in the script.
To that end, I was able to achieve that goal by building arrays.
I also understand that what I am doing is more complicated than it needs to be, but it is unfortunately necessary because of the potential for CTDs when you add scripts to ingredients.
This is the end result: it works, and it consolidates everything to one file.
scriptname aaTKSnowberryImportScript extends Quest Ingredient[] Property Imports auto Ingredient[] Property Base auto Event onInit() RegisterForUpdate(0.5) Debug.Notification("Economy Control Script active") EndEvent Int property ItemCountInt auto Event onUpdate() if game.getplayer().getItemCount(Imports[0]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[0])) game.getPlayer().removeItem(Imports[0], ItemCountInt, true) game.getPlayer().addItem(Base[0], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[1]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[1])) game.getPlayer().removeItem(Imports[1], ItemCountInt, true) game.getPlayer().addItem(Base[1], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[3]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[3])) game.getPlayer().removeItem(Imports[3], ItemCountInt, true) game.getPlayer().addItem(Base[3], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[4]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[4])) game.getPlayer().removeItem(Imports[4], ItemCountInt, true) game.getPlayer().addItem(Base[4], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[5]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[5])) game.getPlayer().removeItem(Imports[5], ItemCountInt, true) game.getPlayer().addItem(Base[5], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[6]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[1])) game.getPlayer().removeItem(Imports[6], ItemCountInt, true) game.getPlayer().addItem(Base[6], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[7]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[7])) game.getPlayer().removeItem(Imports[7], ItemCountInt, true) game.getPlayer().addItem(Base[7], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[8]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[8])) game.getPlayer().removeItem(Imports[8], ItemCountInt, true) game.getPlayer().addItem(Base[8], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[9]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[9])) game.getPlayer().removeItem(Imports[9], ItemCountInt, true) game.getPlayer().addItem(Base[9], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[10]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[10])) game.getPlayer().removeItem(Imports[10], ItemCountInt, true) game.getPlayer().addItem(Base[10], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[11]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[11])) game.getPlayer().removeItem(Imports[11], ItemCountInt, true) game.getPlayer().addItem(Base[11], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[12]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[12])) game.getPlayer().removeItem(Imports[12], ItemCountInt, true) game.getPlayer().addItem(Base[12], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[13]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[13])) game.getPlayer().removeItem(Imports[13], ItemCountInt, true) game.getPlayer().addItem(Base[13], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[14]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[14])) game.getPlayer().removeItem(Imports[14], ItemCountInt, true) game.getPlayer().addItem(Base[14], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[15]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[15])) game.getPlayer().removeItem(Imports[15], ItemCountInt, true) game.getPlayer().addItem(Base[15], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[16]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[16])) game.getPlayer().removeItem(Imports[16], ItemCountInt, true) game.getPlayer().addItem(Base[16], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[17]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[17])) game.getPlayer().removeItem(Imports[17], ItemCountInt, true) game.getPlayer().addItem(Base[17], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[18]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[18])) game.getPlayer().removeItem(Imports[18], ItemCountInt, true) game.getPlayer().addItem(Base[18], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[19]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[19])) game.getPlayer().removeItem(Imports[19], ItemCountInt, true) game.getPlayer().addItem(Base[19], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[20]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[20])) game.getPlayer().removeItem(Imports[20], ItemCountInt, true) game.getPlayer().addItem(Base[20], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[21]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[21])) game.getPlayer().removeItem(Imports[21], ItemCountInt, true) game.getPlayer().addItem(Base[21], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[22]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[22])) game.getPlayer().removeItem(Imports[22], ItemCountInt, true) game.getPlayer().addItem(Base[22], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[23]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[23])) game.getPlayer().removeItem(Imports[23], ItemCountInt, true) game.getPlayer().addItem(Base[23], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[24]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[24])) game.getPlayer().removeItem(Imports[24], ItemCountInt, true) game.getPlayer().addItem(Base[24], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[25]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[25])) game.getPlayer().removeItem(Imports[25], ItemCountInt, true) game.getPlayer().addItem(Base[25], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[26]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[26])) game.getPlayer().removeItem(Imports[26], ItemCountInt, true) game.getPlayer().addItem(Base[26], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[27]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[27])) game.getPlayer().removeItem(Imports[27], ItemCountInt, true) game.getPlayer().addItem(Base[27], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[28]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[28])) game.getPlayer().removeItem(Imports[28], ItemCountInt, true) game.getPlayer().addItem(Base[28], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[29]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[29])) game.getPlayer().removeItem(Imports[29], ItemCountInt, true) game.getPlayer().addItem(Base[29], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[30]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[30])) game.getPlayer().removeItem(Imports[30], ItemCountInt, true) game.getPlayer().addItem(Base[30], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[31]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[31])) game.getPlayer().removeItem(Imports[31], ItemCountInt, true) game.getPlayer().addItem(Base[31], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[32]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[32])) game.getPlayer().removeItem(Imports[32], ItemCountInt, true) game.getPlayer().addItem(Base[32], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[33]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[33])) game.getPlayer().removeItem(Imports[33], ItemCountInt, true) game.getPlayer().addItem(Base[33], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[34]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[34])) game.getPlayer().removeItem(Imports[34], ItemCountInt, true) game.getPlayer().addItem(Base[34], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[35]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[35])) game.getPlayer().removeItem(Imports[35], ItemCountInt, true) game.getPlayer().addItem(Base[35], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[36]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[36])) game.getPlayer().removeItem(Imports[36], ItemCountInt, true) game.getPlayer().addItem(Base[36], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[37]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[37])) game.getPlayer().removeItem(Imports[37], ItemCountInt, true) game.getPlayer().addItem(Base[37], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[38]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[38])) game.getPlayer().removeItem(Imports[38], ItemCountInt, true) game.getPlayer().addItem(Base[38], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[39]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[39])) game.getPlayer().removeItem(Imports[39], ItemCountInt, true) game.getPlayer().addItem(Base[39], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[40]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[40])) game.getPlayer().removeItem(Imports[40], ItemCountInt, true) game.getPlayer().addItem(Base[40], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[41]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[41])) game.getPlayer().removeItem(Imports[41], ItemCountInt, true) game.getPlayer().addItem(Base[41], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[42]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[42])) game.getPlayer().removeItem(Imports[42], ItemCountInt, true) game.getPlayer().addItem(Base[42], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[43]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[43])) game.getPlayer().removeItem(Imports[43], ItemCountInt, true) game.getPlayer().addItem(Base[43], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[44]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[44])) game.getPlayer().removeItem(Imports[44], ItemCountInt, true) game.getPlayer().addItem(Base[44], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[45]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[45])) game.getPlayer().removeItem(Imports[45], ItemCountInt, true) game.getPlayer().addItem(Base[45], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[46]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[46])) game.getPlayer().removeItem(Imports[46], ItemCountInt, true) game.getPlayer().addItem(Base[46], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[47]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[47])) game.getPlayer().removeItem(Imports[47], ItemCountInt, true) game.getPlayer().addItem(Base[47], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[48]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[48])) game.getPlayer().removeItem(Imports[48], ItemCountInt, true) game.getPlayer().addItem(Base[48], ItemCountInt, true) elseif game.getPlayer().getItemCount(Imports[49]) >= 1 ItemCountInt = (game.getPlayer().getItemCount(Imports[49])) game.getPlayer().removeItem(Imports[49], ItemCountInt, true) game.getPlayer().addItem(Base[49], ItemCountInt, true) endif EndEvent
Have you considered using a while loop for this? It'd make your code significantly shorter. Also, you missed the third element (index 2).
-
Its currently being attached to a container quest (as it would be under the old scripting), but I wonder if that doesn't work anymore.
Would it be possible to attach the script to the player, in that case? Since it is pretty much guaranteed for the player to be in the current active cell.
If you're attaching your script to a Quest, it needs to extend Quest. Otherwise nothing will happen.
@WillieSea: I think by container quest he means he's using a dummy quest to attach his script so he doesn't have to attach it directly to a vanilla record (compatibility reasons, I'm guessing).
Game Settings in scripts
in Papyrus 101
Posted
Nope, default Papyrus doesn't have the setters for Game Settings. You'll need SKSE for that. Not sure if it's been implemented yet.