Jump to content

Recycle-Bot Idea


DanTheManForth

Recommended Posts

Seeing how desperate you are, and being bored as I am, I made you this script (requires NVSE). Haven't tested it, but it should do the trick:

 

scn RobocycleScript

short bMenuUp
short iMenuButton
short iCount
short iRequired
ref rItemList
ref rItem
ref rRecycled

begin OnAdd

MessageBoxEx "Which item would you like to make?| |A blank book|Scrap metal|Nevermind"
set bMenuUp to 1

end

begin GameMode

if bMenuUp
	set iMenuButton to GetButtonPressed
	if iMenuButton > -1
		if iMenuButton == 0
		elseif iMenuButton == 3
			set bMenuUp to 0
			Return
		else
			if iMenuButton == 1
				set rItemList to RobocycleBookList
				set iRequired to 10
				set rRecycled to [put the blank book EditorID here]
			elseif iMenuButton == 2
				set rItemList to RobocycleScrapList
				set iRequired to 25
				set rRecycled to SpareParts
			endif
			if player.GetItemCount rItemList >= iRequired
				; Attempting to use an equal number of each compatible item, if possible.
				Label 1
				if iCount == 0
					set iCount to ListGetCount rItemList
				endif
				set iCount to iCount - 1
				set rItem to ListGetNthForm rItemList iCount
				if player.GetItemCount rItem
					player.RemoveItem rItem 1 1
					set iRequired to iRequired - 1
				endif
				if iRequired
					GoTo 1
				else
					set iCount to 0
				endif
				player.AddItem rRecycled 1 1
			else
				MessageBoxEx "Not enough items to recycle."
				Return
			endif
		endif
		MessageBoxEx "Which item would you like to make?| |A blank book|Scrap metal|Nevermind"
	endif
else
	RemoveMe
endif

end

 

1. Make sure you set the script type to 'Object'.

2. Create a new misc item and make it use this script.

3. Create two Form Lists: 'RobocycleBookList' - drag into it all the items that can be recycled to a blank book; 'RobocycleScrapList' - likewise, for scrap metal.

4. Set the dialogue option to add the misc item (from step 2) to the player's inventory, then terminate dialogue.

 

Good luck.

Edited by jazzisparis
Link to comment
Share on other sites

Ok. So, using the script that jazzisparis wrote up for me (thanks a ton, again), I've tweaked it a bit to match more specifically what I am trying to do. I am still having some issues, though, which I've written in on the line which the question addresses. Here is what I have, thus far:

 

scn RobocycleScript

short bMenuUp
short iMenuButton
short iCount
short iRequired
ref rItemList
ref rItem
ref rRecycled

begin OnAdd

        MessageBoxEx "Which Items Do You Wish To Recycle?| |Books|Metal Clutter|Wooden Clutter|Earthen Clutter|Toys|All Of These|None Of These"
        set bMenuUp to 1

end

begin GameMode

        if bMenuUp
                set iMenuButton to GetButtonPressed
                if iMenuButton > -1
                        if iMenuButton == 0
                        elseif iMenuButton == 7
                                set bMenuUp to 0
                                Return
                        else
                                if iMenuButton == 1
                                        set rItemList to RobocycleBookList
                                        set iRequired to 1
                                        set rRecycled to xx011fca			; How do I tell it to find the DLC/Mod load-order to get these first two digits?
                                elseif iMenuButton == 2
                                        set rItemList to RobocycleMetalList
                                        set iRequired to 15
                                        set rRecycled to 00031944			; Should I be using Form/Base ID or Editor ID?
                                elseif iMenuButton == 3
                                        set rItemList to RobocycleWoodList
                                        set iRequired to 10
                                        set rRecycled to xx0133b1			; Same here. The "Book Chute" script does it like this -- NVDLC03BlankBookMISC -- but I dont really know what that means.
                                elseif iMenuButton == 4
                                        set rItemList to RobocycleEarthenList
                                        set iRequired to 5
                                        set rRecycled to 00022106
                               elseif iMenuButton == 5
                                        set rItemList to RobocycleToyList
                                        set iRequired to 1
                                        set rRecycled to 0013b2b1
                               elseif iMenuButton == 6					; How do I tell it to do the operations for all buttons?

                                endif
                                if player.GetItemCount rItemList >= iRequired
                                        ; Attempting to use an equal number of each compatible item, if possible.
                                        Label 1
                                        if iCount == 0
                                                set iCount to ListGetCount rItemList
                                        endif
                                        set iCount to iCount - 1
                                        set rItem to ListGetNthForm rItemList iCount
                                        if player.GetItemCount rItem
                                                player.RemoveItem rItem 1 1
                                                set iRequired to iRequired - 1
                                        endif
                                        if iRequired
                                                GoTo 1
                                        else
                                                set iCount to 0
                                        endif
                                        player.AddItem rRecycled 1 1
                                else
                                        MessageBoxEx "Not enough items to recycle."	; How do I tell it to skip the operation it cant do without showing this message when using the "all" button?
                                        Return
                                endif
                        endif
                        MessageBoxEx "Which Items Do You Wish To Recycle?| |Books|Metal Clutter|Wooden Clutter|Earthen Clutter|Toys|All Of These|None Of These"

                endif
        else
                RemoveMe
        endif

