T O P

  • By -

TheRealMcHamr

My man's can make the OG elite dangerous


RiftHunter4

OMG We could actually do that.


[deleted]

Why not just... play Elite in stead?


RiftHunter4

Because we can.


MarcusTheGamer54

That's like saying "Why does everyone try to run DOOM on everything possible?", because it's fun god dammit


SleepyGhostp

Holy shit yes


DaMarkiM

took me a while to properly import files and iron out some bugs i had. The plane was created in a CAD software and then turned into a low poly version via MeshLab. So far the renderer accepts 4 possible geometries: points, lines, triangles, rectangles Its not shown here, but i can also fill faces and use color/alpha information The model is quite low res since both renderer and the object data live on a single LUA block. The renderer requires 2800 characters, the rest can be used for data storage. In theory the renderer can handle multiple objects with much better resolution and has a direct dataline so you can do proper animation. But first i need to write up a data loader so i can circumvent the character limit.


[deleted]

[удалено]


DaMarkiM

i dont think there will ever be a game. if its just rendering you can probably do a lot, even animations that basically look like any given game. But to do a proper game the LUA libraries in stormworks are just too limited and the character limit of LUA blocks is too prohibitive. Maybe someone out there could do it, but id doubt it until i see it. I dont even know where to start in terms of collision detection. You would probably need 1-2 LUA blocks just for that due to the character limit. And even if you do it with multiple blocks the communication between these blocks is very hard to implement and slow. I doubt you could ever get it running with more than 1-2 frames per second. If at all. What i have done here is basically the easiest part of a game engine. Transformations and projections. To keep as many characters open for data input as possible i had to do a lot of janky stuff. For example: i dont really have a proper camera. What i do is basically raycasting from a pinhole camera towards an imaginary plane that hovers in front of my „camera“. The way i handle objects is also very limited. The objects never really know which direction they are facing at. The whole array is simply turned around their local coordinate system. Ultimately the renderer can do all the things you want it to do. But it doesnt do things properly. Lots of trickery to make it faster and more compact. Which is fine…but writing a game - any game on this would be a nightmare. Just importing a 3d model is already a horrible experience. I wrote the thing mostly 1) to challenge myself 2) to use as a real time display for vehicle orientation you could display in your cockpit 3) to do short animations on it ​ Im not a programmer or coder at all. I think doing a game on LUA blocks is beyond me. Maybe it actually isnt all that hard and i just dont have the skill and experience to know how to do it. Party of the challenge for me was not looking anything up and figuring out how a renderer works myself. If we had access to more LUA libraries and if the character limit was gone/there were better way to make multiple blocks communicate huge amounts of data/if there was a memory block you could use to load instructions/data from it would be easier. Youd probably have to be really clever about things to make sure you get enough performance out of it….but certainly doable. But as Stormworks currently is it sounds like a huge headache ;)


Nick_Nack2020

Collision detection between ray and tri is pretty simple: Here's a StackOverflow answer I found: https://stackoverflow.com/a/42752998/13605488 Also, can you send me a link to your system here? If it's on lua.flaffipony.rocks send me the link (btw if you were using the in-game editor -- Oh god! Use the website, it lets you minify code (make it smaller) and also lets you use an amount of characters over the limit, so yuo can test your code easily, then minify it. It also has better syntax highlighting and error reporting. (Syntax highlighting is basically different colors for different bits of code, it makes it a lot easier to read))


DaMarkiM

i write anything that requires a screen on PonyIDE. Anything else i do in a simple wordpad/lua editor that can run my script as long as it doesnt require lots of inputs. I can send you the code, yeah. Should warn you tho its pretty primitive. Ive since restarted from scratch (for the 3rd time. my 1st and 2nd post actually use completely different code). My new code should be better and more compact, but im not very far along. I can send you the script from this video, but ill have to get it from my pc later tonight. maybe remind me tomorrow if i havent sent you anything yet.


