Jump to content

LUA API Questions


Recommended Posts

One of the main things that I find exciting about this game is being able to program your own controllers and logic for operating machinery. But what has me curious, as a programmer, is how would an end user be expected to interface with the elements on a code level. Objects? Component/Entities?. I'd imagine you don't have the specifics planned out but it would be good to know what kind of feature that would be available to us.

Link to comment
Share on other sites

One of the main things that I find exciting about this game is being able to program your own controllers and logic for operating machinery. But what has me curious, as a programmer, is how would an end user be expected to interface with the elements on a code level. Objects? Component/Entities?. I'd imagine you don't have the specifics planned out but it would be good to know what kind of feature that would be available to us.

They described the process in a Devblog on LUA scripts, which is comprehensive for an ininitated person to LUA scripts. The jist is thee will be items that are Elements, which are non-voxel objects. Pulleys, terminals, jet engines, which can be linked with one another via an external interface and an in-game interpreter is going to act as your canvas, studio, w/e you wanna call it, you get the idea. It's a very comprehensive Devblog and I suggest you read it.

 

Here ye go mate.

 

https://board.dualthegame.com/index.php?/topic/314-devblog-lua-scripting-and-distributed-processing-units-dpus/

Link to comment
Share on other sites

to TL;DR: the Lua dev-blog - You will be able to use custom logic bricks which you will plug different elements into, which will trigger them and/or provide data for the code you'll write on the main 'programmable block' - a.k.a. DPU.

Link to comment
Share on other sites

One of the main things that I find exciting about this game is being able to program your own controllers and logic for operating machinery. But what has me curious, as a programmer, is how would an end user be expected to interface with the elements on a code level. Objects? Component/Entities?. I'd imagine you don't have the specifics planned out but it would be good to know what kind of feature that would be available to us.

 

An element is a block that has a function in the game, like a weapon (it can rotate/shoot/aim/...), a thruster (accelerate/set speed/...), and so on. 

What they can do, is something we'll get in api form. So you can do stuff like this:

 

"thruster name" setspeed 300

"turret name" shoot

"scanner name" scan

"turret name" track "lowest health enemy"

...

 

Since there's a dpu, you'll be able to make those elements interact:

 

If y(altitude)=0 

       setspeed (0,100,0)

else

       inertia.dampeners 1

 

*or whatever, it's just an example. 

 

Lua is not an object oriented language, but functions are considered like 1-grade objects, and even for other reasons, you can do similar stuff. 

Tried to explain at my best, my english is not good enough to go into specifics.

Link to comment
Share on other sites

while true do

if keypress( "your keyboard's assigned ship power button here") = true then

detectGroundAt(x,y,z)

if detectGroundAt == (0,0,0) then

setEnginePowr(100)

fireVerticalThrusters

end

if detectGroundAt == (0,100,0)

setEnginePower(100)

fireHorizontalThrusters

end

end

 

 

Ye forgot to turn the keys lad. Cheers.

Link to comment
Share on other sites

Ye forgot to turn the keys lad. Cheers.

Keypress isn't necessary if you can run it from dpu

There are games where detectground isn't necessary, because there are already variables X Y Z, that the game keeps track constantly, like minecraft. And depending on the game, you can use those Y X Z directly in the script, as variables.

I didn't specified vertical thrust, I guess i played too much kerbal lately, I got used to the simple vertical takeoff xD

The last part of your script, with horizontal thrust, does a different thing compared to mine. Inertia dampeners serves to stop the ship midair, not to move it horizontally. 

Horizontalthrust need a specific axis direction x or z .

 

I guess you considered the "else" part an error, because you thought I were going to stop the ship midair (with inertia dampeners, so you presumed the need for "while true do"), but I didn't really thought much about giving that script a meaning or an use, it was just a script (useless maybe) to show that you can use lua to make different elements interact between them

Link to comment
Share on other sites

There is OOP in lua, just not much of it and it's pretty barebones

 

Seems quite interesting. What I cant seem to take from that page is if it is entirely event handler based, or whether there is a way for scripts to be just straight up run, which would be quite useful.

Link to comment
Share on other sites

Keypress isn't necessary if you can run it from dpu

There are games where detectground isn't necessary, because there are already variables X Y Z, that the game keeps track constantly, like minecraft. And depending on the game, you can use those Y X Z directly in the script, as variables.

I didn't specified vertical thrust, I guess i played too much kerbal lately, I got used to the simple vertical takeoff xD

The last part of your script, with horizontal thrust, does a different thing compared to mine. Inertia dampeners serves to stop the ship midair, not to move it horizontally. 

Horizontalthrust need a specific axis direction x or z .

 

I guess you considered the "else" part an error, because you thought I were going to stop the ship midair (with inertia dampeners, so you presumed the need for "while true do"), but I didn't really thought much about giving that script a meaning or an use, it was just a script (useless maybe) to show that you can use lua to make different elements interact between them

Wait, you wanted the ship to hover before taking off? Then your code was okay, but you should indeed consider a keypress sequence to emulate a password for your ship good sir, perhaps add a trick keypress sequence with a press timer at your specific seconds or a Morse language kind of thing. For al I know, you can play the beat in the intro of Voodoo Child, it could work in LUA.. It's Grand Theft Auto : Dual Universe Edition out there after all.

Link to comment
Share on other sites

There is OOP in lua, just not much of it and it's pretty barebones

 

Seems quite interesting. What I cant seem to take from that page is if it is entirely event handler based, or whether there is a way for scripts to be just straight up run, which would be quite useful.

No matter what Shynras says, I'm not trusting the server to tell me the range of anything.

 

Also, the general consensus given the information out there, is that your will be able to sequence events in LUA, in order to build factories, so it's not going to be a straight-up run. Plus, a player may sell a building as he sells a ship blueprint, therfore, the need for security codes would be apparent, so yey for keypress command.

 

If I could build an auto-rotation add-on for WoW, I can build it here, in the game, as well.

Link to comment
Share on other sites

There is OOP in lua, just not much of it and it's pretty barebones

 

Seems quite interesting. What I cant seem to take from that page is if it is entirely event handler based, or whether there is a way for scripts to be just straight up run, which would be quite useful.

They briefly mentioned being able to plug some 'system' elements such as a timer event.

Using these you'll be able to have a contiguous thread.

 

(Since you can control elements from your DPU, I'm making the assumption you'll be able to control the system 'timer' element as well.)

Link to comment
Share on other sites

They briefly mentioned being able to plug some 'system' elements such as a timer event.

Using these you'll be able to have a contiguous thread.

 

(Since you can control elements from your DPU, I'm making the assumption you'll be able to control the system 'timer' element as well.)

Indeed you can. Timed events are crucial in all LUA integrations I have come across so far, heck even WoW had timer events on almost every add-on in the game.

 

(and some of us had a very specific add-on that could perform your dps rotation in a raid.)

 

Just saying. You can expect a great deal of shenanigans coming out through LUA.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...