Karel2015 Posted May 27, 2016 Share Posted May 27, 2016 (132,15): Additem is not a function or does not exist(135,15): Additem is not a function or does not exist(138,15): Additem is not a function or does not exist(134,15): Additem is not a function or does not exist Weapon Property WeaponHigh AutoWeapon Property Sniper AutoWeapon Property GeneralWeapon AutoWeapon Property Melee Auto Message Property MessageWeapons Auto 125 ElseIf aiButton == 1 ; Minutemen126 aiButton = MessageMinutemen.Show()127 If aiButton == 0 ; SeniorOfficer128 Player.PlaceAtMe(MinuteSO, 1)129 NewSoldiersBuilt.setValueInt(NewSoldiersBuilt.getValueInt() + 1)130 aiButton = MessageWeapons.Show()131 If aiButton == 0 ; High End132 MinuteSO.Additem(WeaponHigh, 1, true)133 Player.RemoveItem(Caps as Form, 1000, True)134 ElseIf aiButton == 1 ; Sniper135 MinuteSO.Additem(Sniper, 1, true)136 Player.RemoveItem(Caps as Form, 1000, True)137 ElseIf aiButton == 2 ; GeneralWeapon138 MinuteSO.Additem(GeneralWeapon, 1, True)139 Player.RemoveItem(Caps as Form, 500, True)140 ElseIf aiButton == 3 ; Melee141 MinuteSO.Additem(Melee, 1, True)142 Player.RemoveItem(Caps as Form, 500, True)143 EndIfOk, So I am trying to add an Item to the NPC that is being placed. Everything works right, Except it says that Additem is not a function or does not exist. I can set it to Player.Additem and it works fine but that doesn't help me. Link to comment Share on other sites More sharing options...
Surilindur Posted May 27, 2016 Share Posted May 27, 2016 You are probably calling it on a base object, since PlaceAtMe takes some sort of a base object as its parameter, and you use MinuteSO there. You cannot add stuff to a base object. However, PlaceAtMe returns the newly placed ObjectReference, so you can pick that up and use it instead. Like this: ... ObjectReference rTemp = Player.PlaceAtMe(MinuteSO, 1) rTemp.AddItem(Sniper, 1, True) ...Did you solve the issue you had earlier, with gold not being removed when it should? The one you posted the assembly code with? Link to comment Share on other sites More sharing options...
Karel2015 Posted May 27, 2016 Author Share Posted May 27, 2016 (edited) Yesssssssssss haha, I forgot :tongue: but yeah I got that fixed :D thanks and omg that worked like a freaking charm, If I could kiss you through the internet bahaha Edited May 27, 2016 by Karel2015 Link to comment Share on other sites More sharing options...
Surilindur Posted May 27, 2016 Share Posted May 27, 2016 No problem, happy to help. Good to hear you got it fixed. :laugh: The Wiki has lots of info on the different commands, and this page is especially useful, and although it does not have the inheritance tree like in the equivalent Skyrim wiki, it is still a nice collection of the top level stuff to work down from if you ever need to find all commands you can use on a specific type of object: http://www.creationkit.com/fallout4/index.php?title=Category:Script_Objects Link to comment Share on other sites More sharing options...
Karel2015 Posted May 27, 2016 Author Share Posted May 27, 2016 ElseIf aiButton == 1 ; Minutemen aiButton = MessageMinutemen.Show() If aiButton == 0 ; SeniorOfficer NewSoldiersBuilt.setValueInt(NewSoldiersBuilt.getValueInt() + 1) aiButton = MessageWeapons.Show() If aiButton == 0 ; Heavy ObjectReference rTemp = Player.PlaceAtMe(MinuteSO, 1) rTemp.AddItem(WeaponHeavy, 1, true) Player.RemoveItem(Caps as Form, 1000, True) aiButton = MessageOutfits.Show() If aiButton == 0 ; Heavy rTemp.AddItem(OutfitHeavy, 1, true) Player.RemoveItem(Caps as Form, 2000, True) ElseIf aiButton == 1 ; Medium rTemp.AddItem(OutfitMedium, 1, true) Player.RemoveItem(Caps as Form, 1000, True) ElseIf aiButton == 2 ; Light rTemp.Additem(OutfitLight, 1, true) Player.RemoveItem(Caps as Form, 500, True) EndIf Ok so trying this, It all compile and works fine. But using the secondary format to add outfits into the mix, It won't give them a weapon or an outfit. With just: ElseIf aiButton == 1 ; Minutemen aiButton = MessageMinutemen.Show() If aiButton == 0 ; SeniorOfficer NewSoldiersBuilt.setValueInt(NewSoldiersBuilt.getValueInt() + 1) aiButton = MessageWeapons.Show() If aiButton == 0 ; Heavy ObjectReference rTemp = Player.PlaceAtMe(MinuteSO, 1) rTemp.AddItem(WeaponHeavy, 1, true) Player.RemoveItem(Caps as Form, 1000, True) It will give the weapon, and remove the caps. But I wanted to add an option for outfits too. Link to comment Share on other sites More sharing options...
Surilindur Posted May 27, 2016 Share Posted May 27, 2016 (edited) Getting interesting that code there. Is there a reason why you have it all inside one if-statement? For the sake of easier debugging, maybe you could try separating it a bit, like one section for NPC, one for weapon, one for outfit. Like this, as an example: .... Int iCaps = 0 ; total cost of the purchase Int iButton = SomeMessage.Show() If(iButton == 0) Return ; 0 would make a handy "cancel" button ElseIf(iButton == 1) Actor rPlaced = None ; ---- pick the soldier here ---- iButton = PickSoldier.Show() If(Button == 0) Return ; 0 would make a handy "cancel" button ElseIf(iButton == 1) rPlaced = Player.PlaceAtMe(SomeSoldier, 1) iCaps += 1000 ElseIf(iButton == 2) .... EndIf ; ---- soldier pick over ---- Utility.Wait(0.5) ; wait a little maybe? ; ---- pick weapon ---- iButton = PickWeapon.Show() ; move on to weapon picking If(iButton == 0) Return ElseIf(iButton == 1) rPlaced.AddItem(SomeWeapon, 1) Utility.Wait(0.5) rPlaced.EquipItem(SomeWeapon) iCaps += 800 ElseIf(iButton == 2) .... EndIf ; ---- weapon pick over ---- Utility.Wait(0.5) ; --- pick outfit --- iButton = PickOutfit.Show() If(iButton == 0) Return ElseIf(iButton == 1) rPlaced.AddItem(SomeOutfit, 1) Utility.Wait(0.5) rPlaced.EquipItem(SomeOutfit) iCaps += 500 ElseIf(iButton == 2) .... EndIf ; ---- outfit pick over ---- ElseIf(iButton == 2) ; something other than those soldiers .... EndIf Player.RemoveItem(Caps, iCaps, False) ; remove whole price at the end .... That is just an example. If you need to nest outfits inside soldier types, then your current system is fine, though. Having lots of nested stuff will make tracking harder, I think, but if you need to do it that way, you have no other choice. You can add messageboxes in your script to see where it goes during execution, for example, to track where it goes wrong by loading in-game and reading the boxes. And Papyrus log should be able to tell you any fatal errors that stop the whole thing, assuming Fallout 4 still has it. Edit: These ones: Debug.MessageBox("Button " + aiButton + ", currently doing blaablaa...") Edited May 27, 2016 by Contrathetix Link to comment Share on other sites More sharing options...
Karel2015 Posted May 27, 2016 Author Share Posted May 27, 2016 (edited) So something like this would be what it would look like built from what you wrote then ? "And how do you get it to color it like that or did you do all that manually ?" Function Menu(Bool abMenu = True, Int aiButton = 0) Int iCaps = 0 ; total cost of the purchase Int iButton = FirstMessage.Show() If(iButton == 0) Return ; 0 would make a handy "cancel" button ElseIf(iButton == 1) Actor rPlaced = None ; ---- pick the soldier here ---- iButton = MessageMinutemen.Show() If(Button == 0) Return ; 0 would make a handy "cancel" button ElseIf(iButton == 1) rPlaced = Player.PlaceAtMe(MinuteSO, 1) iCaps += 1000 ElseIf(iButton == 2) rPlaced = Player.PlaceAtMe(MinuteO, 1) iCaps += 1000 ElseIf(iButton == 3) rPlaced = Player.PlaceAtMe(MinuteR, 1) iCaps += 1000 ElseIf(iButton == 4) rPlaced = Player.PlaceAtMe(MinuteV, 1) iCaps += 1000 ElseIf(iButton == 5) rPlaced = Player.PlaceAtMe(MinuteC, 1) iCaps += 1000 ElseIf(iButton == 6) rPlaced = Player.PlaceAtMe(MinuteREC, 1) iCaps += 1000 EndIf ; ---- soldier pick over ---- Utility.Wait(0.5) ; wait a little maybe? ; ---- pick weapon ---- iButton = MessageWeapons.Show() ; move on to weapon picking If(iButton == 0) Return ElseIf(iButton == 1) rPlaced.AddItem(WeaponHeavy, 1) Utility.Wait(0.5) rPlaced.EquipItem(WeaponHeavy) iCaps += 800 ElseIf(iButton == 2) rPlaced.AddItem(WeaponAutomatic, 1) Utility.Wait(0.5) rPlaced.EquipItem(WeaponAutomatic) iCaps += 800 ElseIf(iButton == 3) rPlaced.AddItem(WeaponShotgun, 1) Utility.Wait(0.5) rPlaced.EquipItem(WeaponShotgun) iCaps += 800 ElseIf(iButton == 4) rPlaced.AddItem(WeaponMelee, 1) Utility.Wait(0.5) rPlaced.EquipItem(WeaponMelee) iCaps += 800 EndIf ; ---- weapon pick over ---- Utility.Wait(0.5) ; --- pick outfit --- iButton = MessageOutfits.Show() If(iButton == 0) Return ElseIf(iButton == 1) rPlaced.AddItem(OutfitHeavy, 1) Utility.Wait(0.5) rPlaced.EquipItem(OutfitHeavy) iCaps += 500 ElseIf(iButton == 2) rPlaced.AddItem(OutfitMedium, 1) Utility.Wait(0.5) rPlaced.EquipItem(OutfitMedium) iCaps += 500 ElseIf(iButton == 3) rPlaced.AddItem(OutfitLight, 1) Utility.Wait(0.5) rPlaced.EquipItem(OutfitLight) iCaps += 500 EndIf ; ---- outfit pick over ---- ElseIf(iButton == 2) ; something other than those soldiers Actor rPlaced = None ; ---- pick the soldier here ---- iButton = MessageSettlers.Show() If(Button == 0) Return ; 0 would make a handy "cancel" button ElseIf(iButton == 1) rPlaced = Player.PlaceAtMe(Settler, 1) iCaps += 1000 ElseIf(iButton == 2) rPlaced = Player.PlaceAtMe(SettlerM, 1) iCaps += 1000 ElseIf(iButton == 3) rPlaced = Player.PlaceAtMe(SettlerR, 1) iCaps += 1000 ElseIf(iButton == 4) rPlaced = Player.PlaceAtMe(SettlerPA, 1) iCaps += 1000 ElseIf(iButton == 5) rPlaced = Player.PlaceAtMe(SettlerG, 3) iCaps += 1000 EndIf ; ---- soldier pick over ---- Utility.Wait(0.5) ; wait a little maybe? ; ---- pick weapon ---- iButton = MessageWeapons.Show() ; move on to weapon picking If(iButton == 0) Return ElseIf(iButton == 1) rPlaced.AddItem(WeaponHeavy, 1) Utility.Wait(0.5) rPlaced.EquipItem(WeaponHeavy) iCaps += 800 ElseIf(iButton == 2) rPlaced.AddItem(WeaponAutomatic, 1) Utility.Wait(0.5) rPlaced.EquipItem(WeaponAutomatic) iCaps += 800 ElseIf(iButton == 3) rPlaced.AddItem(WeaponShotgun, 1) Utility.Wait(0.5) rPlaced.EquipItem(WeaponShotgun) iCaps += 800 ElseIf(iButton == 4) rPlaced.AddItem(WeaponMelee, 1) Utility.Wait(0.5) rPlaced.EquipItem(WeaponMelee) iCaps += 800 EndIf ; ---- weapon pick over ---- Utility.Wait(0.5) ; --- pick outfit --- iButton = MessageOutfits.Show() If(iButton == 0) Return ElseIf(iButton == 1) rPlaced.AddItem(OutfitHeavy, 1) Utility.Wait(0.5) rPlaced.EquipItem(OutfitHeavy) iCaps += 500 ElseIf(iButton == 2) rPlaced.AddItem(OutfitMedium, 1) Utility.Wait(0.5) rPlaced.EquipItem(OutfitMedium) iCaps += 500 ElseIf(iButton == 3) rPlaced.AddItem(OutfitLight, 1) Utility.Wait(0.5) rPlaced.EquipItem(OutfitLight) iCaps += 500 EndIf ; ---- outfit pick over ---- ElseIf(iButton == 3) ; something other than those soldiers Actor rPlaced = None ; ---- pick the soldier here ---- iButton = MessageAnimals.Show() If(Button == 0) Return ; 0 would make a handy "cancel" button ElseIf(iButton == 1) rPlaced = Player.PlaceAtMe(Cat, 1) iCaps += 1000 ElseIf(iButton == 2) rPlaced = Player.PlaceAtMe(Dog, 1) iCaps += 1000 ElseIf(iButton == 3) rPlaced = Player.PlaceAtMe(AnimCatA, 1) iCaps += 1000 ElseIf(iButton == 4) rPlaced = Player.PlaceAtMe(AnimDogA, 1) iCaps += 1000 ElseIf(iButton == 5) rPlaced = Player.PlaceAtMe(AnimGroup, 3) iCaps += 1000 ElseIf(iButton == 6) rPlaced = Player.PlaceAtMe(AnimArmoredGroup, 3) iCaps += 1000 EndIf Player.RemoveItem(Caps, iCaps, False) ; remove whole price at the end EndIf EndFunction Edited May 28, 2016 by Karel2015 Link to comment Share on other sites More sharing options...
Karel2015 Posted May 27, 2016 Author Share Posted May 27, 2016 Doing it that way, I get this error now: (118,12): type mismatch while assigning to a actor (cast missing or types unrelated) Link to comment Share on other sites More sharing options...
Surilindur Posted May 28, 2016 Share Posted May 28, 2016 (edited) It was just an example, an idea, a different view on the matter. Nothing serious, I am not here to tell anyone how to do their stuff. People can do everything exactly the way they want to. You can use your original one just fine, it does not matter. Apologies if I made it seem otherwise, it was not my intention. :smile: You can probably use ObjectReference. I have no idea if you can cast an ObjectReference as an Actor. If casting does not work, you can use an ObjectReference. Actor rTemp = Player.PlaceAtMe(something, 1) as Actor ; most likely fails...As for the colours, they are random (or so it would seem), but to paste more code-like code, you can use the code tags, like if you write a spoiler like this (approximately): [ spoiler ] contents [ / spoiler ] and it looks like this: contents you can write [ code ] contents [ / code ] and it will show like this contentsand you can even nest them, placing code tag inside a spoiler. And yes, I usually write most of the common tags manually for some reason. When on PC, I often do use the editor buttons, too. But I have not managed to make a spoiler with them. :tongue: Edited May 28, 2016 by Contrathetix Link to comment Share on other sites More sharing options...
Karel2015 Posted May 28, 2016 Author Share Posted May 28, 2016 Ughhhhhhhhhhhhhh This is just giving me a headache, Can't seem to get it to work lmao I'll keep digging at it though Link to comment Share on other sites More sharing options...
Recommended Posts