Really frustrated over sharing properties between scripts

Post » Tue Jun 19, 2012 7:22 am

I've been banging my head against my keyboard for like 3 hours now, anyone who can help would be a saving grace. (I even used the official wiki's stuff and it didn't work)

Script 1:


Scriptname CheckStuff extends Actor

int property SpellAttack = 0 auto


Script 2:


Scriptname MagicStuff extends ActiveMagicEffect

CheckStuff Property PlayerSpellAttack auto

Int testing = 20

Event OnEffectStart(Actor Target, Actor Caster)
;When caster hits a target

debug.MessageBox(testing)

PlayerSpellAttack.SpellAttack = 300
testing = PlayerSpellAttack.SpellAttack
debug.MessageBox(testing)

EndEvent

This returns a 20 the first time, and then a 0 the second time instead of 300 which I would have expected. What am I missing or forgetting to include to share the variable of script 1 with script 2?

Bonus question: Anyone know why I cant use Debug.Messagebox if I call a function in Script 1 from Script 2. It will only appear in game if it's called and located in Script 2(The one with the event).
User avatar
Jason King
 
Posts: 3382
Joined: Tue Jul 17, 2007 2:05 pm

Post » Tue Jun 19, 2012 3:02 am

What happens if you change the property to this?
int Property SpellAttach = 0	Function Set(int value)		SpellAttach = value		Debug.Trace("Set SpellAttach to " + value)	EndFunction	int Function Get()		Debug.Trace("Get SpellAttach: " + SpellAttach)		Return SpellAttach	EndFunctionEndProperty

Cipscis
User avatar
QuinDINGDONGcey
 
Posts: 3369
Joined: Mon Jul 23, 2007 4:11 pm

Post » Tue Jun 19, 2012 3:15 pm

If I do this then it compiles fine for script 1, but script 2 tells me that "int is not a user-defined type"
User avatar
Marcus Jordan
 
Posts: 3474
Joined: Fri Jun 29, 2007 1:16 am

Post » Tue Jun 19, 2012 2:14 pm

Even though your second script is using the exact same code as before? I haven't seen that error before, could you post the entire script and the entire compiler error so I can use the line and character number information?

Cipscis
User avatar
Nana Samboy
 
Posts: 3424
Joined: Thu Sep 14, 2006 4:29 pm

Post » Tue Jun 19, 2012 4:54 am

I'm really sorry, this seems to be giving me even more headache now and I can't get back to where I had the "Int user defined error"

Fyi: The above error happened when I had it without auto previously and it threw that error at both the set and get calls.

