Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Orbiter Lua Scripting
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter Lua Scripting Find support, share snippets and general discussion around using the Lua engine in Orbiter.

Reply
 
Thread Tools
Old 11-30-2017, 05:10 PM   #31
kuddel
Donator
Default

The issue with the current Terminal (LuaConsole) is, that is uses one single buffer for the screen and history storage

Code:
 0| term.out('a') << marked as 'input' & therefore considered 'history item'
 1| % a           << marked as 'output' & therefore *not* considered 'history item'
 2| ...
99|
The buffer is implemented as ring buffer, so when 100 lines have been added to the buffer, the "oldest" ones will be lost. Even for the history!

This is the current state. Maybe I'll separate history- and screen-buffer to see if that helps.

In the meantime I've tried to reduce the likelihood of crashes a bit, but that's definitely not the final solution!

Note: The attached DLLs were build using Visual Studio 2017, so if they don't run on XP or totally fail to load or ..., don't be alarmed
Although I hope these work as good (or bad ) as the previous one.

/Kuddel


P.S.:
The ring buffer behavior can be easily "visualized" by these two:
Code:
term.out('-')
for i=1,90 do term.out(i) end
-- both commands will stay in history
Code:
term.out('-')
for i=1,100 do term.out(i) end
-- no more commands in history
Attached Files
File Type: zip LuaScript 2017-11-30(dlls).zip (123.8 KB, 3 views)
kuddel is offline   Reply With Quote
Old 11-30-2017, 08:00 PM   #32
BEEP
Addon Developer
Default

Despite I'm running on XP it didn't ask for VS2017 runtime pendencies ( I do not think I already have them) or anything and ran smoothly.

The crash to desktop problem is solved as far as I could investigate. So Lua Console operation and behaviour can always be reset to normal now because even if you can't really see the input line you can still blindly type 'term.clear()' and restore things back to functionality. Not an elegant solution but a solution where there wasn't any until this moment which is a nice and quickly achieved improvement. Thanks a lot.
BEEP is online now   Reply With Quote
Thanked by:
Old 11-30-2017, 11:09 PM   #33
kuddel
Donator
Default

Another minor change ( Lua MFD now also understands term.clear() )
Attached Files
File Type: zip LuaScript 2017-12-01(dlls).zip (112.9 KB, 1 views)
kuddel is offline   Reply With Quote
Thanked by:
Old 12-04-2017, 09:14 PM   #34
kuddel
Donator
Default

@BEEP: Do you mind if I rename term.clear() into (even shorter)term.clr() ?
As I have to merge all my code into the new rev.73 of Orbiter BETA, I stumbled upon this one and thought "shorter might be better"...
kuddel is offline   Reply With Quote
Old 12-05-2017, 11:04 AM   #35
BEEP
Addon Developer
Default

I myself do not mind but I sincerely think that, in this case where the word is already short, the benefit of having the whole, meaningful word is far more advantageous than the one achieved by just two characters less. I'd keep it term.clear() for semiotic and aesthetic reasons.

Last edited by BEEP; 12-05-2017 at 11:06 AM.
BEEP is online now   Reply With Quote
Thanked by:
Old 12-05-2017, 12:11 PM   #36
kuddel
Donator
Default LuaScript 2017-12-05 DLLs

Here's the result after porting to "Orbiter BETA rev.73"

No intended functional changes
I hope I didn't mess up to much during the porting.

Have fun,
Kuddel
Attached Files
File Type: zip LuaScript 2017-12-05(dlls).zip (103.5 KB, 3 views)
kuddel is offline   Reply With Quote
Old 12-06-2017, 01:34 PM   #37
BEEP
Addon Developer
Default Following Lua API inclusions and exclusions

Quote:
Originally Posted by kuddel View Post
 Another batch of vessel functions added.

A question to those who have experience in writing Lua C API (martin?):
Do you have any recommendation how to implement "reference types" (I mean structures that can be changed anytime and will immediately effect the Orbiter-Core.)
Like the BEACONLIGHTSPEC structure used with VESSEL::AddBeacon()
I think "metatables" and "__index" and all its voodoo ( ) is the way to go, but I don't feel I could do this at the moment...
A working (AddBeacon) C++ example would be perfect

