Welcome to the Builder Academy

Question Saving object timer values to pfile with remote

More
20 Mar 2018 04:36 #7732 by hurin
So I am at a loss. I am trying to figure out a way to save timer values on an object to the player file using remote at multiple times to include when they rent out.

So I have an object that has a timer of 2000 tics, when you rent out and come back in the object reverts to the default timer in the object file. I can set the timer value to 0 in the object file and then when the item loads have an otimer trigger set the value to 2000. But then again when you rent and come back in the new timer value is 0.


Is this best done saving the unique id and the current timer to the player file throughout and when renting. Then when entering the game the object checks to reference that the pfile variable uniqueID matches its uniqueID and then pulls the timer value stored and uses otimer to set its new value?


My thought was to do something similar to the below. This would need to be a global random type trigger to ensure the most recent values are saved. Then again at rent. My problem is that the %self.id% changes when renting and coming back in. Ive tried multiple self.uniqueid or self.unique_id but none of them seem to return the unique id associated with the object. This value might be unique to the object files on our codebase, if so I will have to ask the coder.

eval oven_timer %self.timer%
eval oven_id %self.id%
global oven_timer
remote oven_id %actor.id%
remote oven_timer %actor.id%

Of course I will also have to ensure that when you give the object away it rdeletes the varialbles on the character file and then also to account for giving it away when it is in a container and renting with it in a container.

If anyone could offer insight or other stuff to consider that would be awesome, and the best way to do this using the eval/context/global/remote commands because I am totally not super good with all that.

Many Thanks - Hurin

Please Log in or Create an account to join the conversation.

More
20 Mar 2018 06:40 #7735 by thomas
The id is unique to that instance . Once you log out, the object is destroyed, and the id no longer exists.
So, this approach won't work.

I'll have to give it a little thought ☺

Please Log in or Create an account to join the conversation.

More
23 Mar 2018 05:35 - 23 Mar 2018 21:05 #7762 by hurin
Okay so after some changes to the script code self.Uniqueid returns the unique id that is assigned to an object upon creation. I'm still having trouble with this though so any help would be greatly appreciated.

stat of the character showing he has the variable with the objects unique id and the timer value
Global Variables:
381282685: 1949
(UniqueID) (timer)


eval temp %self.Uniqueid%
%echo% %temp%
if %actor.varexists(%temp%)%
%echo% %%actor.%temp%%% i should be echoing *** This is returning %actor.381282685% not the timer value
else
eval %self.Uniqueid% %self.timer%
global %self.Uniqueid%
remote %self.Uniqueid% %actor.id%
end

So I am missing how to pull the value(1969) from the variable stored in the pfile, what should i be doing?
Last edit: 23 Mar 2018 21:05 by hurin.

Please Log in or Create an account to join the conversation.

More
24 Mar 2018 01:41 #7779 by thomas
First, forget about using the unique id. It is a runtime-dependant number. It will not work across restarts.

Then, rethink the use case.

"As a player, I wish for the state of my objects to be consistent over logins and reboots"

I think perhaps adding saving and loading of vars remoted to the object is the most correct way of doing this.

Please Log in or Create an account to join the conversation.

More
24 Mar 2018 17:07 #7787 by cunning
Thomas,
The unique ID is not run time dependent, an object is tagged with the ID and when the player logs out it saved the uniqueID to the rent file. It does not change.

This is part of the DUPE code as part of Rasputin/Doom. We did this because of the propensity of ASCII rent files to duplicate on a crash. So All objects are tagged with a generation time and a Unique ID. These never change over the life of the object. They are always saved and remain upon login.

Just thought I would clear this up. I added to uniqueid as a variable under objects.

Please Log in or Create an account to join the conversation.

More
24 Mar 2018 20:09 #7789 by thomas
Ah. mistook it for the internal id...

Then, I'd add a lookup method (%actor.uniquieId(number)% ? %find_unique% number ? I digress), to make it possible to find objects by this number :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.229 seconds