Jump to content

Script Help


renogaz

Recommended Posts

All I know is my updates never worked till I pulled them out into their own function. Once I did that. My stuff worked.

 

Hmm...that doesn't make sense. Something odd is going on if you've had to do that. Registering for updates works fine from within events. Just look at any number of vanilla script that do the same.

 

EDIT: renogaz, here is your answer: "Once an object has been added to a container it is no longer valid to call functions on it. Functions on self will fail to run with an error." - from CK wiki.

 

So basically, calling OnUpdate() or OnUpdateGameTime() on an object in your inventory is simply not possible. You will have to figure out some sort of work-around, like using a quest, then setting a stage when the purse is picked up, and the stage would have a fragment that calls RegisterForSingleUpdateGameTime on the main quest script, which would hold the OnUpdateGameTime event.

Edited by steve40
Link to comment
Share on other sites

Hmm...that doesn't make sense. Something odd is going on if you've had to do that. Registering for updates works fine from within events. Just look at any number of vanilla script that do the same.

I think the 'odd' might be that my script was on a container whose interface object is able to be carried by the player. Since the interface object inherits the script (it was applied to the container but the object has it too in the CK), it might be that when the update register was written directly in the event's if statement it thought it was being applied to the object inside the player inventory and thus failing?

 

All I know is that it works... once a minute if carried crafting supplies are present they get auto-stored.

Link to comment
Share on other sites

Hmm...that doesn't make sense. Something odd is going on if you've had to do that. Registering for updates works fine from within events. Just look at any number of vanilla script that do the same.

I think the 'odd' might be that my script was on a container whose interface object is able to be carried by the player. Since the interface object inherits the script (it was applied to the container but the object has it too in the CK), it might be that when the update register was written directly in the event's if statement it thought it was being applied to the object inside the player inventory and thus failing?

 

All I know is that it works... once a minute if carried crafting supplies are present they get auto-stored.

 

If you placed the script on the container's form in the CK, that script will also be applied to the container's objectreference in-game. So, after the player picks up the container, the container is now inside a container (player's inventory) so again the script should fail (in theory) if you try to call functions on it. If you've found a suitable work-around, maybe you could add the example to the wiki.

Edited by steve40
Link to comment
Share on other sites

If you've found a suitable work-around, maybe you could add the example to the wiki.
Perhaps, but its still under testing and I need to make sure the mod uninstalls without leaving too much annoying crap in the save. i.e. I need to find a way to fully stop the update and unregister for it before the player removes the mod.
Link to comment
Share on other sites

If you've found a suitable work-around, maybe you could add the example to the wiki.
Perhaps, but its still under testing and I need to make sure the mod uninstalls without leaving too much annoying crap in the save. i.e. I need to find a way to fully stop the update and unregister for it before the player removes the mod.

 

 

on the official forums they helped me to do some scripts, heres what i did, hope it helps :)

 

 


Bool messageshown
bool dropable
ActorBase property gallina auto

Event OnContainerChanged (ObjectReference akNewContainer,  ObjectReference akOldContainer)
if dropable == true 
 if akOldContainer == Game.GetPlayer() && !akNewContainer
  Game.GetPlayer(). PlaceAtMe (gallina)
  Self.Delete()
 endif
elseif akNewContainer == Game.GetPlayer()
   Debug.MessageBox("You found a Good Chicken Egg!, this egg will hatch in 3 days!")
     if !messageshown
       messageshown = true
       Utility.WaitGameTime (72)
       Debug.MessageBox("The egg is hatching!")
       messageshown = false
       dropable = true
   endif
endif
endevent

 

What this basically does, is that in the event of the egg changin container will trigger a check for the variable "dropable" if its set to true will run another if statement to check if it was dropped, if it was dropped will t\spwn the chicken, BUT if dropable set to false will run the script Utility.WaitGameTime(x) wich will stop the script for a certain amount of time then it will keep running and then will set "dropable" true, annd then will run the first script :)

Link to comment
Share on other sites

Yes, but that is not the script that you were originally asking for help with.

Actually, I'm somewhat confused about the statement on the CK wiki that says you can't call functions on an object in a container. Why then do we have "OnContainerChanged()" and how come "OnUpdate()" worked in your original script? Obviously events DO continue to work on objects in a container. In the scope that the wiki uses the term "functions" it also means events. So then, why wasn't "OnUpdateGameTime()" firing if "OnUpdate()" clearly works. Seems very odd because the whole point of having a function like "RegisterForSingleUpdateGameTime()" is specifically to avoid having to use a long "wait()" or "waitgametime()" call, which is not the ideal thing to do :wallbash:

Edited by steve40
Link to comment
Share on other sites

Yes, but that is not the script that you were originally asking for help with.

Actually, I'm somewhat confused about the statement on the CK wiki that says you can't call functions on an object in a container. Why then do we have "OnContainerChanged()" and how come "OnUpdate()" worked in your original script? Obviously events DO continue to work on objects in a container. In the scope that the wiki uses the term "functions" it also means events. So then, why wasn't "OnUpdateGameTime()" firing if "OnUpdate()" clearly works. Seems very odd because the whole point of having a function like "RegisterForSingleUpdateGameTime()" is specifically to avoid having to use a long "wait()" or "waitgametime()" call, which is not the ideal thing to do :wallbash:

 

 

nott pretty sure but it worked so far so im happy with that :) but i just messed something else up....again....trying to make a quest wheere i need to get a chicken egg(ingridient vanilla one) to exchange it for a hatchable one, and then a quest to tell me to wait for 3 days to let it hatch and when i talk to the chicken i finish the quest, and i got it almost working, but cant remember how many changes i did that i just broke it :/ anyone wanna hel-p me out with the mod? not just script help and such, but be my partner in the proyect?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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