---------- Post added 25-10-17 at 00:05 ---------- Previous post was 24-10-17 at 23:47 ----------

....aaaand as I wrote a script for myself to clearly overview all missing / not missing VESSEL API methods. Here's the result:

Legend:
1st column:
[ ] not (yet) available in Lua
[x] available in Lua
[-] depricated or obsolete (may or may not be available in Lua)
2nd column:
Orbiter C-Method name
3rd column:
Lua vessel function name


Should this maybe added to the 1st post?

Yeeeees please and keep it updated as I'm already having issues with the latest releases ( the carrier I just uploaded doesn't work anymore ).

I'll keep you informed as soon as I clarify the problems ( If I manage to do it ).

Beep

---------- Post added at 01:34 PM ---------- Previous post was at 12:10 AM ----------

Regarding your package for BETA r.73

I cannot extend now but my investigations pointed to a problem in the

vi:create_thrustergroup() ( going CTD)

that may be the reason none of my vessels work.

Could you check?

I may supply more info later.

Beep
BEEP is online now   Reply With Quote
Old 12-06-2017, 06:10 PM   #38
kuddel
Donator
Default

Quote:
Originally Posted by BEEP View Post
 [Regarding your package for BETA r.73

I cannot extend now but my investigations pointed to a problem in the

vi:create_thrustergroup() ( going CTD)

that may be the reason none of my vessels work.

Could you check?

I may supply more info later.

Beep
Thanks for looking into that.
Could you provide a simple Lua script that used to work but crashes now?
As I can not find any real difference in (martins)0 implementation of create_thrustergroup between rev.64 and rev.73

/Kuddel

---------- Post added at 18:10 ---------- Previous post was at 18:00 ----------

...and the Example for the method...
PHP Code:
vessel.get_focusinterface()

h1 v:create_thruster({pos={x=-1,y=0,z=0}, dir={x=0,y=0,z=1}, maxth0=1e5})
h2 v:create_thruster({pos={x=1,y=0,z=0}, dir={x=0,y=0,z=1}, maxth0=1e5})
hmain v:create_thrustergroup({h1,h2},THGROUP.MAIN
...works fine here
kuddel is offline   Reply With Quote
Old 12-06-2017, 07:28 PM   #39
BEEP
Addon Developer
Default

Thanks a lot for your quick reply.

Entering your suggested code line after line in the Lua Console Window:

a) If using LuaInterpreter.dll and LuaInline.dll that come with the r73 BETA package everything works fine.

b) If using LuaInterpreter.dll and LuaInline.dll that come in the LuaScript 2017-12-05(dlls).zip you provided the sim hangs and shutdowns with the usual Windows message after pressing <Enter> at the last ("create_trustergroup" ) line.

Please try to run a scenario with the following (invisible) "vessel" with and without the last line.

Code:
--[[
ClassName = crashtest
Module = ScriptVessel
Script = crashtest.cfg
ImageBmp = 
END PARSE
--]]

function clbk_setclasscaps(cfg)

	hsmkprop = vi:create_propellantresource(1e6, 1e6 ,1.0)

	smkthr_prm = {
	pos = {x = 0 , y= 0  ,z= 0},
	dir={x=0,y=-1,z=0},
	maxth0 =1e-12,
	isp0 = 1e-3, 
	ispr = 0,
	hprop = hsmkprop
  }
  
	hsmkthr_0 = vi:create_thruster(smkthr_prm)

	vi:add_exhaust(hsmkthr_0,.01,.01,{x = 0 , y= 0  ,z=0},{x=0,y=0,z= 1})

	--Stream for the exhaust above
    exhaust_smk = {
		srcsize = 1,
		srcrate = 100,
		v0 =30,
		srcspread = .5,
		lifetime = 1,
		growthrate =5,
		atmslowdown = 0,
		ltype = PARTICLE.EMISSIVE,
		levelmap = PARTICLE.LVL_SQRT,
		atmsmap = PARTICLE.ATM_PLOG,
		amin = 1e-5,
		amax = 0.1
  }
	vi:add_exhauststream(hsmkthr_0,{x = 0 , y= 0  ,z= 0},exhaust_smk)

	
	--**PROBLEM  :-(    PROBLEM   :-(   PROBLEM**
	--Comment and uncomment with a '--' the line below
	hsmkthgrp = vi:create_thrustergroup({hsmkthr_0},THGROUP.MAIN)
end

Also the TGT_Fct_1.cfg from my Makeshift targets

https://www.orbithangar.com/searchid.php?ID=6793

makes a good example on this.

Remember I had already commented about problems with my addons in the past but I'm looking at them only now and so this problem may be not really new and appearing in r73 but may be in earlier versions and around for some time.
BEEP is online now   Reply With Quote
Old 12-06-2017, 08:01 PM   #40
kuddel
Donator
Default

Quote:
Originally Posted by BEEP View Post
 Entering your suggested code line after line in the Lua Console Window:
Really? As copy and paste doesn't work, it's a recipe for failure
Nevertheless, I tried and it works (no crash)

Quote:
Originally Posted by BEEP View Post
 a) If using LuaInterpreter.dll and LuaInline.dll that come with the r73 BETA package everything works fine.

b) If using LuaInterpreter.dll and LuaInline.dll that come in the LuaScript 2017-12-05(dlls).zip you provided the sim hangs and shutdowns with the usual Windows message after pressing <Enter> at the last ("create_trustergroup" ) line.
That simple test does not present the issue here, sorry

