Jump to content

Need help, button that moves object.


Recommended Posts

Hi all,

 

I need help with CK. I wanna put multiple buttons (for example 4) in my Player Home Mod and

which button the player push the workshop workbench moves to (a specific xmarker) that position.

So the player can chose from 4 locations to move there workshop workbench.

*to be clear i do not want to spawn a workshop workbench

just change the position of the existed one.

 

and one short question besides my original question :

i was looking for a activator that lets a object rotate when i push a button something like "platformhelperfree01". but than with rotation

i find this "RotateHelperFree" but don't know how to make it work.

 

 

I hope there is a simple way for it cuz i'm not a pro in modding. I would appreciate your help guys :smile:

Edited by H3S
Link to comment
Share on other sites

Ok :smile: finaly it works like how it should be with this script:

Scriptname DCF_ObjectMoveToScript extends ObjectReference

;properties
ObjectReference Property XMarker Auto Const
ObjectReference Property workshopnewloc Auto Const

;events
Event OnActivate(ObjectReference akActionRef)
	workshopnewloc .MoveTo(XMarker )
	Debug.Notification("Wotkbench is moved")
EndEvent

now only one thing i want is that after the workbench is moved and i push the same button again there must be a different Notification message (for example "Workbench is already moved")

anyone who knows which line i must put in the script ?

Link to comment
Share on other sites

There are several ways. E.g.:

 

A. You can add a custom keyword to already moved workshops, with addKeyword, Then test if your reference has that HasKeyword().

 

B. Make your workshop mover is a one-time thing that you build, push the button, and then it's gone. To prevent the user from clicking half a dozen time before the script finishes anyway, you can just use states (see the tutorial on Beth's site) or just have a "bool alreadyMoved" variable below the properties.

 

C. If there's only one mover, you can have an "ObjectReference[] alreadyMovedWorkshops" array as a variable, and just add already moved workshops to it. It even has a function to check if an array contains a specific object, so basically you don't even have to iterate through the array yourself.

 

D. Use a custom FormList as a to your script property, that starts empty. Then just add the workshop to it when you move it. Since it's a global thing, it gets shared even among multiple buttons,

 

Etc.

 

Personally I'd use the keyword, but otherwise it's up to you.

Link to comment
Share on other sites

There are several ways. E.g.:

 

A. You can add a custom keyword to already moved workshops, with addKeyword, Then test if your reference has that HasKeyword().

 

B. Make your workshop mover is a one-time thing that you build, push the button, and then it's gone. To prevent the user from clicking half a dozen time before the script finishes anyway, you can just use states (see the tutorial on Beth's site) or just have a "bool alreadyMoved" variable below the properties.

 

C. If there's only one mover, you can have an "ObjectReference[] alreadyMovedWorkshops" array as a variable, and just add already moved workshops to it. It even has a function to check if an array contains a specific object, so basically you don't even have to iterate through the array yourself.

 

D. Use a custom FormList as a to your script property, that starts empty. Then just add the workshop to it when you move it. Since it's a global thing, it gets shared even among multiple buttons,

 

Etc.

 

Personally I'd use the keyword, but otherwise it's up to you.

 

thnx for your reply ,

i have multiple buttons (movers) and they are not craftable there just in the cell .

Can you please give the line of script or explain me the simple method

i'm confused about which method and how i must use i would really appreciate it.

Link to comment
Share on other sites

Well, then it's like this:

 

Define a keyword in the CK. Say, "WorkshopAlreadyMovedKeyword".

 

Make it a property in your script, say, by the same name. Easiest to make and initialize is to just use the "Create using form" option.

 

In your onActivate function have an "if workshopnewloc.HasKeyword(WorkshopAlreadyMovedKeyword)", and your "MoveTo" in the "Else" part of it.

 

Also do a "workshopnewloc.AddKeyword(WorkshopAlreadyMovedKeyword)" after you moved it.

 

 

On a complete tangent, if you want to actually show the user a message, Debug.Notification is not how you do it. Because if the user didn't activate debug logging, they'll never see the message. Use .show() on your own actual Message object, if you want most users to actually see it.

 

Of course, if it IS just debugging, and you couldn't care less about the user seeing or not seeing it, then, yeah, the Debug script is just right.

Link to comment
Share on other sites

Well, then it's like this:

 

Define a keyword in the CK. Say, "WorkshopAlreadyMovedKeyword".

 

Make it a property in your script, say, by the same name. Easiest to make and initialize is to just use the "Create using form" option.

 

In your onActivate function have an "if workshopnewloc.HasKeyword(WorkshopAlreadyMovedKeyword)", and your "MoveTo" in the "Else" part of it.

 

Also do a "workshopnewloc.AddKeyword(WorkshopAlreadyMovedKeyword)" after you moved it.

 

 

On a complete tangent, if you want to actually show the user a message, Debug.Notification is not how you do it. Because if the user didn't activate debug logging, they'll never see the message. Use .show() on your own actual Message object, if you want most users to actually see it.

 

Of course, if it IS just debugging, and you couldn't care less about the user seeing or not seeing it, then, yeah, the Debug script is just right.

i follow all the steps but the message still shows after it moved

maybe xuz i didn't know what you mean by "Also do a "workshopnewloc.AddKeyword(WorkshopAlreadyMovedKeyword)" after you moved it." ?everything was clear only this one i don't understand :confused:

this is what i have :

Scriptname DCF_ObjectMoveToScript extends ObjectReference

