Being Stupid

So Im writing a new interface for launching fighters and retrieving fighters (as well as other things).

I'm using the HTTP interface and working well (ish) so far. (bear in mind my programming skills are limited).

$.ajax({
url:"/exec.lua",
method: "POST",
data: "ECHO1 = PlayerSpaceship():setCallSign('ECHO-1'):setFaction('Human Navy'):setTemplate('Player Fighter'):setPosition(-8000, 15000)"
}).then(function (data) {
//success callback
console.log(data)
})

Is the command to spawn a new fighter in a set posistion.

But for some reason I cannot work out how I destroy the same fighter.

$.ajax({
url:"/exec.lua",
method: "POST",
data: "ECHO1:destroy"
}).then(function (data) {
//success callback
console.log(data)
})

Is the code but its not working, Ive tried not just destroying but changing any attribute.

Now Im pretty sure Im missing the obvious since the guide says

_OBJECT_=someObjectGetter()

to select a different object rather than the active player. OK but how would that work in this instance? Could someone give an example?

Comments

  • The problem here is that each call to exec.lua runs in a new "sandbox", so while you set the variable proper on the first call, this is no longer available in the 2nd call.

    There is no perfect solution for this yet. But you can set custom values on any object. And then use that custom value to find your ship again.

    So you could:

    new_ship = PlayerSpaceship():setCallSign('ECHO-1'):setFaction('Human Navy'):setTemplate('Player Fighter'):setPosition(-8000, 15000)
    new_ship.fighter_name = "ECHO1"

    for _, obj in ipairs(getAllObjects()) do
    if obj.fighter_name == "ECHO1" then
    obj:destroy()
    end
    end
  • Next Stupid question how would I send the 2 lines as one line, is there a seperator to use? if tried various { and , ?
  • Couldn't you add using the Custom Script Buttons to a screen such as Comms? That way you don't have to build one in HTML for this.

    Course having a Screen just for Custom Script buttons would be best so you can have someone who's responsibility is to handle Launching and Docking of Fighters.
  • Its to be a seperate screen purely because its one guys job to launch fighter and retrieve them, But in all honestly Im open to ideas, Im pretty new to Empty Epsilon and trying to build a full startship out of what is already amazing stuff. Slightly different engineering screen etc as well.

    Hence HTML is what Im using as I know it best. But open to ideas
  • So a screen with just custom script button would that be different to my current approach?
  • You can do what you want to do with custom script buttons. You would need to add it to the scenario you're playing; which would allow you to keep track of this easier.
    The issue would be you'd have to use one of the existing stations to do this right now.

    One of the benefits with the HTML code you could use it with any scenario; custom or not. I'm running functions for convention play that allows us to fix/break the ship as well as other settings for beginner or advanced crews. That being said you are trying to do is a little more advanced than us. You would have to query the game more with your scripts to make sure things exist and get information on them before firing off commands.

    If a new custom (empty) screen was added to the code in the game itself you could have it in your scenario and make a custom station in the LUA code with the buttons kicking off what you want to do. That would require a bit more work, but not impossible as I was playing with this a while back, but never did anything with it.
  • You can put "\n" between lines to separate them.
  • Awesome on both and thank for the idea of another screen that allows you to do little bits for conventions. Pretty much thats what we are planning apart from LARP stuff. We do 4 conventions a year in ARTEMIS at the moment, but Empty Epsilon seems a better fit.
  • Awesome now working perfectly. I can crack on even more.
  • Me again, so launching and retrieving fighters is now a thing using a HTML page. Next job is getting information out of Empty Epsilon using the Get command. Ive got a mate of mine on Thursday looking at it but if anyone has any idea of what is wrong with the below I would appreciate it.

    $.ajax({
    url:"/get.lua",
    method: "POST",
    data: "hull=getHull()",
    datatype: "text",
    success:function(result){
    document.getElementById("test").innerHTML = result;
    //for pumping to a popup -- alert (data)
    }
    });

    I get a {} result. Which obviously Is not what I expect. :) All help welcome otherwise Ill have to ponder till Thursday.
  • Sorted it, missed on that it was POST not GET.

    Marvelous another thing sorted.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!