[Fix] space.getSystem().
This commit is contained in:
parent
800ac52895
commit
4fa786ce21
@ -33,7 +33,7 @@
|
||||
<mission name="Empire Shipping">
|
||||
<lua>es_cargo</lua>
|
||||
<avail>
|
||||
<cond>var.peek("es_cargo") == true</cond>
|
||||
<cond>player.getFaction("Empire") >=0 and var.peek("es_cargo") == true</cond>
|
||||
<chance>350</chance>
|
||||
<location>Computer</location>
|
||||
<faction>Empire</faction>
|
||||
|
@ -62,7 +62,7 @@ function create()
|
||||
misn_time = time.get() + time.units(5) +
|
||||
rnd.int(time.units(5), time.units(8)) * misn_dist
|
||||
misn.setDesc(string.format( misn_desc, carg_mass, carg_type,
|
||||
planet:name(),, system:name(),
|
||||
planet:name(), system:name(),
|
||||
time.str(misn_time), time.str(misn_time-time.get())))
|
||||
reward = misn_dist * carg_mass * (500+rnd.int(250)) +
|
||||
carg_mass * (250+rnd.int(150)) +
|
||||
|
@ -297,15 +297,20 @@ int lua_issystem(lua_State* L, int ind) {
|
||||
static int systemL_get(lua_State* L) {
|
||||
LLUA_MIN_ARGS(1);
|
||||
LuaSystem sys;
|
||||
char* planetname, *sysname;
|
||||
LuaPlanet* p;
|
||||
|
||||
if(lua_isstring(L, 1)) planetname = (char*)lua_tostring(L, 1);
|
||||
else if(lua_isuserdata(L, 1)) {}
|
||||
/* Passing a string (systemname) */
|
||||
if(lua_isstring(L, 1)) {
|
||||
sys.s = system_get((char*)lua_tostring(L, 1));
|
||||
}
|
||||
/* Passing a planet */
|
||||
else if(lua_isplanet(L, 1)) {
|
||||
p = lua_toplanet(L, 1);
|
||||
sys.s = system_get(planet_getSystem(p->p->name));
|
||||
}
|
||||
else LLUA_INVALID_PARAMETER();
|
||||
|
||||
/* Return the system. */
|
||||
sysname = planet_getSystem(planetname);
|
||||
sys.s = system_get(sysname);
|
||||
lua_pushsystem(L, sys);
|
||||
return 1;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "llua.h"
|
||||
#include "llua_space.h"
|
||||
#include "lluadef.h"
|
||||
#include "hook.h"
|
||||
#include "mission.h"
|
||||
@ -386,18 +387,23 @@ static int misn_setReward(lua_State* L) {
|
||||
}
|
||||
|
||||
static int misn_setMarker(lua_State* L) {
|
||||
if(lua_isstring(L, 1)) {
|
||||
if(cur_mission->sys_marker != NULL) /* Cleanup old markers. */
|
||||
LuaSystem* sys;
|
||||
|
||||
/* No parameter clears the marker. */
|
||||
if(lua_gettop(L)==0) {
|
||||
if(cur_mission->sys_marker != NULL)
|
||||
free(cur_mission->sys_marker);
|
||||
cur_mission->sys_marker = strdup((char*)lua_tostring(L, 1));
|
||||
#ifdef DEBUG
|
||||
if(system_get(cur_mission->sys_marker)==NULL)
|
||||
LLUA_DEBUG("Marking unexistant system '%s'", cur_mission->sys_marker);
|
||||
#endif
|
||||
mission_sysMark();
|
||||
mission_sysMark(); /* Clear the marker. */
|
||||
}
|
||||
else if(cur_mission->sys_marker != NULL) /* No parameter nullifies. */
|
||||
free(cur_mission->sys_marker);
|
||||
|
||||
/* Passing in a Star System. */
|
||||
if(lua_issystem(L, 1)) {
|
||||
sys = lua_tosystem(L, 1);
|
||||
cur_mission->sys_marker = strdup(sys->s->name);
|
||||
mission_sysMark(); /* Mark the system. */
|
||||
}
|
||||
else LLUA_INVALID_PARAMETER();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user