;properties
ObjectReference Property XMarker Auto Const
ObjectReference Property workshopnewloc Auto Const
Keyword Property pDCF_WorkshopAlreadyMovedKeyword Auto Const Mandatory

;events
Event OnActivate(ObjectReference akActionRef)

	debug.notification("Workbench is moved")
	if workshopnewloc.HasKeyword(pDCF_WorkshopAlreadyMovedKeyword)
	else
	workshopnewloc .MoveTo(XMarker )
	workshopnewloc.AddKeyword(pDCF_WorkshopAlreadyMovedKeyword)
   EndIf

EndEvent


Link to comment
Share on other sites

You're still seeing the notification, because it's outside the if block. So basically regardless of whether the workshop already got moved or not, you're displaying the message anyway. If you want it to be displayed only when you can move the workshop, the move it into the else block.
Link to comment
Share on other sites

You're still seeing the notification, because it's outside the if block. So basically regardless of whether the workshop already got moved or not, you're displaying the message anyway. If you want it to be displayed only when you can move the workshop, the move it into the else block.

So i did that and its working now the two messages are showing correctly only one thing is not working correctly .(with one button it's working fine)

 

so i have 2 buttons and 2 xmarkers and 1 wsworkbench .

When i push b1 it moves wsworkbench to x1 and shows the message "Workbench is moved".

When i push again b1 it shows the message "Workbench is already moved".

When i push b2 it moves wsworkbench to x2 and shows the message "Workbench is moved".

When i push again b2 it shows the message "Workbench is already moved".

So far good but now ...

When i push b1 again it is not moving the wsworkbench to x1 and it still shows the message "Workbench is already moved" instead of "Workbench is moved". :confused:

It seems like it's doing the hole process only one time . Where is the problem can someone help me please ?

I was thinking about making separated script for each button ,

didn't try it yet is that a option or is there a way to fix it in one script btw this is my script so far :

Scriptname DCF_ObjectMoveToScript extends ObjectReference

;properties
ObjectReference Property XMarker Auto Const
ObjectReference Property workshopnewloc Auto Const
Keyword Property DCF_WorkshopAlreadyMovedKeyword Auto Const Mandatory

;events
Event OnActivate(ObjectReference akActionRef)
	if workshopnewloc.HasKeyword(DCF_WorkshopAlreadyMovedKeyword)
	debug.notification("Workbench is already moved")
	else
	workshopnewloc .MoveTo(XMarker )
	workshopnewloc.AddKeyword(DCF_WorkshopAlreadyMovedKeyword)
	debug.notification("Workbench is moved")
   EndIf

EndEvent
Edited by H3S
Link to comment
Share on other sites

Actually, the only thing that surprises me is that b2 works at all, after you already set the keyword with b1. Unless you use a different keyword for each button, I guess.

 

In any case, look, putting a keyword on a form is like sticking a post-it to the fridge. Unless you remove it, it stays there. Next time you look at whether you have a post-it on the fridge, surprise, you still do.

 

At this point I think it helps more if you state your scenario clearly, because otherwise you're likely to find out again that the part you never mentioned, surprise, wasn't included in the solution.

 

But anyway... if your test is really whether the workshop is already at a certain marker, as opposed to whether it's been ever moved, why not just test the distance to the marker? Seems like the most obvious condition to test for, innit?

 

https://www.creationkit.com/fallout4/index.php?title=GetDistance_-_ObjectReference&redirect=no

Link to comment
Share on other sites

Actually, the only thing that surprises me is that b2 works at all, after you already set the keyword with b1. Unless you use a different keyword for each button, I guess.

 

In any case, look, putting a keyword on a form is like sticking a post-it to the fridge. Unless you remove it, it stays there. Next time you look at whether you have a post-it on the fridge, surprise, you still do.

 

At this point I think it helps more if you state your scenario clearly, because otherwise you're likely to find out again that the part you never mentioned, surprise, wasn't included in the solution.

 

But anyway... if your test is really whether the workshop is already at a certain marker, as opposed to whether it's been ever moved, why not just test the distance to the marker? Seems like the most obvious condition to test for, innit?

 

https://www.creationkit.com/fallout4/index.php?title=GetDistance_-_ObjectReference&redirect=no

i checked the link but don't really understand it but find something with ___RemoveKeyword() (maybe not the best way but it's the closest i get).

so now it's working like how i want it to work only i must push twice if i wanna place the wsworkbench .

Didn't know how to fix that so i changed the message "Workbench is already moved" in to "Push again to move it".

Updated script :

Scriptname DCF_ObjectMoveToScript extends ObjectReference

;properties
ObjectReference Property XMarker Auto Const
ObjectReference Property workshopnewloc Auto Const
Keyword Property DCF_WorkshopAlreadyMovedKeyword Auto Const Mandatory

;events
Event OnActivate(ObjectReference akActionRef)
	if workshopnewloc.HasKeyword(DCF_WorkshopAlreadyMovedKeyword)
	debug.notification("Push again to move it")
	workshopnewloc .RemoveKeyword(DCF_WorkshopAlreadyMovedKeyword)
	else
	workshopnewloc .MoveTo(XMarker)
	workshopnewloc.AddKeyword(DCF_WorkshopAlreadyMovedKeyword)
	debug.notification("It is moved")
   EndIf

EndEvent

I saw something with event state here https://www.creationkit.com/fallout4/index.php?title=States_(Papyrus) i thought maybe can do something to bring

the event to his default state but was to difficult for me so i am pleased with this result i guess :happy:

I wanna thnx you for your time and patience . You helped me well so thnx again and Have a nice day :thumbsup:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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