Archey6 Posted April 28, 2012 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
fg109 Posted April 30, 2012 Posted April 30, 2012 Your script shouldn't extend Input, have it extend something else.Import Input.Create a property for gold.
Archey6 Posted April 30, 2012 Author Posted April 30, 2012 On 4/30/2012 at 1:16 AM, fg109 said: 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
fg109 Posted April 30, 2012 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?
Archey6 Posted April 30, 2012 Author Posted April 30, 2012 (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 April 30, 2012 by archeyreece
fg109 Posted April 30, 2012 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
Archey6 Posted April 30, 2012 Author Posted April 30, 2012 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.
minymoo Posted April 30, 2012 Posted April 30, 2012 Dumb question, but can this only be done with SKSE?
Archey6 Posted April 30, 2012 Author Posted April 30, 2012 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.
Recommended Posts