Quote:
Originally Posted by BEEP View Post
 Please try to run a scenario with the following (invisible) "vessel" with and without the last line.
I have tried your code (just called the function and also stepped through the C-code with the debugger)
PHP Code:
vi vessel.get_focusinterface()
clbk_setclasscaps() 
...but nothing failed / crashed. Even tried it several times (to find issues with previous created thrustergroups)

I would recommend to 1st try my attached DLLs and if they don't change the behavior, try a pristine Orbiter install (that fooled me, too)
Attached Files
File Type: zip LuaScript 2017-12-06(dlls).zip (104.1 KB, 4 views)
kuddel is offline   Reply With Quote
Old 12-06-2017, 10:43 PM   #41
BEEP
Addon Developer
Default

Quote:
Originally Posted by kuddel
 Really? As copy and paste doesn't work, it's a recipe for failure
Nevertheless, I tried and it works (no crash)
This is a concern to me since punching IBM cards in the 70's so I'm used to it ( to make a lot of errors and correcting them )
I see you cannot reproduce the problem at your side.
I'm starting to think it may be a issue concerning Windows XP, which is the one I use.


Quote:
Originally Posted by kuddel
 That simple test does not present the issue here, sorry
I think you got me wrong. What I meant is that when using the two Lua dll files in the Orbiter root folder that are received through the SVN updating to the r 73 the function vi:create_thrustergroup() works normally both using the Lua Terminal Window and when part of a vessel .cfg file. When I replace these files with the dll's that you make available here in this thread this function does not work anymore for me.

Quote:
Originally Posted by kuddel
 I have tried your code (just called the function and also stepped through the C-code with the debugger)
PHP Code:
vi vessel.get_focusinterface()
clbk_setclasscaps() 
...but nothing failed / crashed. Even tried it several times (to find issues with previous created thrustergroups)
The code I enclosed is a full "vessel". It's supposed to be saved as a vesselname.cfg file in the config\vessels folder where it will appear in the Scenario Editor "new" vessels list. To me when using the dlls you make available in this thread, as adding this vessel is attempted with the vi:create_thrustergroup(..) line active in the vessel code the sim crashes. If the line is commented with the "--" the vessel can be added normally which can be verified by pressing F9 as the vessel doesn't have a mesh to be seen. Of course, the thrustergroup is not created.

Could you please check my Makeshift Targets factory as I recomended? This is a good case of a full but very simple vessel that illustrates the problem nicely. I suspect that it will work normally at your side.


Quote:
Originally Posted by kuddel
 I would recommend to 1st try my attached DLLs and if they don't change the behavior, try a pristine Orbiter install (that fooled me, too)
Using the dll's in the LuaScript 2017-12-06(dlls).zip package the problem persists. I can solve it going back to the SVN r 73 original Lua dll's.

As the problem does not manifest itself when using the two original SVN dll's I don't think I need a new Orbiter installation to check the issue. It's probably related to a Windows XP incompatibility in the new compilations. Please check ( with Martin if needed) for this possibility. However, I'll do a new Orbiter installation ( without the 32G of textures ) and a new r73 update elsewhere in my PC (same Windows XP) and try. I'll make you know the results here.

