Okay so, not sure what I'm doing. (Papyrus)

Post » Tue Jun 19, 2012 2:43 am

I am currently trying to write a simple Papyrus fragment for a dialogue event; However, I keep getting an error that I can't figure out. I haven't worked with any of Bethesda's old scripting languages, but I am pretty familiar with coding logic (having coded in Basic, C++ and GML, and UnrealSc.). I know what I want to do is simple from a code persepective, but I must be doing something wrong, because every time I try to compile a simple script, I get this error:

"\TIF__01002F00.psc(11,6): no viable alternative at input '\\r\\n"


The code I'm trying to compile is :


If (GetPCIsRace() == RedguardRace || GetPCIsRace() == BretonRace || GetPCIsRace() == NordRace || GetPCIsRace() == ImperialRace)
Game.GetPlayer().AddItem(MOD1SecretInvitationHU)
ElseIf
EndIf




Any help is appreciated.
User avatar
Danii Brown
 
Posts: 3337
Joined: Tue Aug 22, 2006 7:13 am

Post » Tue Jun 19, 2012 8:10 am

You have nothing after ElseIf. If you use Elseif you need a condition.

If (GetPCIsRace() == RedguardRace || GetPCIsRace() == BretonRace || GetPCIsRace() == NordRace || GetPCIsRace() == ImperialRace)	 Game.GetPlayer().AddItem(MOD1SecretInvitationHU)EndIf

or

If (GetPCIsRace() == BretonRace || GetPCIsRace() == NordRace || GetPCIsRace() == ImperialRace)	 Game.GetPlayer().AddItem(MOD1SecretInvitationHU)ElseIf (GetPCIsRace() == RedguardRace)     Game.GetPlayer().AddItem(MOD2SecretInvitationHU)EndIf
User avatar
Nuno Castro
 
Posts: 3414
Joined: Sat Oct 13, 2007 1:40 am

Post » Mon Jun 18, 2012 8:28 pm

Ok, so that fixed my initial error, but now I have two new errors (about) for every race listed. My first instinct is to use a property, but the CK isn't letting me declare a race property for my script.

My Code:

If (GetPCIsRace() == RedguardRace || GetPCIsRace() == BretonRace || GetPCIsRace() == NordRace || GetPCIsRace() == ImperialRace)	Game.GetPlayer().AddItem(MOD1SecretInvitationHU)EndIf


Errors:
script property ImperialRace already defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(30,14): script variable ::ImperialRace_var already defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(30,14): script property ImperialRace already has a get function defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(30,14): script property ImperialRace already has a set function defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(32,14): script property ImperialRace already defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(32,14): script variable ::ImperialRace_var already defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(32,14): script property ImperialRace already has a get function defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(32,14): script property ImperialRace already has a set function defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(36,14): script property NordRace already defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(36,14): script variable ::NordRace_var already defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(36,14): script property NordRace already has a get function defined
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01002F00.psc(36,14): script property NordRace already has a set function defined
User avatar
Rachael
 
Posts: 3412
Joined: Sat Feb 17, 2007 2:10 pm

Post » Tue Jun 19, 2012 6:40 am

Ok, first of, read http://www.gamesas.com/topic/1347469-how-to-ask-for-scripting-help/. Next, can I see the whole script?
User avatar
mollypop
 
Posts: 3420
Joined: Fri Jan 05, 2007 1:47 am

Post » Mon Jun 18, 2012 11:38 pm

Ok, first of, read http://www.gamesas.com/topic/1347469-how-to-ask-for-scripting-help/. Next, can I see the whole script?

That is the whole script. That is so far. I was going to finish writing the script once I got the simple part to work.


The final script should looks something like:

If (GetPCIsRace() == RedguardRace || GetPCIsRace() == BretonRace || GetPCIsRace() == NordRace || GetPCIsRace() == ImperialRace)		Game.GetPlayer().AddItem(MOD1SecretInvitationHU)ElseIf (GetPCIsRace() == HighElfRace || GetPCIsRace() == WoodElfRace || GetPCIsRace() == DarkElfRace)		Game.GetPlayer().AddItem(MOD1SecretInvitationElv)ElseIf (GetPCIsRace() == ArgonianRace)		Game.GetPlayer().AddItem(MOD1SecretInvitationAr)ElseIf (GetPCIsRace() == KhajiitRace)		Game.GetPlayer().AddItem(MOD1SecretInvitationKj)EndIf


But Like I said, what's was already posted is the only code I have so far.
User avatar
BEl J
 
Posts: 3397
Joined: Tue Feb 13, 2007 8:12 am

Post » Tue Jun 19, 2012 4:08 am

looking at the errors your getting, that cannot be 'everything' that is in your script.
Your missing the definitions, the scriptname, the event, the functions... There must be more to your script.
User avatar
Ash
 
Posts: 3392
Joined: Tue Jun 13, 2006 8:59 am

Post » Tue Jun 19, 2012 4:50 am

looking at the errors your getting, that cannot be 'everything' that is in your script.
Your missing the definitions, the scriptname, the event, the functions... There must be more to your script.

I'm copying and pasting directly from editor.

OH... Wait.. My fault. I'm copying the fragment. You guys need the source. 1 Sec....(TBH) I forgot about the source.

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment;NEXT FRAGMENT INDEX 1Scriptname TIF__01002F00 Extends TopicInfo Hidden;BEGIN FRAGMENT Fragment_0Function Fragment_0(ObjectReference akSpeakerRef)Actor akSpeaker = akSpeakerRef as Actor;BEGIN CODEIf (GetPCIsRace() == RedguardRace || GetPCIsRace() == BretonRace || GetPCIsRace() == NordRace || GetPCIsRace() == ImperialRace)	Game.GetPlayer().AddItem(MOD1SecretInvitationHU)EndIf;END CODEEndFunction;END FRAGMENT;END FRAGMENT CODE - Do not edit anything between this and the begin commentBook Property MOD1SecretInvitationHU  Auto  Book Property MOD1SecretInvitationElv  Auto  Book Property MOD1SecretInvitationKj  Auto  Book Property MOD1SecretInvitationAr  Auto  Book Property MOD1SecretInvitationOc  Auto  Race Property ImperialRace  Auto  Race Property ImperialRace  Auto  Race Property ImperialRace  Auto  Race Property NordRace  Auto  Race Property NordRace  Auto  


Is that what you guys need?


EDIT: Well, there's an obvious problem with the properties...
User avatar
Dean
 
Posts: 3438
Joined: Fri Jul 27, 2007 4:58 pm

Post » Tue Jun 19, 2012 9:04 am

Is that what you guys need?

Yeah!


Race Property ImperialRace  Auto  Race Property ImperialRace  Auto  Race Property ImperialRace  Auto  Race Property NordRace  Auto  Race Property NordRace  Auto  

Errors: script property ImperialRace already defined

You have these multiple times, isn't that obvious? You define ImperialRace 3 times when only once is needed. Same with the others.
User avatar
Claire
 
Posts: 3329
Joined: Tue Oct 24, 2006 4:01 pm

Post » Tue Jun 19, 2012 2:29 am

Ok, so upon deleting the repetitive races, I am told that GetPCIsRace is not a function, but I know it is, I just don't know what it's located under. I believe I need "something.GetPCIsRace()" but I don't know what "something" is. can you guys help me out?
User avatar
Milad Hajipour
 
Posts: 3482
Joined: Tue May 29, 2007 3:01 am

Post » Tue Jun 19, 2012 12:40 am

It's a condition function - you can't call it from Papyrus. You want to use http://www.creationkit.com/GetRace_-_Actor instead.

Cipscis
User avatar
Dj Matty P
 
Posts: 3398
Joined: Sat Jun 09, 2007 12:31 am

Post » Tue Jun 19, 2012 7:27 am

It's a condition function - you can't call it from Papyrus. You want to use http://www.creationkit.com/GetRace_-_Actor instead.