Using the code you gave me(I assume to just get rid of "auto" it now gives me
"c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CheckSneak.psc(3,33): no viable alternative at input '\\r\\n'
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CheckSneak.psc(10,0): missing EOF at 'EndProperty'
No output generated for CheckSneak, compilation failed."

For this code:


Scriptname CheckSneak extends Actor

int Property SpellSneakAttack = 0
int Function Get()
Return SpellSneakAttack
endFunction
Function Set(int value)
SpellSneakAttack = value
EndFunction
EndProperty
User avatar
Guinevere Wood
 
Posts: 3368
Joined: Mon Dec 04, 2006 3:06 pm

Post » Tue Jun 19, 2012 7:59 am

I've went back to the auto one since it doesn't throw errors but I still have the same issue as before and I cant share the variable from script 1 with script 2.

1:


Scriptname CheckSneak extends Actor

int Property SpellSneakAttack = 0 auto

Function CheckSneakSpell(Actor akCaster)

EndFunction

2:


Scriptname MagicSneak extends ActiveMagicEffect

Import CheckSneak
CheckSneak Property PlayerSpellSneak auto


Int testing = 20

Event OnEffectStart(Actor Target, Actor Caster)
;When caster hits a target

;debug.MessageBox(Target + " " + Caster) ;Show Target
debug.MessageBox(testing)
PlayerSpellSneak.SpellSneakAttack = 300
testing = PlayerSpellSneak.SpellSneakAttack
debug.MessageBox(testing)

EndEvent
User avatar
kyle pinchen
 
Posts: 3475
Joined: Thu May 17, 2007 9:01 pm

Post » Tue Jun 19, 2012 8:35 am

Oh, it appears non-auto functions can't be initialised in the same way as auto functions. The following should compile:
int Property SpellAttach	Function Set(int value)		SpellAttach = value		Debug.Trace("Set SpellAttach to " + value)	EndFunction	int Function Get()		Debug.Trace("Get SpellAttach: " + SpellAttach)		Return SpellAttach	EndFunctionEndProperty

If you want to use an initialisation as well, then create an "int" variable, initialise it, and define your properties "Get" and "Set" functions to manipulate the variable rather than the property.

Cipscis
User avatar
sw1ss
 
Posts: 3461
Joined: Wed Nov 28, 2007 8:02 pm

Post » Tue Jun 19, 2012 12:23 pm

Okay, so now we are back to "Int is not a known user defined" here are my scripts:

Script 1: (Not throwing errors)

Scriptname CheckSneak extends Actor

int Property SneakSpellAttack
Function Set(int value)
SneakSpellAttack = value
Debug.Trace("Set SpellAttack to " + value)
EndFunction
int Function Get()
Debug.Trace("Get SpellAttack: " + SneakSpellAttack)
Return SneakSpellAttack
EndFunction
EndProperty

Script 2:


Scriptname MagicSneak extends ActiveMagicEffect

CheckSneak Property PlayerSpellSneak auto

Int testing = 20

Event OnEffectStart(Actor Target, Actor Caster)
;When caster hits a target

;debug.MessageBox(Target + " " + Caster) ;Show Target
debug.MessageBox(testing)
PlayerSpellSneak.SpellSneakAttack.set(300)
testing = PlayerSpellSneak.SpellSneakAttack.get()
debug.MessageBox(testing)

EndEvent

Errors:Starting 1 compile threads for 1 files...
Compiling "MagicSneak"...
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\MagicSneak.psc(12,35): int is not a known user-defined type
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\MagicSneak.psc(13,45): int is not a known user-defined type
c:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\MagicSneak.psc(13,1): type mismatch while assigning to a int (cast missing or types unrelated)
No output generated for MagicSneak, compilation failed.
User avatar
Michelle Smith
 
Posts: 3417
Joined: Wed Nov 15, 2006 2:03 am

Post » Tue Jun 19, 2012 1:04 pm

You don't call the "Set" and "Get" functions manually - just treat your property exactly the same as before, when it was an auto property.

Cipscis
User avatar
Rude_Bitch_420
 
Posts: 3429
Joined: Wed Aug 08, 2007 2:26 pm

Post » Tue Jun 19, 2012 11:01 am

Interesting, now that I'm treating it like an auto it does compile and run but alas the second message box is still returning a 0 instead of a 300 which brings me full circle. I really appreciate your help thus far. I just cant understand why the variable isn't being set with testing = PlayerSpellSneak.SpellSneakAttack.get().
This is becoming really frustrating and I don't know what I'm doing wrong. Is it possible Messagebox isn't showing the value correctly(longshot)? How could I easily test it without using them?
User avatar
Tamara Dost
 
Posts: 3445
Joined: Mon Mar 12, 2007 12:20 pm

Post » Tue Jun 19, 2012 3:58 am

The "Get" and "Set" functions that are part of a property aren't like regular functions. They're special functions that allow you to define the behaviour when you assign a new value to a property, and when you get the property's value. Instead of being called directly, those names are only used in their definitions.

Did you include those http://www.creationkit.com/Trace_-_Debug function calls that I had in my example? The main point of that was that I'm interested in seeing what the output shows.

Cipscis
User avatar
Jeff Turner
 
Posts: 3458
Joined: Tue Sep 04, 2007 5:35 pm

Post » Tue Jun 19, 2012 4:31 am

I did include them but for whatever reason I've never figured out how to enable/use them which is why I always ended up using Messageboxes instead.
User avatar
Harinder Ghag
 
Posts: 3405
Joined: Wed Jan 17, 2007 11:26 am

Post » Tue Jun 19, 2012 5:54 am

The stickied "http://www.gamesas.com/topic/1345130-having-papyrus-trouble-here-are-some-things-to-try/" thread has information on enabling debugging.

Cipscis

EDIT:

While we're talking about stickied threads, have a look at the "http://www.gamesas.com/topic/1347469-how-to-ask-for-scripting-help/" one too. It tells you how you can post scripts in a form that preserves indenting and uses a fixed-width font, which makes them much easier to read.

Cipscis
User avatar
Del Arte
 
Posts: 3543
Joined: Tue Aug 01, 2006 8:40 pm

Post » Tue Jun 19, 2012 10:01 am

Okay so, I get that I'm supposed to make/edit a .ini file somewhere but the wiki entry doesn't say what to name it or what it's name is. I tried making Skyrimcustom.ini as suggested by someone else but it didn't work, what am I doing wrong? How can I get this working?
User avatar
Skrapp Stephens
 
Posts: 3350
Joined: Mon Aug 06, 2007 5:04 am

Post » Tue Jun 19, 2012 4:21 pm

You can find that ini file under "My Documents/My Games/Skyrim".

Cipscis
User avatar
naomi
 
Posts: 3400
Joined: Tue Jul 11, 2006 2:58 pm

Post » Tue Jun 19, 2012 10:19 am

"That ini" being Skyrim.ini or Skyrimcustom.ini? Both of them have the papyrus section in them fully enabled and I do not yet have a folder being created to put my logs into as the wiki suggests. I have restarted skyrim 4 times now to no avail. Starting to feel a little dumb.
User avatar
meghan lock
 
Posts: 3451
Joined: Thu Jan 11, 2007 10:26 pm

Post » Tue Jun 19, 2012 9:07 am

I think, from memory, the file you want to edit is "My Documents\My Games\Skyrim\SkyrimPrefs.ini".

Cipscis
User avatar
Romy Welsch
 
Posts: 3329
Joined: Wed Apr 25, 2007 10:36 pm

Post » Tue Jun 19, 2012 2:55 pm

Here's the logs you requested
Spoiler
[02/23/2012 - 06:38:29PM] Papyrus log opened (PC)[02/23/2012 - 06:38:29PM] Update budget: 1.200000ms (Extra tasklet budget: 1.200000ms, Load screen budget: 500.000000ms)[02/23/2012 - 06:38:29PM] Memory page: 128 (min) 512 (max) 76800 (max total)[02/23/2012 - 06:38:46PM] PATCH 1.4 QUEST HAS STARTED[02/23/2012 - 06:38:47PM] [default2StateActivator < (02007BB0)>] Enabling Collision[02/23/2012 - 06:38:47PM] DARYL - [WeaponRackActivateSCRIPT < (02007936)>] running OnCellLoad() and AlreadyInit = False[02/23/2012 - 06:38:47PM] DARYL - [WeaponRackActivateSCRIPT < (02007936)>] The TriggerMarker is [WeaponRackTriggerSCRIPT < (02007937)>][02/23/2012 - 06:38:47PM] Patch Script is working[02/23/2012 - 06:38:47PM] DARYL - [WeaponRackActivateSCRIPT < (02007936)>] The Starting Weapon is [ObjectReference < (0200792F)>][02/23/2012 - 06:38:47PM] DARYL - [WeaponRackActivateSCRIPT < (02007936)>] Has a starting weapon[02/23/2012 - 06:38:47PM] DARYL - [WeaponRackActivateSCRIPT < (02007936)>] Handling Starting Weapon[02/23/2012 - 06:38:47PM] DARYL - [WeaponRackActivateSCRIPT < (02007936)>] Disabling physics on [ObjectReference < (0200792F)>][02/23/2012 - 06:38:47PM] DARYL - [WeaponRackActivateSCRIPT < (02007936)>] Moving 0 to the BattleaxeMarker[02/23/2012 - 06:38:47PM] DARYL - [WeaponRackActivateSCRIPT < (02007936)>] finishing OnCellLoad() and AlreadyInit = TRUE[02/23/2012 - 06:39:06PM] error: Unable to bind script CheckSneak to Active effect 1 on  (02007BAB) because their base types do not match[02/23/2012 - 06:39:06PM] error: Cannot call SpellSneakAttack() on a None object, aborting function callstack:[Active effect 1 on  (02007BAB)].MagicSneak.OnEffectStart() - "MagicSneak.psc" Line 12[02/23/2012 - 06:39:06PM] error: Cannot call SpellSneakAttack() on a None object, aborting function callstack:[Active effect 1 on  (02007BAB)].MagicSneak.OnEffectStart() - "MagicSneak.psc" Line 13[02/23/2012 - 06:39:06PM] warning: Assigning None to a non-object variable named "::temp0"stack:[Active effect 1 on  (02007BAB)].MagicSneak.OnEffectStart() - "MagicSneak.psc" Line 13[02/23/2012 - 06:39:08PM] error: Unable to bind script CheckSneak to Active effect 1 on  (02007BAB) because their base types do not match[02/23/2012 - 06:39:08PM] error: Cannot call SpellSneakAttack() on a None object, aborting function callstack:[Active effect 1 on  (02007BAB)].MagicSneak.OnEffectStart() - "MagicSneak.psc" Line 12[02/23/2012 - 06:39:08PM] error: Cannot call SpellSneakAttack() on a None object, aborting function callstack:[Active effect 1 on  (02007BAB)].MagicSneak.OnEffectStart() - "MagicSneak.psc" Line 13

and repeats the last 3 for what I assume is every spellcast I did.
User avatar
Kellymarie Heppell
 
Posts: 3456
Joined: Mon Jul 24, 2006 4:37 am

Post » Tue Jun 19, 2012 2:17 pm

"Cannot call SpellSneakAttack() on a None object, aborting function call" makes it sound to me like you haven't associated your property with an object in the Creation Kit. Are you sure you've set up your property correctly?

Cipscis
User avatar
Kerri Lee
 
Posts: 3404
Joined: Sun Feb 25, 2007 9:37 pm

Post » Tue Jun 19, 2012 6:31 am

Currently I have both scripts running on a spell effect, in this case FireDamageFFAimed. I guess I see where the conflict would be since CheckSneak wants to be on an actor. The idea I had before would be to make spells be able to sneak attack by checking on a spells hit wether the player is sneaking and undetected. How would I associate CheckSneak with the player(Is that even possible?)?

Upon making CheckSneak also an activemagic effect the error is still occuring. Any suggestions as to what I'm forgetting?
User avatar
Latisha Fry
 
Posts: 3399
Joined: Sat Jun 24, 2006 6:42 am

Post » Tue Jun 19, 2012 3:37 am

I'm not sure what you mean... The Creation Kit won't allow you to attach a script extending http://www.creationkit.com/Actor_Script to an object of type http://www.creationkit.com/ActiveMagicEffect.

I'll ask again, are your properties set up correctly in the Creation Kit? The error log makes it seem to me that you haven't specified a value, so you're trying to use None as though it were an actual object, and that's why this isn't working.

It's possible to attach scripts to the player, but generally a bad idea as it destroys compatibility and there's an entirely compatible way to do it. You'll want to make a quest with an alias the points to the player, and attach a script that extends http://www.creationkit.com/ReferenceAlias_Script to that alias.

Cipscis
User avatar
Cathrin Hummel
 
Posts: 3399
Joined: Mon Apr 16, 2007 7:16 pm

Post » Tue Jun 19, 2012 11:04 am

I suppose that's my problem then, I'll do more research on this. Thank you for your help and patience. I still do not fully understand how not setting up a property would interact with the variables it holds but that's probably because I'm still learning the engine. Thank you again.

Edit: Do you have any examples of someone doing what you said above that I can use to learn? I love the creation kit but I really wish there was a book instead of a wiki.
User avatar
Quick Draw III
 
Posts: 3372
Joined: Sat Oct 20, 2007 6:27 am


Return to V - Skyrim