Jump to content

Recommended Posts

Posted (edited)

I'm trying to compile this code

 

Scriptname GimmeGold Extends Input
{Free Gold Sir}

Function GiveMeGold()
if IsKeyPressed(86) == 1
	Game.GetPlayer().AddItem(Gold, 2, true)
endif
endFunction

 

but I'm getting these errors

 

Starting 1 compile threads for 1 files...
Starting 1 compile threads for 1 files...
Compiling "GimmeGold"...
c:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\GimmeGold.psc(5,4): global function IsKeyPressed cannot be called on an object
c:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\GimmeGold.psc(5,21): cannot compare a none to a int (cast missing or types unrelated)
c:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\GimmeGold.psc(6,27): variable Gold is undefined
No output generated for GimmeGold, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on GimmeGold

Edited by archeyreece
Posted
  On 4/30/2012 at 1:16 AM, fg109 said:


  1.  
  2. Your script shouldn't extend Input, have it extend something else.
  3. Import Input.
  4. Create a property for gold.

 

Alright, I decided I wouldnt add an item, but just show a debug message. this is my current code, it compiles but it doesn't do anything in-game.

 

Scriptname MessageMe
{Playing around}

Import Input

function MsgMe()
if IsKeyPressed(0x57) == 1
	Debug.MessageBox("Success!")
endIf
endFunction

Posted
You realize that it would only work if you happen to be pressing the F11 key when you call the MsgMe() function right? Do you know how to call functions?
Posted (edited)
  On 4/30/2012 at 3:03 AM, fg109 said:

You realize that it would only work if you happen to be pressing the F11 key when you call the MsgMe() function right? Do you know how to call functions?

 

I didn't realize that. I've tried the code without a function, but I get an error. I've tried calling the function by using

 

MsgMe()

 

But that too just gives an error.

Edited by archeyreece
Posted (edited)

All code needs to be contained within functions or events. This is a working example of using IsKeyPressed:

 

Scriptname Example extends Quest

import Input

Event OnInit()
RegisterForSingleUpdate(0.1)
EndEvent

Event OnUpdate()
if (IsKeyPressed(0x57))
	Debug.MessageBox("You stopped the quest.")
	Stop()
else
	RegisterForSingleUpdate(0.1)
endif
EndEvent

Edited by fg109
Posted
  On 4/30/2012 at 3:26 AM, fg109 said:

All code needs to be contained within functions or events. This is a working example of using IsKeyPressed:

 

Scriptname Example extends Quest

import Input

Event OnInit()
RegisterForSingleUpdate(0.1)
EndEvent

Event OnUpdate()
if (IsKeyPressed(0x57))
	Debug.MessageBox("You stopped the quest.")
	Stop()
else
	RegisterForSingleUpdate(0.1)
endif
EndEvent

 

 

Not sure whats wrong but even that won't work.

Posted
  On 4/30/2012 at 8:59 PM, minymoo said:

Dumb question, but can this only be done with SKSE?

 

Yes, but I have imported 'Input' which allows me to use the IsKeyPressed function.

  • Recently Browsing   0 members

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