How to store info inside objects?

Post » Mon Jun 18, 2012 1:44 pm

Hi, anyone know how to store custom informations (a variable or a pointer to an object) inside a reference of an object, that can be SET and GET by a papyrus script?
For example an Hungry level on the player, or an HP on an item.
Eventually it is possible to use Gobal variables?
User avatar
Lori Joe
 
Posts: 3539
Joined: Tue Jun 20, 2006 6:10 am

Post » Mon Jun 18, 2012 5:13 am

Could http://www.creationkit.com/GlobalVariable_Script be what you're looking for?
User avatar
rae.x
 
Posts: 3326
Joined: Wed Jun 14, 2006 2:13 pm

Post » Mon Jun 18, 2012 8:50 am

Scripts can use variables, which do a good job at storing informations.

If you must: http://www.creationkit.com/Globals
User avatar
Bitter End
 
Posts: 3418
Joined: Fri Sep 08, 2006 11:40 am

Post » Mon Jun 18, 2012 6:33 pm

Thanks! Now i know where to store global information :)

About local info, variables in script can be manipulated internally, but if i need to access or modify them for an external source, i think i need SET/GET methods.
Inside the "Papyrus manager" i found scripts named like "armor" or "weapon". If i modify them, adding properties and functions to manage them, i'll brake the game or they are just not used by the game?
User avatar
Lloyd Muldowney
 
Posts: 3497
Joined: Wed May 23, 2007 2:08 pm

Post » Mon Jun 18, 2012 4:01 am

Yeah, don't mess with those. Pretty sure they're related to how scripts recognize forms or some such thing.
User avatar
Calum Campbell
 
Posts: 3574
Joined: Tue Jul 10, 2007 7:55 am

Post » Mon Jun 18, 2012 4:22 am

Ok, it's better to leave them alone :biggrin:

I've another idea: when the game creates a reference of an obj, it creates also a reference of the assigned scripts (and its properties)? If "yes", how i point to the referenced script's properties?
If it works, i can create an Extended version of original scripts :smile:
User avatar
KiiSsez jdgaf Benzler
 
Posts: 3546
Joined: Fri Mar 16, 2007 7:10 am

Post » Mon Jun 18, 2012 10:37 am

Perhaps http://www.creationkit.com/Extending_Scripts_(Papyrus) is what you need?

It works with properties/functions, but not variables.

Unless you meant where if you had two objects with the same script, could you access the variables in one from the other? Which as far as I can tell, is impossible., as variables are entirely private.
User avatar
ONLY ME!!!!
 
Posts: 3479
Joined: Tue Aug 28, 2007 12:16 pm

Post » Mon Jun 18, 2012 5:03 am

Unless you meant where if you had two objects with the same script, could you access the variables in one from the other? Which as far as I can tell, is impossible., as variables are entirely private.

Not exaclty, i meant if two references of the same base object with an assigned script, have also referenced properties, so another script can access and modify (by get/set functions) the referenced properties (not the variables) and not the base object's ones.

Two other questions:
1- To create a global variable there is a menu in the CK that i didn't see, or the first time u declare it in a script, it will be globally created?
2- How do u point the object to which is assigned the current script? can't find the function

Thanks for patience, i'm trying to better understand the CK ;) (and i'm a little rusted on ObjOriented programming)
User avatar
Jack Bryan
 
Posts: 3449
Joined: Wed May 16, 2007 2:31 am

Post » Mon Jun 18, 2012 11:03 am

2: "self" variable
User avatar
Samantha Wood
 
Posts: 3286
Joined: Sun Oct 15, 2006 5:03 am

Post » Mon Jun 18, 2012 9:09 am

i thought that "self" was the script himself. So if i create a script like
Scriptname ActorExt extends Actorint property Asd autoFunction Blabla()....EndFunction
and i assign it to an actor, i've extended the actor with "Blabla" function and "Asd" property.

I'll try tomorrow, it's midnight here :D
User avatar
Leonie Connor
 
Posts: 3434
Joined: Mon Mar 12, 2007 4:18 pm

Post » Mon Jun 18, 2012 3:50 am

I believe Papyrus doesn't differentiate between the "script itself" and the "object it is assigned to".
They are one and the same.

Could be wrong though ... but I've used the "self" variable to apply physics to an activator, so it definitely points to the object.
User avatar
YO MAma
 
Posts: 3321
Joined: Thu Dec 21, 2006 8:24 am


Return to V - Skyrim