end

 

Thanks again, everyone, for all your help!

Edited by DanTheManForth
Link to comment
Share on other sites

Should I be using Form/Base ID or Editor ID?

The GECK will only accept Editor IDs (there is, actually, a way to convert Form IDs to Editor IDs, but you don't really need to use it for what you're planning).

 

How do I tell it to find the DLC/Mod load-order to get these first two digits?

No need for that. Your mod will require Old World Blues to be installed anyway. Just use the relevant Editor ID.

 

Same here. The "Book Chute" script does it like this -- NVDLC03BlankBookMISC -- but I dont really know what that means.

That's probably the Editor ID of a blank book. :)

 

How do I tell it to do the operations for all buttons?
How do I tell it to skip the operation it cant do without showing this message when using the "all" button?
Both have been taken cared of:

 

scn RobocycleScript

short bMenuUp
short iMenuButton
short bRecycleAll
short iCount
short iRequired
ref rItemList
ref rItem
ref rRecycled

begin OnAdd

MessageBoxEx "Which Items Do You Wish To Recycle?| |Books|Metal Clutter|Wooden Clutter|Earthen Clutter|Toys|All Of These|None Of These"
set bMenuUp to 1

end

begin GameMode

if bMenuUp
	set iMenuButton to GetButtonPressed
	if iMenuButton > -1
		if iMenuButton == 0
		elseif iMenuButton == 7
			set bMenuUp to 0
			Return
		else
			if iMenuButton == 6
				set bRecycleAll to 1
				set iMenuButton to 1
			endif
			Label 2
			if iMenuButton == 1
				set rItemList to RobocycleBookList
				set iRequired to 1
				set rRecycled to [item editor ID]
			elseif iMenuButton == 2
				set rItemList to RobocycleMetalList
				set iRequired to 15
				set rRecycled to [item editor ID]
			elseif iMenuButton == 3
				set rItemList to RobocycleWoodList
				set iRequired to 10
				set rRecycled to [item editor ID]
			elseif iMenuButton == 4
				set rItemList to RobocycleEarthenList
				set iRequired to 5
				set rRecycled to [item editor ID]
			elseif iMenuButton == 5
				set rItemList to RobocycleToyList
				set iRequired to 1
				set rRecycled to [item editor ID]
			endif
			if player.GetItemCount rItemList >= iRequired
				; Attempting to use an equal number of each compatible item, if possible.
				Label 1
				if iCount == 0
					set iCount to ListGetCount rItemList
				endif
				set iCount to iCount - 1
				set rItem to ListGetNthForm rItemList iCount
				if player.GetItemCount rItem
					player.RemoveItem rItem 1 1
					set iRequired to iRequired - 1
				endif
				if iRequired
					GoTo 1
				else
					set iCount to 0
				endif
				player.AddItem rRecycled 1 1
			elseif bRecycleAll == 0
				MessageBoxEx "Not enough items to recycle."
				Return
			endif
			if bRecycleAll == 0
			elseif iMenuButton < 5
				set iMenuButton to iMenuButton + 1
				GoTo 2
			else
				set bRecycleAll to 0
			endif
		endif
		MessageBoxEx "Which Items Do You Wish To Recycle?| |Books|Metal Clutter|Wooden Clutter|Earthen Clutter|Toys|All Of These|None Of These"
	endif
else
	RemoveMe
endif

end

Link to comment
Share on other sites

Amazing! :dance: If I manage to get this thing functioning, and post it for download, I will be sure to list you as co-creator. :thumbsup:

 

Last Question: for the Form Lists, do I just open script editor in GECK, give it the appropriate scn, and just list everything this script should be looking for? And I assume I will need to list everything by Editor ID in the form lists as well ... ?

Link to comment
Share on other sites

Last Question: for the Form Lists, do I just open script editor in GECK, give it the appropriate scn, and just list everything this script should be looking for? And I assume I will need to list everything by Editor ID in the form lists as well ... ?

