antstubell Posted March 22, 2020 Share Posted March 22, 2020 This is just an idea I am playing with and a small part of a larger script I will need to write. Player will place a certain type(s) of objects in a container, in my case they are fuses. Fuses have different values, for now say 20, 15, 10 and 5 these should not be prices (these will be different) but values that will be added together when player has finished placing fuses in order to reach a specific numeric value, in this case 75+.Firstly how do I assign a value of 20 to a Red Fuse, 15 to a Blue Fuse, 10 to a Black Fuse and 5 to an Old Fuse?Next how do I assure that the player only places the correct number of fuses - sometimes 3 need to be placed, sometimes only 1. This will avoid player dumping 10 fuses into a container which requires only 1 and should be the correct value or more - if less than required then messagebox "Not enough power being sent." In this case fuses placed (which can vary) will be returned to player inventory?Also a method of adding up the value of the fuses?I'm working on this myself but am unsure which approach to take.Thanks. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 22, 2020 Share Posted March 22, 2020 I would suggest if you have a small number of items dong this to hard code the values for each within the script and do a little math. Here is an example (not covering all possibilities) MiscObject Property RedFuse Auto MiscObject Property BlueFuse Auto MiscObject Property BlackFuse Auto MiscObject Property OldFuse Auto Int TotalFuseValue = 0 Int Property RequiredFuseValue Auto Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akSourceContainer == Game.GetPlayer() ; did player add the items If (akBaseItem as MiscObject) If (akBaseItem as MiscObject) == RedFuse TotalFuseValue += (20 * aiItemCount) ElseIf (akBaseItem as MiscObject) == BlueFuse TotalFuseValue += (15 * aiItemCount) ElseIf (akBaseItem as MiscObject) == BlackFuse TotalFuseValue += (10 * aiItemCount) ElseIf (akBaseItem as MiscObject) == OldFuse TotalFuseValue += (5 * aiItemCount) EndIf If TotalFuseValue < RequiredFuseValue Debug.Messagebox("Not enough power. "+TotalFuseValue+" / "+RequiredFuseValue) ElseIf TotalFuseValue > RequiredFuseValue Debug.Messagebox("Too much power"+TotalFuseValue+" / "+RequiredFuseValue) ElseIf TotalFuseVAlue == RequiredFuseValue Debug.Messagebox("Right amount of power"+TotalFuseValue+" / "+RequiredFuseValue) EndIf EndIf EndIf EndEvent You may wish to utilize states to prevent the player from spamming the container with fuses and potentially creating a stack dump. Link to comment Share on other sites More sharing options...
maxarturo Posted March 22, 2020 Share Posted March 22, 2020 (edited) One approach to this is what IsharaMeradin suggested. Another way is to separate those items in groups of values, for example: 1 Fuse A + 1 Fuse B + 1 Fuse C = 75 1 Fuse A + 2 Fuse B = 75 3 Fuse A + 1 Fuse C = 75 etc... Then your script should check for any of those potential groups of items that equals 75. * Values are fictional and they don't leave anywhere (they don't actually exists), only you know and define them. * I tried to write a more detailed explanation but i got confused, then i checked my script to refresh my brain on how i actually did something similar, and i got even more confused because my mind is right now in a state of computing other complicated mod's related things. But this is the general idea, oupss sorry... Edited March 22, 2020 by maxarturo Link to comment Share on other sites More sharing options...
antstubell Posted March 22, 2020 Author Share Posted March 22, 2020 Thanks both of you. You've given me a slightly different approach which I will explore. Link to comment Share on other sites More sharing options...
antstubell Posted March 23, 2020 Author Share Posted March 23, 2020 The approach I am currently taking is using quite a few global variables. Without posing the entire script,which I may end up doing, can you show me the reason this part, which points script to other functions, won't compile please/ Event OnActivate(ObjectReference akActionRef)If (My_GVfuseboxShowMsg.GetValue()) == (0)My_MSGfusebox1stEncounter.Show()My_GVfuseboxShowMsg.SetValue(1)EndIfIf (Game.GetPlayer().GetItemCount(My_FuseRed)) < 1 && (Game.GetPlayer().GetItemCount(My_FuseBlue) < 1) && (Game.GetPlayer().GetItemCount(My_FuseBlack) < 1) && (Game.GetPlayer().GetItemCount(My_FuseUsed) < 1) && (My_GVfuseColorSlot1.GetValue()) == 0My_MSGnoFuses.Show(); player has no fuses; if player does have fuses we continueElseint Function GetValueInt()int SlotsCurrentlyFilled = My_GVfuseSlotNum.GetValueInt()If (SlotsCurrentlyFilled.GetValue()) < (NumSlots)Int iButton = My_MENU_Fuses.Show()If (iButton == 4); removes all fusesRemoveAll()EndIfIf (iButton == 0); red fuse 20Slot1Red()EndIfIf (iButton == 1); blue fuse 15Slot1Blue()EndIfIf (iButton == 2); black fuse 10Slot1Black()EndIfIf (iButton == 3); used fuse depends on fixed value of fuseSlot1Used()EndIfEndIfEndFunctionEndEvent (42,0): no viable alternative at input 'int'(42,0): no viable alternative at input 'int'(69,0): mismatched input 'EndFunction' expecting ENDEVENT Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 23, 2020 Share Posted March 23, 2020 You have Int Function GetValueInt() and EndFunction both inside of an event. You cannot define a function inside of an event. Events and functions are basically the same thing and cannot be nested. One can call the other but cannot be defined within the other. Plus GetValueInt() is already a defined function within papyrus and it is slightly slower than using GetValue() as Int For this case, just remove those two lines and it should be good. Link to comment Share on other sites More sharing options...
antstubell Posted March 25, 2020 Author Share Posted March 25, 2020 Thank you. Sorted out the issue. Now can I ask, I read the information a long time ago and don't remember how to do it. Within a script how can I call a function from a different script. This would be very helpful and obviously save a lot of excessive scripting. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 25, 2020 Share Posted March 25, 2020 This may help: https://www.creationkit.com/index.php?title=Function_Reference#Accessing_Functions_From_Other_Scripts Link to comment Share on other sites More sharing options...
antstubell Posted March 26, 2020 Author Share Posted March 26, 2020 Thanks but it kind of doesn't address what I need to do but anyway I have worked around it. Just a quick question, how can I show a float value as a percentage. I'll post the entire script so you can see. I'm setting the fuse values at 2.5, 2.0 and 1.5 (in game player would eventually guess them as having values of 25, 20 and 15). The issue is with the math and as I said show a percentage instead of a decimal.If you think there is a better way to represent the fuse values and do the math please tell me. Script is not finished, it only checks the fuse colour/value in Slot1. ; Values Red=25 Blue=20 Black-15Float Property Slot1Value AutoFloat Property Slot2Value AutoFloat Property Slot3Value AutoFloat Property FuseValueTotal AutoGlobalVariable Property My_GVfuseSlotNum Auto; slot check global is ALREADY set to 1GlobalVariable Property My_GVfusebox1stTrySlotEmpty AutoGlobalVariable Property My_GVfuseColorSlot1 AutoGlobalVariable Property My_GVfuseColorSlot2 AutoGlobalVariable Property My_GVfuseColorSlot3 AutoInt Property NumSlots = 1 Auto; user input for how many slots on this fuseboxMessage Property My_MSGfillSlots AutoObjectReference Property ObjToAct1 AutoEvent OnActivate(ObjectReference akActionRef)If (My_GVfusebox1stTrySlotEmpty.GetValue() == 0)My_MSGfillSlots.Show()My_GVfusebox1stTrySlotEmpty.SetValue(1)EndIfint SlotsCurrentlyFilled = My_GVfuseSlotNum.GetValue() as IntIf (SlotsCurrentlyFilled) == (NumSlots)DoMath()Elsedebug.notification("At Least 1 Slot Is Empty.")EndIfEndEvent;----------------------------------------------------------------------------------------------Function DoMath()debug.notification("Math Function.");----------------------------------- Slot 1 Red -----------------------------------------------If (My_GVfuseColorSlot1.GetValue() == 1); red fuse in slot 1Slot1Value = 2.5debug.notification("Red Fuse In Slot 1.")EndIf;----------------------------------- Slot 1 Blue -----------------------------------------------If (My_GVfuseColorSlot1.GetValue() == 2); blue fuse in slot 1Slot1Value = 2.0debug.notification("Blue Fuse In Slot 1.")EndIf;----------------------------------- Slot 1 Black -----------------------------------------------If (My_GVfuseColorSlot1.GetValue() == 3); black fuse in slot 1Slot1Value = 1.5debug.notification("Black Fuse In Slot 1.")EndIfFuseValueTotal = Slot1Value + Slot2Value + Slot3ValueDebug.Messagebox("Power = "+ Slot1Value)EndFunction Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 26, 2020 Share Posted March 26, 2020 I think you would just multiply by 10 to shift the decimal place by one and use the word percent in your text where the number is showing to the player. Link to comment Share on other sites More sharing options...
Recommended Posts