Jump to content

Unable to call functions in Papyrus Script


gwave

Recommended Posts

Posted

Hello,

 

First of all, I don't know much about scripting. So there might be an error so obvious that nobody ever had the same problem as me.

Recently I wanted to get into Skyrim Scripting, but my success so far is very limited. I'm using this http://www.cipscis.com/skyrim/tutorials/beginners.aspx#Functions   tutorial and I'm working with Notepad++.

 

Now I can define functions without problems. Such as the example in the tutorial:

int Function Max(int a, int  global
	{Returns the largest value out of two integers}

	if (a > 
		Return a
	else
		Return b
	endif

EndFunction

But when I want to call that function with

int c = Max(3, 6)

I get and error when compiling: "no viable alternative at "Max".

 

Or when I just call the functions without assigning a new variable:

Max(3, 6)

I get an similar error. "no viable alternative at "(".

 

 

 

Posted

I tried your sample. It compiled fine.

 

My guess is, that its not the problem with the line where you called function Max, but with code that is "before" that line.

 

Dunno, something like "If" that doesn't have "EndIf" or something like that.

 

 

 

 

Guest airdance
Posted

Look for a typo in the lines just previous to this inline function.

Posted

In the line before is nothing. You can see it in this picture.

 

d4b2aedd85.jpg

 

I already tried to compile scripts from other mods that should run fine. And evertime I get this error when they call a function. Must be some errror with the compiler. I'm thinking about reinstalling Skyrim and all updates, but my Internet is terribly slow and that would take several days.

Posted

Are you using MO?
if yes: edit StartCompile.BAT and add the paths to the source scripts you use to the -i parameter.

Posted

You need to bind your script to an object first. Create a quest and add your script in the Script Tab. The first line has then to be rewritten to

 

ScriptName test Extends Quest

Then it should work.

Posted

Are you using MO?

if yes: edit StartCompile.BAT and add the paths to the source scripts you use to the -i parameter.

 

No, I'm using Notepad++. I set everything up so I can compile the file with Strg+F5. Compiling works fine as long as I don't call a function.

 

@Heromaster

You (or I can't) bind an uncompiled script to any object. It needs to be compiled from .psc do .pex first.

Posted

Just did what you said and it doesn't work either.

 

I think I'm going to reinstall Skyrim and try it on a clean game. Will inform you in a few days if I have success.

Posted

Maybe you can't use functions outside of other functions or events.

 

This line:

int c = Max(3, 6)

 

just outside of everything else looks wrong.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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