In the GECK, look for 'Form List' under 'Miscellaneous'. Create the new lists you require, then open each of them and simply '"drag" (from the object window) the items into it.

Link to comment
Share on other sites

Aright! And, we're back! So, I've been doing a bunch of testing and everything is working almost perfect. You Rock! The only thing I have noticed is that, If I have an inventory full of junk, it only does one "recycle" exchange for every time I push a button (I had to hit "Books" 37 times to process all of the books). Is there a way to make it repeat the "recycle" action until it runs out of items in each category?

 

On a different note, I wanted him to also offer repair services, but I can't figure out how to raise his repair skill (he's currently at zero) ... the editor is a bit wonkie about skills for some reason...

scn RobocycleScript

short bMenuUp
short iMenuButton
short bRecycleAll
short iCount
short iRequired
ref rItemList
ref rItem
ref rRecycled

begin OnAdd

        MessageBoxEx "Which Items Do You Wish To Recycle?| |Books|Metal Clutter|Wooden Clutter|Earthen Clutter|Toys|All Of These|None Of These"
        set bMenuUp to 1

end

begin GameMode

        if bMenuUp
                set iMenuButton to GetButtonPressed
                if iMenuButton > -1
                        if iMenuButton == 0
                        elseif iMenuButton == 7
                                set bMenuUp to 0
                                Return
                        else
                                if iMenuButton == 6
                                        set bRecycleAll to 1
                                        set iMenuButton to 1
                                endif
                                Label 2
                                if iMenuButton == 1
                                        set rItemList to RobocycleBookList
                                        set iRequired to 2
                                        set rRecycled to NVDLC03BlankBookMISC

                                elseif iMenuButton == 2
                                        set rItemList to RobocycleMetalList
                                        set iRequired to 15
                                        set rRecycled to SpareParts
                                elseif iMenuButton == 3
                                        set rItemList to RobocycleWoodList
                                        set iRequired to 10
                                        set rRecycled to NVDLC03SalientGreen
                                elseif iMenuButton == 4
                                        set rItemList to RobocycleEarthenList
                                        set iRequired to 5
                                        set rRecycled to AbraxoCleaner
                                elseif iMenuButton == 5
                                        set rItemList to RobocycleToyList
                                        set iRequired to 1
                                        set rRecycled to ScrapElectronics
                                endif
                                if player.GetItemCount rItemList >= iRequired
                                        ; Attempting to use an equal number of each compatible item, if possible.
                                        Label 1
                                        if iCount == 0
                                                set iCount to ListGetCount rItemList
                                        endif
                                        set iCount to iCount - 1
                                        set rItem to ListGetNthForm rItemList iCount
                                        if player.GetItemCount rItem
                                                player.RemoveItem rItem 1 1
                                                set iRequired to iRequired - 1
                                        endif
                                        if iRequired
                                                GoTo 1
                                        else
                                                set iCount to 0
                                        endif
                                        player.AddItem rRecycled 1 1
                                elseif bRecycleAll == 0
                                        MessageBoxEx "Not enough items to recycle."
                                        Return
                                endif
                                if bRecycleAll == 0
                                elseif iMenuButton < 5
                                        set iMenuButton to iMenuButton + 1
                                        GoTo 2
                                else
                                        set bRecycleAll to 0
                                endif
                        endif
                        MessageBoxEx "Which Items Do You Wish To Recycle?| |Books|Metal Clutter|Wooden Clutter|Earthen Clutter|Toys|All Of These|None Of These"
                endif
        else
                RemoveMe
        endif

end

Link to comment
Share on other sites

Glad to hear it works! :)

 

If I have an inventory full of junk, it only does one "recycle" exchange for every time I push a button (I had to hit "Books" 37 times to process all of the books). Is there a way to make it repeat the "recycle" action until it runs out of items in each category?
Yes, that was intentional. If you want my opinion - it's better this way, as it gives the player control over how many items are destroyed and recycled. Still, this is only how I, personally, would prefer it to be. It's your mod though, so it's entirely up to you. If you want, it can be made to recycle everything in one click.

 

On a different note, I wanted him to also offer repair services, but I can't figure out how to raise his repair skill (he's currently at zero) ... the editor is a bit wonkie about skills for some reason...
Hmm. I'm not quite sure what you mean. You set the repair skill (as any other skill) in the 'Stats' tab of the NPC. If that NPC uses a template, make sure 'Use Stats' is left unchecked, otherwise it will override any changes you've made manually.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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