Archey6 Posted April 28, 2012 Share Posted April 28, 2012 (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 April 28, 2012 by archeyreece Link to comment Share on other sites More sharing options...
Archey6 Posted April 30, 2012 Author Share Posted April 30, 2012 anyone able to help? Link to comment Share on other sites More sharing options...
fg109 Posted April 30, 2012 Share Posted April 30, 2012 Your script shouldn't extend Input, have it extend something else.Import Input.Create a property for gold. Link to comment Share on other sites More sharing options...
Archey6 Posted April 30, 2012 Author Share Posted April 30, 2012 Your script shouldn't extend Input, have it extend something else.Import Input.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 Link to comment Share on other sites More sharing options...
fg109 Posted April 30, 2012 Share Posted April 30, 2012 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? Link to comment Share on other sites More sharing options...
Archey6 Posted April 30, 2012 Author Share Posted April 30, 2012 (edited) 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 April 30, 2012 by archeyreece Link to comment Share on other sites More sharing options...
fg109 Posted April 30, 2012 Share Posted April 30, 2012 (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 April 30, 2012 by fg109 Link to comment Share on other sites More sharing options...
Archey6 Posted April 30, 2012 Author Share Posted April 30, 2012 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. Link to comment Share on other sites More sharing options...
minymoo Posted April 30, 2012 Share Posted April 30, 2012 Dumb question, but can this only be done with SKSE? Link to comment Share on other sites More sharing options...
Archey6 Posted April 30, 2012 Author Share Posted April 30, 2012 Dumb question, but can this only be done with SKSE? Yes, but I have imported 'Input' which allows me to use the IsKeyPressed function. Link to comment Share on other sites More sharing options...
Recommended Posts