Cool. Now I get the reasoning. Creating the ship is guaranteed to run the code. There are probably other ways but not yet known. objFireItemEvent may be useful here (already tried objFireEvent). This is why I am currently using dockscreens. Not because they are the least fiddly way of doing it, but because I know how to make them work (well, usually ).marsrocks wrote:I think we have to initially have our code fit into one of the pre-defined events – with oncreate being guaranteed to run.
And thanks for those wiki links. Extremely helpful. I get frustrated by the wiki because often it seems to be an automatic "This topic does not exist yet" page generator.
Of course. Now I get it. Otherwise you change the rotation value but the ship won't rotate unless it's far enough to get to the next facing. Ties in beautifully with AP's shpGetImageDesc code. But I am intrigued by the glitch you mentioned with the ship not turning in one direction at lower degree values. "The game is afoot."marsrocks wrote:If we have 40 facings (360/40=9) then each facing is 9 degrees from the next. With 120 (360/120=3), then each facing is 3 degrees off the next. Also, I don’t want my next to last turn to beyond the target I want – so, if I am moving 10 degrees at a time – then that gives me another 10 degree error to account for and avoid. 10 (potential error from going too far)+9 (if 40 facings)=19. So, I felt like I needed to have a minimum number here of 19 – and 20 degrees is close enough in case I miscalculated. This also gives it a nice snap when it hits the target I want.
This, I think, is the critical bit of info I needed. I've got the code there but the game is ignoring it because (in an evil digital voice) 'your puny code is not worthy for some reason which we aren't going to tell you'.marsrocks wrote:Again – no event runs until you have some pre-defined transcode allowed event run first. – so my timers are put in oncreate – and then other events I make up can run from there. The computer is looking for those predefined transcode events – but will not actively look for the ones you make up. Those new ones have to be referenced - and put in the computer’s face so to speak before they will run.
I ran through all the code examples you put up before I posted the non-func mod. Same problems. Can run the code within <OnGlobalPaneInit> easily but it won't refer to or call (whichever jargon) to anything else in the <Events> block. All I was looking for was a text dbgOutput but no luck. objFireItemEvent may work here (from those links you posted, thanks again) or it may be as you say, it won't run in a virtual item. I did think at one stage that scrAddAction might be interfering but your examples above pretty much exclude this. Will probably just use your example and create a ship to run the code if something doesn't start working before I go to the next version using Invoke. Thanks for your help.
For general info, here's a couple more links from the pages marsrocks listed above with info on Events:
http://forums.kronosaur.com/viewtopic.php?f=8&t=1997
http://wiki.kronosaur.com/modding/xml/itemtype#events
http://wiki.kronosaur.com/modding/xml/designtype#events