Cipscis
Oh... I see. So Condition functions can't be use in Papyrus, Gotcha.

Been working on the code. It's coming along nicely now. Thanks for that.

I've learned some things. I'll post again if I need anything. Thanks Guys.
User avatar
Pixie
 
Posts: 3430
Joined: Sat Oct 07, 2006 4:50 am

Post » Mon Jun 18, 2012 8:52 pm

Okay, so this is less a Papyrus problem, but... As mentioned before my script is in a Dialouge Response. The goal is to have the NPC give the play a letter (based on race, which is what all the coding was). However, now I have one topic branch and one topic info, and one response. My code is placed in the begin section of the response pane. When I am forcegreeted and start the topic, I do not get the items. Anyone have any ideas?

Just in case, here's my final code:
Spoiler

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment;NEXT FRAGMENT INDEX 1Scriptname TIF__01002F00 Extends TopicInfo Hidden;BEGIN FRAGMENT Fragment_0Function Fragment_0(ObjectReference akSpeakerRef)Actor akSpeaker = akSpeakerRef as Actor;BEGIN CODEActorBase PlayerBase = Game.GetPlayer().GetBaseObject() as ActorBaseRace PlayerRace = PlayerBase.GetRace()If (PlayerRace == RedguardRace || PlayerRace == BretonRace || PlayerRace == NordRace || PlayerRace == ImperialRace)    Game.GetPlayer().AddItem(MOD1SecretInvitationHU)ElseIf (PlayerRace == WoodElfRace || PlayerRace == HighElfRace || PlayerRace == DarkElfRace)    Game.GetPlayer().AddItem(MOD1SecretInvitationElv)ElseIf (PlayerRace == ArgonianRace)    Game.GetPlayer().AddItem(MOD1SecretInvitationAr)ElseIf (PlayerRace == KhajiitRace)    Game.GetPlayer().AddItem(MOD1SecretInvitationKj)ElseIf (PlayerRace == OrcRace)    Game.GetPlayer().AddItem(MOD1SecretInvitationOc)EndIf;END CODEEndFunction;END FRAGMENT;END FRAGMENT CODE - Do not edit anything between this and the begin commentBook Property MOD1SecretInvitationHU  Auto  Book Property MOD1SecretInvitationElv  Auto  Book Property MOD1SecretInvitationKj  Auto  Book Property MOD1SecretInvitationAr  Auto  Book Property MOD1SecretInvitationOc  Auto  Race Property ImperialRace  Auto  Race Property NordRace  Auto  Race Property RedguardRace  Auto  Race Property BretonRace  Auto  Race Property WoodElfRace  Auto  Race Property DarkElfRace  Auto  Race Property HighElfRace  Auto  Race Property ArgonianRace  Auto  Race Property KhajiitRace  Auto  Race Property OrcRace  Auto   
User avatar
Louise Lowe
 
Posts: 3262
Joined: Fri Jul 28, 2006 9:08 am

Post » Tue Jun 19, 2012 5:13 am

Okay, so I added a Debug Messagebox in an "Else" condition to my code, otherwise it's the same. Apparently it doesn't think that my Wood Elf is a Wood Elf, becuase the textbox appears.
User avatar
Captian Caveman
 
Posts: 3410
Joined: Thu Sep 20, 2007 5:36 am

Post » Tue Jun 19, 2012 12:24 pm

did you hook those book properties up to the books they represent in the script's ck properties?
User avatar
Sudah mati ini Keparat
 
Posts: 3605
Joined: Mon Jul 23, 2007 6:14 pm

Post » Tue Jun 19, 2012 4:00 am

did you hook those book properties up to the books they represent in the script's ck properties?

Yes. Actually IU figured it out. I'm sorry. I forgot to assign properties to the races. Was able to fix it.
User avatar
Courtney Foren
 
Posts: 3418
Joined: Sun Mar 11, 2007 6:49 am


Return to V - Skyrim