Thanks a lot in advance for your help and understanding.

Beep

Last edited by BEEP; 12-07-2017 at 12:20 AM.
BEEP is online now   Reply With Quote
Old 12-07-2017, 12:50 AM   #42
kuddel
Donator
Default

O.K. I ran your Makeshift Targets factory...
and again no CTD!
I don't think this has to do with your machine running XP, as other functions seems to work, right?
I really would recommend to try it on a clean pristine Orbiter Install.
Or you could check your PATH environment variable, 'cause some of those lousy Lua Editors around -that I've tried- did like to alter it and that gave me a hard time as well.

By the way, I hope running the included Scenario (Scenarios\Makeshift Targets\TGTs Test All .scn ...which has a ugly trailing space after "All" btw ) from your Makeshift Targets would be enough to trigger your problem, right.
If not, please give me a ZIP with only the really needed parts, with a scenario that I can run without thinking.
As you might know it is hard enough to hunt bugs, it makes things worse when you have to setup anything ...that distracts you from the main point.

---------- Post added at 00:50 ---------- Previous post was at 00:29 ----------

By the way, I'll add future "DLL- ZIPs" to the first post from now on, 'cause my upload quota is getting to its limit
kuddel is offline   Reply With Quote
Old 12-07-2017, 01:48 AM   #43
BEEP
Addon Developer
Post

I've just:

1. Installed a new Orbiter from the distribution .ZIP in another folder.
2. Installed Makeshift Targets on it for testing.
3. Made a test: It ran fine.
4. Installed r 73 by copying the files from my SVN Download /Update folder. (This is not my simulation running Orbiter folder. It holds the clean SVN files only.)
5. Made a new test : everything ok!
6. Installed your Lua dlls from LuaScript 2017-12-06(dlls).zip
7. Tested again : CRASH!!!
8. Returned the two root folder SVN Lua dll's
9. Tested again : everything ran fine.


One thing that may be useful: When I first tried your dlls, some days ago, the system requested the installation of the VC++ 2015 redist package which I did. It seems that this was not necessary for the earlier SVN versions. The VC++ 2015 version I have now is (x86) 14.0.23026. (NOTE: It has been erased by the VC 2017 installation which seems to replace it)

The scenario shows/tests all 37 targets of the package ( the name is ugly to combine with the meshes :-) ) but just the TGT_Fct_1 vessel would already do for the testing. As you can see in the related file \config\vessels\TGT_Fct_1.cfg file it has the vi:create_thrustergroup() function call that interests us.

ADDED1:
Just installed VC++ 2017 Redist 14.10.25008 (despite it was never asked for). To no avail. It didn't change anything.

ADDED2:
It came to me that maybe you'd want to create a debug .dll version that would generate a log file for each call with relevant , useful info. If this is the case please count on me to run the test and send back the results.

Last edited by BEEP; 12-07-2017 at 05:05 PM.
BEEP is online now   Reply With Quote
Old 12-07-2017, 06:22 PM   #44
kuddel
Donator
Default

BEEP, thanks for your detailed checks.

I don't think a debug-build with added logging would give more information, as a crash nearly always crashes the logging, too...
The latest builds were all compiled and linked with Visual Studio 2015, with one exception being build with Visual Studio 2017.

I really checked that the build would be "sane" for XP and only needs the VC2015 runtimes.
But I will take another look into the project files (maybe I'll try building a statically linked one).
If a statically linked one works, this might lead us to the root-cause.
/Kuddel
kuddel is offline   Reply With Quote
Old 12-07-2017, 07:02 PM   #45
kuddel
Donator
Default

I've extracted just the needed parts to setup a "as simple as possible" test to run.
Just start the Test.scn scenario.

For me it works (a smokin' Factory).
Can anybody else try this simple test (with Orbiter BETA r73)?
The ZIP includes the most current build of the Lua-DLLs, too.
Attached Files
File Type: zip LuaTest_Scenario.zip (112.2 KB, 4 views)

Last edited by kuddel; 12-07-2017 at 07:07 PM.
kuddel is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Addons > Orbiter Lua Scripting


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 11:32 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.