i need help with a mission code
Starbase:sendCommsMessage(Player, [[Wolf,
Captian there is an unknowen object approaching Human space.
You are to intercept this object in sector Z13 and identify it.
Good Luck Captian.]])
mission_state=oNe
end
function update(Delta)
if distance(Player, Intruder) < 30000 then
Starbase:sendCommsMessage(Player, [[Wolf,
We are now recieving sensor data now, Proceed with caution!]])
end
if distance(Player, Intruder) <5000 then
Intruder:setFaction("kraylor"):orderRoaming()
end
end
I'm new to empty epsilon and working on a mission i have run into a error with this piece of code the message pops up at < 30000 when it is susposed to but when you click close it generates another hail with the same message and continues to repeat. if some one could point out the error and how to fix it i would be greatfull.
thanks
Comments
So the message shows up whenever the distance is less then 30000 game units (30U ingame iirc)
So, if you close the message, and you are still in range, the condition "distance(Player, Intruder) < 30000" is still true, so you will still be hailed.
To avoid that, you have to let the game recognize if the message was already sent.
1) set some flag when you send this message, so add another line after the message.
scanmessage_received = true
2) let the game recognize this flag by including it in your if-statement
if distance(Player, Intruder) < 30000 and not scanmessage_received then
Disclaimer: I have almost no experience in lua, so I am not sure if the syntax of my examples is 100% correct, but I guess it may be enough to get an idea how to solve the problem. I'm also not entirely sure how lua handles undefined variables, so to be on the safe side, define
scanmessage_received=false
in the init functionSo you need to keep track of state somehow. One solution is the "flag" as suggested.
Another solution is to track mission state. The tutorial on emptyepsilon.org uses a state variable. Or, you can also track the current mission state as a function. This is what the "Atlantis" mission script does. And it works better for larger missions: Which allows you to split up the different stages of your mission better and clearer in the file. Which is my personal favorite way to do it.
The atlantis mission still checks defeat conditions at all times from the update function, as well as some other trigger conditions that will always happen. While the rest is done from mission state functions.
for example
if x<250000 then
any help would be most appreciated
thanks
if mission_state==0 then
comms_source=(starbase)
comms_target=(player)
setCommsMessage("Starbase 001 here what can we do for you Captian")
addCommsReply("Ready to Depart", function()
setCommsMessage([["Wolf you are cleared to undock....Maintine 50% impulse until you clear Starbase by 30000 Meters and good luck.]])
end)
mission_state=1
addCommsReply("Ready for Chaseing Comets", function()
setCommsMessage ([["We recieved data on a comet that passes by Sector ???? every 17.5 minutes investigate and let us know what you find"]])
end)
mission_state=2
return
end
thank you for any help
The Atlantis mission script is quite complex in this regard. Maybe this example will help:
earth:setDescriptions("Class M Oxygen, Nitrogen, and Water....Earth like.",random(0, 600000000000)"Life signs")
Attaching strings together is done with
..
earth:setDescriptions("Class M Oxygen, Nitrogen, and Water....Earth like.", random(0, 600000000000) .. " Life signs")
You can read the current values with getShieldLevel(n) and the maximum value with getShieldMax(n).
n can be different values (for 2-shield-ships it is 0:front and 1:rear)
player:getShieldLevel(0) - .001
player:getShieldLevel(1) - .001
player:getEnergy -.001
end
still having trouble making this work
A word of advice, when asking questions of this nature, try to describe what you're trying to do, and what you have tried, and in what way it's not working as you would expect, and any sort of diagnostic error messages you're getting.
"Here's some code that doesn't work." is not exactly a question that can be answered without making an attempt to be a mind reader.
I will in the future add more
if distance(player, anomaly3) < 5000 then
player:getShieldLevel(0) - .001
player:getShieldLevel(1) - .001
player:getEnergy -.001
end
player:setShields(player:getShieldLevel(0) - 0.001,(player:getShieldLevel(1)) - 0.001);
player:setEnergy(player:getEnergy() - 0.001);
but anyway, this way you will get in serious trouble, as you do not have defined how fast the shields and energy will get drained. Right now it will be drained by 0.001 per cycle, so it will depend on the fps/speed of your server. So use the delta-parameter, which is the time between the current and the last script call in seconds. so if you want your shield drained by 1 (absolute value, not percent) per second, and your energy by 2 per second, do make sure this is in the
update(delta)
functionThere is also a function takedamage, that probably could be used to directly make damage at the shields (damage type emp)
I would also recommend to have a look at the script_reference.html from time to time. It is autogenerated at compiletime, and can befound in the emptyepsilon folder. Also it helps to look into the other mission files to see how similar things were done.
player:isEnemy(bf1)
bf1 = the other ship
isEnemy is used to check if something is an enemy compared to something else:
if player:isEnemy(bf1) then bf1:destroy() end