Jump to content

RedOnion: Unrestricted In-game scripting - Development Thread


evandisoft

Recommended Posts

Both RedOnion.Script RedOnion.ROS and RedOnion.UI are independent libraries and can be used by anybody (MIT license).

The code used to create the test window in the video from Evan (with the "Click Me!" button) looks like this:

var wnd = new window
function shutdown
  wnd.dispose

wnd.layout = layout.horizontal
var left = wnd.add new panel
left.layout = layout.vertical

var top = left.add new textbox
var box = left.add new textbox
box.multiline = true
box.flexHeight = 1

var right = wnd.add new panel
right.layout = layout.vertical

var btn = right.add new button
btn.text = "Click Me!"
var lbl = right.add new label
lbl.text = "Clicked 0x"

var counter = 0
function click
  counter++
  lbl.text = "Clicked " + counter + "x"
btn.click += click

wnd.y -= unity.screen.height / 3

The purpose of the shutdown function is to close the window when you click the Red Onion launcher button for second time.
It is looking for functions named fixedUpdate, update and onGUI, to execute them from the Launcher : MonoBehaviour,
so, you can e.g. try IMGUI from inside function onGUI. The list of imported objects can be seen here (the FillRoot method).

UPDATE: UI.Window now has ROS-native wrapper that will dispose the windown on engine reset or scene change. The engine is also no longer looking for any specific function, because you can now subscribe to system.update (aliased as ksp.update) or system.idle which are called from FixedUpdate. Subscriptions to update have precedence, idle may get invoked less often (especially if update used a lot of instructions and/or time).

ROS is currently unable to pause and continue the execution, so, do not write infinite loops ;)
ROS2 was redesigned to allow yield/wait commands/functions and automatic fiber/coroutine switching - see launch.ros for the usage.

RO-UI-Test.jpg

I will edit this post later, if we get some feedback... :)

Edited by firda
Update for ROS2 / first release for KSP 1.8
Link to comment
Share on other sites

New Release (0.2.0): https://spacedock.info/mod/2116/Red Onion 

Original post updated.

ChangeLog:

Spoiler

0.2.0:

General:

  • Improved error handling and reporting (line number and line content of where error/exception occured)

ROS:

  • Fixed some engine and parser bugs (functions, lambdas and loops)
  • Enhanced reflection, especially for IEnumerable and List (new for var e in list)

Documentation:

Lua:

  • Wrapper table class called, ProxyTable, created. Can be used to act in place of classes that MoonSharp cannot properly reflect.

Scripts:

  • majorMalfunction.lua: A fun script that causes random parts to explode.
  • selfDestruct.lua: A script that explodes all the parts starting from the parts furthest from the root.
  • testFlightGui.ros: A script that creates a simple UI for interacting with the autopilot.

Videos:

 

Edited by evandisoft
Link to comment
Share on other sites

Hmmm... this looks interesting.

I'm wondering if this could be used in conjunction with writing Lua scripts for use with MOARdV's MAS mod. I beleive Lua is needed to code fuctions for many of the MAS IVA props.

MAS is here, if you are not familiar with it. I beleive MOARdV has a good tutorial on the Github repo Wiki.

MAS- MOARdV's Avionics Systems

Edited by Stone Blue
Link to comment
Share on other sites

43 minutes ago, Stone Blue said:

Hmmm... this looks interesting.

Thanks!

43 minutes ago, Stone Blue said:

I'm wondering if this could be used in conjunction with writing Lua scripts for use with MOARdV's MAS mod. I beleive Lua is needed to code fuctions for many of the MAS IVA props.

I saw that project a while ago when I was first thinking about this project and looking for anything Lua-related that already exists.

The editor will eventually be capable of being used as a standalone tool for in-general editing of files in-game. It's not really at that point yet. It's tied into our scripting system.

But we are absolutely in favor of anyone using this scripting system for interacting with other mods. At this point we don't have an easy system provided for connecting the user to dll's that were not compiled with our project. I believe we will eventually be able to do that.

We're open to working with others on making this mod work well with other mods, and that is one of the goals: to make this a tool for other modders.

Edited by evandisoft
Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...

We are currently testing our mod in KSP 1.8, expect a release soon.

The release will include launch script: https://raw.githubusercontent.com/evandisoft/RedOnion/master/GameData/RedOnion/Scripts/launch.ros

Parameter GUI:

bib5SwZ.png

Auto-staging:

A04WlsE.png

Circularization:

0viQQxx.png

Eccentricity 0.00001 ;)
Apoapsis: 79 929 m
Periapsis: 79 915 m

Edited by firda
e=0.00001 (so many zeros that I forgot one)
Link to comment
Share on other sites

  • 3 weeks later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...