Pellape Posted February 18, 2021 Author Share Posted February 18, 2021 Yes, the blinking is disable enable. :) Link to comment Share on other sites More sharing options...
Pellape Posted February 18, 2021 Author Share Posted February 18, 2021 Yes, the blinking is disable enable. :) I also added the video to the first message at the top. Link to comment Share on other sites More sharing options...
Pellape Posted February 18, 2021 Author Share Posted February 18, 2021 Yes, I know. But position cell can only turn an object in Z angle as I do turn it in all 3 axes. Link to comment Share on other sites More sharing options...
JustChill Posted February 18, 2021 Share Posted February 18, 2021 In that case PositionCell would be a bit faster as State 3 and 4 wouldn't be necessary. But - despite of hating relative math - I see how your formula works for other shelfs, which makes it easier to convert since the exact bottle location will be calculated according the shelf location. :thumbsup: Nice work, I often go the longer way to avoid such formula's as I fear that I mess up the calculation by not being that good with math. ^^ Yes, I know. But position cell can only turn an object in Z angle as I do turn it in all 3 axes.That's true.Which then requires SetAngle X and SetAngle Y used separately.After using PositionCell. As everything should happen within the same frame, I doubt that Havok will kick in and make a mess. ^^ Ah, just checked on SetAngle... Seems this one either doesn't update the collision box on the object. :( This would require further testing. Maybe it's not bad for the shelf, but if so then the method with enabling and disabling seems really to be the only way. :( Link to comment Share on other sites More sharing options...
Pellape Posted February 18, 2021 Author Share Posted February 18, 2021 Yes Link to comment Share on other sites More sharing options...
Pellape Posted February 18, 2021 Author Share Posted February 18, 2021 Lots of set in the check for bottle function changed to Let and I changed the scribe to printc, in case I publish the debug by mistake. We will get offset info from it now and be in full control - hopefully scn PekCheckBottleTypesFUN string_var Path string_var CompPatch Ref BottleRef ;Ref BottleBaseRef Ref EmptyRef Float RNDBottleFL Short RNDBottleSH Short BeerTurnCOBL Short BottlesAmmount Short ItemType Short Turn Short BottleType ; Beer 1 ; Wine01 2 ; Wine02 3 ; Milk 4 Begin Function {} Label 0 Set EmptyRef to 0 Set BottleType to 0 Let BottlesAmmount := DrinksCabinet01Ref.GetNumItems + 1 Let RNDBottleFL := Rand 0 BottlesAmmount Set RNDBottleSH to RNDBottleFL Let BottleRef := DrinksCabinet01Ref.GetInventoryObject RNDBottleSH If eval ( BottleRef != EmptyRef || BottleRef == DrinksCabinet01Ref) Let ItemType := GetObjectType BottleRef EndIf If ( ItemType != 40 ) Let BottlesAmmount += 1 Set Turn to BottlesAmmount Printc "Item Type == %.0f - BottleRef = %i %n" ItemType BottleRef BottleRef While ( Turn > -1 ) Printc "Turn = %.0f", Turn Let BottleRef := DrinksCabinet01Ref.GetInventoryObject Turn Printc "BottleRef = %i %n" BottleRef BottleRef If eval ( BottleRef != EmptyRef || BottleRef == DrinksCabinet01Ref) Let ItemType := GetObjectType BottleRef ;Set BottleBaseRef to BottleRef.GetBaseObject Printc "Bottle = %i %n - ItemType Type = %.0f", BottleRef, BottleRef, ItemType If eval ( BottleRef != cobBevFlin || BottleRef != cobBevGreef ) If eval (BottleRef != cobBevMazte || BottleRef != cobBevShein ) If eval ( BottleRef != PotionSkooma || BottleRef != cobBevSujamma ) If Eval ( BottleRef != cobBevTelvanniBugMusk || BottleRef != cobBevTea ) If Eval ( BottleRef != cobSalDrinkHoney ) If ( ItemType == 40 ) break EndIf EndIf EndIf EndIf EndIf EndIf EndIf Set Turn to Turn - 1 Loop Let BottlesAmmount -= 1 If ( Turn <= 0 ) MessageBoxEX "Fill up the Upper Cabinet to the right of the rack with bottles" Set PekFillRackRef.State to 0 Return EndIf EndIf If eval ( BottleRef != EmptyRef || BottleRef == DrinksCabinet01Ref) Let Path := GetModelPath BottleRef Printc "Path = %z", Path EndIf Set BeerTurnCOBL to 1 While ( BeerTurnCOBL < 15 ) Let CompPatch := ToString BeerTurnCOBL If ( BeerTurnCOBL < 10 ) Let CompPatch := "clutter\Booze\BEER!bottle0" + CompPatch + ".nif" Else Let CompPatch := "clutter\Booze\BEER!bottle" + CompPatch + ".nif" EndIf If Eval ( Path == CompPatch ) Set BottleType to 1 Break EndIf Let BeerTurnCOBL += 1 Loop Let CompPatch := ToString "Clutter\AleBottle.NIF" If Eval ( Path == CompPatch ) Set BottleType to 1 EndIf Let CompPatch := ToString "Clutter\BeerBottle.NIF" If Eval ( Path == CompPatch ) Set BottleType to 1 EndIf Let CompPatch := ToString "Clutter\MeadBottle.NIF" If Eval ( Path == CompPatch ) Set BottleType to 1 EndIf Let CompPatch := ToString "clutter\milkbottle.nif" If Eval ( Path == CompPatch ) Set BottleType to 4 EndIf Let CompPatch := ToString "clutter\Booze\BEER!Mead.nif" If Eval ( Path == CompPatch ) Set BottleType to 1 EndIf Let CompPatch := ToString "clutter\Booze\BEER!Cider.nif" If Eval ( Path == CompPatch ) Set BottleType to 1 EndIf Let CompPatch := ToString "Clutter\winebottle01.NIF" If Eval ( Path == CompPatch ) Set BottleType to 2 EndIf Let CompPatch := ToString "Clutter\winebottle02.NIF" If Eval ( Path == CompPatch ) Set BottleType to 3 EndIf Let CompPatch := ToString "Clutter\winebottle03.NIF" If Eval ( Path == CompPatch ) Set BottleType to 2 EndIf If ( BottleType == 0 ) Goto 0 EndIf Set PekFillRackRef.BottleType to BottleType Set PekFillRackRef.BottleRef to BottleRef End Link to comment Share on other sites More sharing options...
Pellape Posted February 18, 2021 Author Share Posted February 18, 2021 (edited) Damn Drake:I did found that set BottleIndex to 1, which was later set to 2, which resulted in every ref got added to the array index 2. :wallbash: MEGA THANKS Edited February 18, 2021 by Pellape Link to comment Share on other sites More sharing options...
Pellape Posted February 18, 2021 Author Share Posted February 18, 2021 I did clean the main script from a couple of set and added some Let scn PekFillRackWithBottles02SCR array_var BottleArr array_var BottlePosX array_var BottlePosY array_var BottlePosZ array_var BottleAngX array_var BottleAngY array_var BottleAngZ array_var BottleExistArr Ref BottleRef Ref BottleRef2 Ref StoredBottleRef Ref BottleBaseRef Ref EmptyRef Ref BeastRef Ref HandleRef Float xPos Float yPos Float zPos Float xAngle Float yAngle Float zAngle Float StartX Float StartY Float StartZ ;Float RackPosAng Short Button Short TurnX Short TurnZ ;Short Turn Short BottlesAmmount Short State Short Rack Short DoOnce Short BottleIndex Short BottleExist Short UpdateArrays Short BottleType ; Beer 1 ; Wine01 2 ; Wine02 3 ; Milk 4 Begin OnActivate Set State to -1 End ;;;;;;;;;;;;;;;;;;;;;;;;;;; Begin GameMode If ( State == 0 ) Return EndIf If ( DoOnce == 0 ) let BottleArr := ar_Construct Array let BottlePosX := ar_Construct Array let BottlePosY := ar_Construct Array let BottlePosZ := ar_Construct Array let BottleAngX := ar_Construct Array let BottleAngY := ar_Construct Array let BottleAngZ := ar_Construct Array Let BottleExistArr := ar_Construct Array Set EmptyRef to 0 let BottleArr[0] := EmptyRef let BottlePosX[0] := 0 let BottlePosY[0] := 0 let BottlePosZ[0] := 0 let BottleAngX[0] := 0 let BottleAngY[0] := 0 let BottleAngZ[0] := 0 let BottleExistArr[0] := 0 Set BottleIndex to 1 While ( BottleIndex < 46 ) let BottleArr[BottleIndex] := 666 let BottlePosX[BottleIndex] := 0 let BottlePosY[BottleIndex] := 0 let BottlePosZ[BottleIndex] := 0 let BottleAngX[BottleIndex] := 0 let BottleAngY[BottleIndex] := 0 let BottleAngZ[BottleIndex] := 0 let BottleExistArr[BottleIndex] := 0 Set BottleIndex to BottleIndex + 1 Loop MessageBoxEX "Make sure the 2 bottle racks are empty this first time. Do you want to fill them with Bottles?|No|Yes|Fix positions" Set State to 30 Set UpdateArrays to 1 Set DoOnce to 1 ElseIf ( State == -1 ) MessageBoxEX "Do you want to fill the rack with Bottles?|No|Yes|Fix positions" Set State to 30 Set UpdateArrays to 1 EndIf ;Set BottleIndex to 1 If ( State == 20 ) Set Button to GetButtonPressed If ( Button == 0 ) Set State to 0 Return ElseIf ( Button == 1 ) Set State to 1 Set Button to -1 ElseIf ( Button == 2 ) Set State to 30 Set Button to -1 EndIf EndIf If ( State == 1 ) Set EmptyRef to 0 Set BottleType to 0 Set BeastRef to 666 Let BottlesAmmount := DrinksCabinet01Ref.GetNumItems If ( BottlesAmmount == 0 ) MessageBoxEX "Fill up the Upper Cabinet to the right of the rack with bottles" Set State to 0 Return EndIf ; Filling the upper Rack Set Rack to 1 ; x steps 10.85 ; z steps 13,37 Set StartX to PekBottleRackRef.Getpos x - 32.52 Set StartY to PekBottleRackRef.Getpos y - 3.1 Set StartZ to PekBottleRackRef.Getpos z + 31.17 Set TurnZ to 1 Set TurnX to 1 Set State to 2 EndIf If ( State == 2 ) If ( TurnZ < 5 ) If ( TurnX < 6 ) Let BottleIndex += 1 ;Scribe "BottleNumber = %0.0f" BottleIndex Let BottleExist := BottleExistArr[BottleIndex] If ( BottleExist == 0 ) let BottleArr[BottleIndex] := EmptyRef let BottlePosX[BottleIndex] := 0 let BottlePosY[BottleIndex] := 0 let BottlePosZ[BottleIndex] := 0 let BottleAngX[BottleIndex] := 0 let BottleAngY[BottleIndex] := 0 let BottleAngZ[BottleIndex] := 0 EndIf Let StoredBottleRef := BottleArr[BottleIndex] If eval ( StoredBottleRef == BeastRef ) ElseIf eval ( StoredBottleRef != EmptyRef ) Let TurnX += 1 Return EndIf Call PekCheckBottleTypesFUN ;Beer and Mead bottles Set xPos to StartX + ( 10.85 * TurnX ) Set yPos to StartY Set zPos to StartZ - ( 13.37 * TurnZ ) Set xAngle to -92.5 Set yAngle to 0 Set zAngle to 135 If ( BottleType == 2 ) Set zPos to zPos + 1 Set xAngle to -90 Set zAngle to 165 ElseIf ( BottleType == 3 ) Set zPos to zPos + 1 Set xAngle to -90 ElseIf ( BottleType == 4 ) Set xPos to xPos + 0.5 Set yPos to yPos + 2 Set zPos to zPos + 1 Set xAngle to -90 EndIf Set TurnX to TurnX + 1 If eval ( BottleRef != EmptyRef ) Player.PlaceAtMe BottleRef 1 DrinksCabinet01Ref.RemoveItemNS BottleRef 1 Set State to 3 Return EndIf Else Set TurnX to 1 Let TurnZ += 1 EndIf Else Set State to 11 Set Rack to 2 EndIf EndIf If ( State == 3 ) BottleRef.disable Set State to 4 Return EndIf If ( State == 4 ) BottleRef.enable Set State to 5 Return EndIf If ( State == 5 ) ;Printc "Bottle == %i %n", BottleRef, BottleRef Let BottleRef2 := GetFirstRef 40 4 While ( BottleRef2 ) Let BottleBaseRef := BottleRef2.GetBaseObject If eval ( BottleBaseRef == BottleRef ) Set BottleRef to BottleRef2 Break EndIf Let BottleRef2 := GetNextRef loop If eval ( BottleRef != PekBottleRackRef || BottleRef == EmptyRef ) BottleRef.SetPos x xPos BottleRef.SetPos y yPos BottleRef.SetPos z zPos BottleRef.SetAngle x xAngle BottleRef.SetAngle y yAngle BottleRef.SetAngle z zAngle let BottleArr[BottleIndex] := BottleRef let BottlePosX[BottleIndex] := xPos let BottlePosY[BottleIndex] := yPos let BottlePosZ[BottleIndex] := zPos let BottleAngX[BottleIndex] := xAngle let BottleAngY[BottleIndex] := yAngle let BottleAngZ[BottleIndex] := zAngle let BottleExistArr[BottleIndex] := 1 EndIf Set State to 6 Return EndIf If ( State == 6 ) BottleRef.disable Set State to 7 Return EndIf If ( State == 7 ) BottleRef.Enable If ( Rack == 1 ) Set State to 2 ElseIf ( Rack == 2 ) Set State to 12 EndIf Return EndIf ;Filling the lower Rack ; x steps 14 ; z steps 13,22 If ( State == 11 ) Set StartX to PekBottleRackRef.Getpos x - 35.3 Set StartY to PekBottleRackRef.Getpos y + 8 Set StartZ to PekBottleRackRef.Getpos z - 35.3 Set TurnZ to 1 Set TurnX to 1 Set State to 12 EndIf If ( State == 12 ) If ( TurnZ < 5 ) If ( TurnX < 5 ) Let BottleIndex := + 1 ;Scribe "BottleNumber = %0.0f" BottleIndex Let BottleExist := BottleExistArr[BottleIndex] If ( BottleExist == 0 ) let BottleArr[BottleIndex] := EmptyRef let BottlePosX[BottleIndex] := 0 let BottlePosY[BottleIndex] := 0 let BottlePosZ[BottleIndex] := 0 let BottleAngX[BottleIndex] := 0 let BottleAngY[BottleIndex] := 0 let BottleAngZ[BottleIndex] := 0 EndIf Let StoredBottleRef := BottleArr[BottleIndex] If eval ( StoredBottleRef == BeastRef ) ElseIf eval ( StoredBottleRef != EmptyRef ) Let TurnX += 1 Return EndIf Call PekCheckBottleTypesFUN ;Beer and Mead bottles Set xPos to StartX + ( 14 * TurnX ) Set yPos to StartY - 15 Set zPos to StartZ - ( 13.22 * TurnZ ) Set xAngle to -90 Set yAngle to 0 Set zAngle to 135 If ( BottleType == 2 ) Set zPos to zPos + 1 Set zAngle to 165 ElseIf ( BottleType == 3 ) Set zPos to zPos + 1 ElseIf ( BottleType == 4 ) Set xPos to xPos + 0.5 Set yPos to yPos + 2 Set zPos to zPos + 1 EndIf Set TurnX to TurnX + 1 If eval ( BottleRef != EmptyRef ) Player.PlaceAtMe BottleRef 1 DrinksCabinet01Ref.RemoveItemNS BottleRef 1 let BottleArr[BottleIndex] := BottleRef let BottlePosX[BottleIndex] := xPos let BottlePosY[BottleIndex] := yPos let BottlePosZ[BottleIndex] := zPos let BottleAngX[BottleIndex] := xAngle let BottleAngY[BottleIndex] := yAngle let BottleAngZ[BottleIndex] := zAngle let BottleExistArr[BottleIndex] := 1 Set State to 3 Return EndIf Else Set TurnX to 1 Set TurnZ to TurnZ + 1 EndIf Else Set State to 0 Set TurnZ to 1 EndIf EndIf If ( State == 30 ) Printc "Initiates positioning" Set EmptyRef to 0 Set BeastRef to 666 Set HandleRef to GetSelf Set BottleIndex to 1 While (BottleIndex < 46 ) Let StoredBottleRef := BottleArr[BottleIndex] If eval ( StoredBottleRef != EmptyRef || StoredBottleRef != BeastRef ) Let BottleRef2 := GetFirstRef 40 4 While ( BottleRef2 ) If eval ( BottleRef2 == StoredBottleRef && BottleRef2 != EmptyRef) let BottleExistArr[BottleIndex] := 1 Break Else let BottleExistArr[BottleIndex] := 0 EndIf Let BottleRef2 := GetNextRef loop Let BottleExist := BottleExistArr[BottleIndex] If ( BottleExist == 1 ) If Eval ( BottleRef2 != HandleRef ) Let xPos := BottlePosX[BottleIndex] Let yPos := BottlePosY[BottleIndex] Let zPos := BottlePosZ[BottleIndex] Let xAngle := BottleAngX[BottleIndex] Let yAngle := BottleAngY[BottleIndex] Let zAngle := BottleAngZ[BottleIndex] BottleRef2.SetPos x xPos BottleRef2.SetPos y yPos BottleRef2.SetPos z zPos BottleRef2.SetAngle x xAngle BottleRef2.SetAngle y yAngle BottleRef2.SetAngle z zAngle EndIf EndIf EndIf Printc "BottleIndex = %g - %i %n - Exist? %g" BottleIndex BottleRef2 BottleRef2 BottleExist Let BottleIndex += 1 Loop If ( UpdateArrays == 1 ) Set State to 20 Set UpdateArrays to 0 Else Set State to 0 EndIf EndIf End Time to test this crap, again... No wonder that script did not added more than 1 bottles at rack 2. :D Damn... But do not say hey until you crossed the river Pekka... ;) I am happy never the less :) Link to comment Share on other sites More sharing options...
JustChill Posted February 18, 2021 Share Posted February 18, 2021 Nice. ^^I often bite into my desk when scripting and suddenly something weird occurs which I have to figure out by debuggin the whole stuff. Glad you found it out. Just one thing that comes into my mind about your video.I see that you firstly move the bottles into positon and then they are blinking on the spot. Would it either work, if you disable the bottles first, then move them into postion and enable them afterwards.That would fix the blinking for moving the bottles from shelf to shelf, even though it wouldn't for the button which fixes the placement of already positioned bottles.But still, might look a bit more appealing? ;) Link to comment Share on other sites More sharing options...
Pellape Posted February 18, 2021 Author Share Posted February 18, 2021 (edited) I do get a lot of offset info now to work with and the bottom rack gets filled. SO far, so good. It does not work perfect yet but it do what it is meant to at least: Maybe? I keep it as it is right now and maybe do it later. I must find the bug first Edited February 18, 2021 by Pellape Link to comment Share on other sites More sharing options...
Recommended Posts