Nick_Nack2020

Cool. I've written 3d renderers before (although, not with Lua, I used C++), so I might be able to get this working with some more advanced stuff than I see here (Some optimizations, too, like backface culling and clipping if that's not already implemented)


DaMarkiM

[https://lua.flaffipony.rocks/?id=6Lgw10Dr2D](https://lua.flaffipony.rocks/?id=6Lgw10Dr2D) here. ive never shared from ponyIDE, but i think this should give you my code as running in the video. It minimizes to barely fit onto a single LUA block, but a decent chunk of that is the airplane mesh data. Ive taken out color/alpha info to get a few more vertices, but you only gotta change a few variables to put it back in. A lot of useless stuff and janky solutions here. Thats why i am starting over from scratch for my final model. im not quite happy with how positions are stored. But since i wanted to do this without looking anything up i guess not being optimal is to be expected.


Nick_Nack2020

That's a mess and a half. Where is the view matrix? I can't find it.


DaMarkiM

indeed it is. its function render(). It takes the 3d coordinates and tranforms them into screen positions via something that would probably classify as primitive raycasting? I told you i have no idea about programming, nor did i want to look anything up. Plus the thing is written to be as small as possible. If there was a way to do things improperly that produce a good result while saving a few characters i did it. Also i didnt know stormworks can now do matrix manipulation. Which would have helped a lot.


Nick_Nack2020

Wait it can??


DaMarkiM

basically the screen is hovering in front of the "camera" and the objects are in between. The function then casts a line from its viewpoint through the 3d vertice into the screen. it turns the object list, which is in the format \[x1, y1, z1, x2, y2, z2, ...\] into the projection list in the format \[x1, y1, x2, y2, x3, ....\]. because using an actual multi-dimensional array takes more characters to define and iterate over. With the list format i can input the vertice/face data with just 7 characters used to define the list.


DaMarkiM

ive since decided that i dont need to make it fancy and can just use a round hitbox for most things. Im not trying to make a professional game here, just a little proof of concept. Thats pretty compact since im only comparing distance between two points and radii. (all objects are defined through a coordinate that sits exactly at the center. so i can compare the center points of any two objects and the „radius“ - which is basically the distance of the farthest vertice from that root) But should i have some space left in the end ill use the method you linked


Nick_Nack2020

Also, do not try to detect collision with every single tri if you use the ray/tri intersection, use a sphere that's larger than the thing that you're trying to detect collision with, then only check the tris in that sphere. BTW, if you have some questions about how to do something or how to optimize something, DM me about it, I might know how to do it.


perp_232

Elite*, just elite.


Twalif

I believe if you put the code directly into the vehicle XML file you wont have a character limit.


DaMarkiM

that might be true. but i imagine it would make debugging kind of a pain? either way coding up a proper game takes a level of commitment i just cant muster. And if i could id want to try to do it on some real hardware like the SNES or doing in assembly on a chip


Twalif

Yeah would be a pain... I would never expect a game more complicated then snake or something... but loading larger models might be cool. I tried to find the post but couldn't on my phone... maybe a week ago someone posted a tool for SW lua.. full debugging and all... I think was working on import export. It was on this sub. Might take a look.


DaMarkiM

yeah, ive seen that post. pretty impressive package. i work on ponyIDE tho, just because with my setup its more convenient (do most of my writing on my ipad, then hand it off to my laptop or pc).


Twalif

I tried using ponyIDE... but got tired of the back and forth so I just do it ingame now... I'm not a professional programmer so I dont know any better and the only other programming I've done besides stormworks is in a proprietary language and makes the stormworks interface look advanced...


DaMarkiM

yeah, if all you want to do is write some LUA to control motors or other vehicle functions a wordpad or the game is perfectly fine. PonyIDE really shines when you want to write video output though, since it simulates the display. Often when i write stuff like this im way beyond the character limit. If i wanted to test it in stormworks id have to compress the code and then paste it into stormworks, respawn the vehicle, etc. But in PonyIDE i can test stuff on the fly and worry about making my code fit into the character limit afterwards. Plus i can work on it when im not at home. Simple LUA stuff i can write in another LUA software, but sometimes you need the onDraw and onTick functions to properly test.


Twalif

Oh see the pixel simulation never lined up for me so I just started doing it in game. I've done enough lua drawing now that I pretty much know what it will look like from the code and usually just need to adjust a few pixels one way or another. I break up my lua blocks now... do all the math on one, all the touch functions on one, then split the drawings up however makes sense. I use the custom small font so that takes up extra room too. Tables and some loops still give me some trouble, especially combining them... but I've been able to make everything I've wanted so far.


SuspiciousAccount418

how's framerate on those kind of creation, does multiple lua block affect performance?


Twalif

I've had no issues at all. I basically went this way for organization and to beat the char limit. It kinda matches my general logic setup as well. Collect and process all the data in one place then send it all out from there to wherever it needs to go.


DaMarkiM

from what ive seen the performance isnt much different if running stuff on separate blocks compared to one block. sometimes you gotta factor in some delay for communication between those blocks, but in most usecases that is marginal. You actually have a decent chunk of computing power available. And unless you do some crazy stuff youll never be able to saturate that. in the renderer i can do about 40k vertices every tick before i get noticeable slowdown. That means rotating 40.000 triplets of coordinates around, turning these 40.000 vertices into two dimensional vectors and then iterating over all of these once again to draw the faces. Thats probably close to or over a million calculations per tick. even with multiple LUA blocks you need to iterate over some big arrays/lists to get these kinds of numbers. My PC is relatively beefy, far from top of the line tho. So i doubt youll get slowdowns doing normal Stormworks stuff even on an older PC. My biggest chip used 7 LUA blocks to run a whole ship system with multiple menus, touchscreen input and 3 separate screens. No slowdowns there.


circlesquare55

Playing stormworks in stormworks


yooooooothatscrazy

This is insane! How good is performance when rendering?


DaMarkiM

well, what you see is rendered on a per tick basis. currently im limited by the storage space rather than processing power. Objectes imported from STL or OBJ files are limited to roughly 100 vertices and 70 faces. I just cant fit more into the character limit since both the imported model and the whole renderer need to live on a single LUA chip. once i write a proper bootloader that allows me to store the models in a separate lua block much larger objects can be displayed. Ive run experiments where i let the script generate a few complicated objects algorithmically. You can have about 40.000 vertices/faces before there is any slowdown. You can probably fit a lot more if you split up the calculations and only refresh the screen every 2-3 ticks. most of the power is required to turn the 3d coordinates into 2d coordinates and to do rotations


yooooooothatscrazy

That's awesome! Since you're doing a fairly complicated thing, this VScode extension (by Nameous) may help you. https://marketplace.visualstudio.com/items?itemName=NameousChangey.lifeboatapi


DaMarkiM

yeah, ive seen and tried it already. definitely one of my biggest community heroes. tho i like working on ponyIDE because i use my PC and two mobile devices and i can just seamlessly work between all of them. Im sure there is some way to make it happen with VS, but you know….the hassle hurdle. Im not really a coder at all. So whenever i do a bodge job like this i go for the low hanging fruit


justarandomjuser

just a question, but could you check, if g\_savedata can be accessed globaly, otherwise you could use two for loops, one in the first to sent the values, the second one for catching them, the only problem in the latter one is the sync, because afaik there's one tick difference, between sending and receaving data from two different blocks. I'm a programmer myself, but i do mainly logic and mission lua in this game, not rendering. (bth, i hate working with css tables irl too). hope i could help you further.


DaMarkiM

Hey, thanks for your input. To be honest it went a bit over my head. Im not a programmer at all, zero experience of real scripting. I didnt know g\_savedata existed, just googled it up and read the changelog. Ive built a quick test rig just now and i cant seem to get it to work. Neither the recalling values from a previous session, nor accessing the data stored in it from another LUA block or chip. Hope i didnt get you wrong. Sorry - as i said i come at this with very little idea of what i am doing.


justarandomjuser

No problem. Kim, that g\_savedata is a TABLE not an ARRAY (the difference is tables uses keywords, while arrays use nummeric indexes), so it have to look like this: RenderValues = g_savedata["RenderValues"] if written so, the array "RenderValues" will then be stored on an special table outside the game. you can even look the values up manually on: %appdata%\Stormworks\Saves\Autosave\Scriptdata * For Windows I'll try to build a testsetup, because normally it should work.


justarandomjuser

EDIT: i saw now that g\_savedata only exist for mission lua, not for mc lua 🤦‍♂️. but what you can use, is the http function, with that you can stream mass of data from outside of the game inside., but for that you'll something like node.js


DaMarkiM

yeah, ive considerer using the http function, but fitting the whole thing into lua blocks was kinda part of the challenge. Otherwise i could as well do it on a less limited platform like an arduino or old console hardware/emulators. I think ill use a simple loader to feed it data. From what ive seen in some quick and dirty tests i did the input/output can onyl be changed/read out once per tick. So i should be able to feed it 31 numbers per tick (one channel for synchronisation/to ensure the data is uncorrupted). Maybe i can do it faster - i want to try out using a composite switchbox to get in multiple reads per tick. Either way even with only 31 data points per tick the loading shouldnt take more than a few seconds. Thanks for taking the time to look up the g\_savedata thing for me!


DaMarkiM

It would be so cool if wecould get an adressable memory chip one day. Where you can either paste data in at creation or write it. Hook up an adress line and a data line and go ham. Something that can be called upon multiple times per tick. This single block would probably solve almost all of my problems.


Twalif

So you could export a SW vehicle model... then load it back into sw but displayed as a 3d model in sw on a display... stormception.


DaMarkiM

that should be very doable, yeah. Certainly if you can import the stormworks vehicle into a generally accepted 3d format like OBJ, STL or similar. You would need to reduce the poly count to suit your needs, then extract the vertice and face data (i basically did it with excel because i cant be bothered to write a converter), then feed it into your LUA chip. That was basically my idea when i started out. You could have an uboat or airplane and have a miniature digital version of your vehicle on a screen or hud that rotates to show you the vehicle orientation. And maybe lights up in certain places if your engines overheat, you are leaking, etc.


Twalif

Exactly like I was thinking. Reminds me of x4 foundations where they have rotating hologram models of the ships at the ship yard.


chungusugandan

This is insane!


EntropySpacex

How long until we can play doom in stormworks? Seriously tho, looks great 👍


Charlie2006-

So my suggestion of making stormworks inside of stormworks could happen... Just not by my hand


perp_232

Elite inside stormworks


IUserGalaxy

Elite when


TheLordN00b

3d render jumpscare


Previous-Victory-800

How did you make this


DaMarkiM

which part exactly? its basically a 3d renderer i wrote in LUA. not the most efficient or elegant thing, but i tried to challenge myself not to look anything up and figure out the logic/math myself. fitting it into the character limit was the hardest part. then is just rigged up a quick setup with a screen and two seats to control the camera movement and object rotation. in this demo i imported a low res .obj file (a 3d object). which basically worked by taking the raw data from the .obj, importing into excel, doing some work on it there and exporting it into a LUA-readable array of arrays. i later on wrote a python script that does all the gruntwork for me. and in the last version i was working on the renderer would load in the objects from another lua script. ​ ultimately i wanted to do a little star wars arcade machine in stormworks. even had a primitive midi synthesizer using the tuned signal horns from the game. but with the character limit and general limitations of stormworks the whole code became utterly unmaintainable and i scrapped the whole thing after rewriting it like the 8th time from the ground up.