Author Topic: A few things I've done with lua.cpp  (Read 6400 times)

0 Members and 1 Guest are viewing this topic.

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: A few things I've done with lua.cpp
its just a unique identifier, like the names the rts uses. you need to come up with a means to tell if the object is still useful. isValid does that fine. periodically loop through the objects if they are valid but arent in the metasystem, add them, if they are in the metasystem but not valid, clear them. luais a memory whore so its absolutely neccisary to clear dead meta entries from the system.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: A few things I've done with lua.cpp
heres a couple of "why the **** weren't they in lua to begin with" function i wrote for ship

Code: [Select]
ADE_VIRTVAR(WeaponEnergy, l_Ship, "number", "Current weapon energy reserves", "number", "Ship current weapon energy reserve level, or -1 if invalid")
{
object_h *objh;
float neweng = -1;
if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &neweng))
return ade_set_error(L, "f", -1.0f);

if(!objh->IsValid())
return ade_set_error(L, "f", -1.0f);

ship *shipp = &Ships[objh->objp->instance];

if(ADE_SETTING_VAR && neweng > -1)
shipp->weapon_energy = neweng;

return ade_set_args(L, "f", shipp->weapon_energy);
}

ADE_VIRTVAR(WeaponEnergyMax, l_Ship, "number", "Maximum weapon energy", "number", "Ship maximum weapon energy reserve level, or -1 if invalid")
{
object_h *objh;
float neweng = -1;
if(!ade_get_args(L, "o|f", l_Ship.GetPtr(&objh), &neweng))
return ade_set_error(L, "f", -1.0f);

if(!objh->IsValid())
return ade_set_error(L, "f", -1.0f);

ship_info *sip = &Ship_info[Ships[objh->objp->instance].ship_info_index];

if(ADE_SETTING_VAR && neweng > -1)
sip->max_weapon_reserve = neweng;

return ade_set_args(L, "f", sip->max_weapon_reserve);
}

ive tested them and they work fine
« Last Edit: July 21, 2009, 11:53:16 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Re: A few things I've done with lua.cpp
It'd still be nice to get a general-use sexp interpreter for Lua (or something similar)...

That is, being able to execute sexp-format code from Lua, just like we can execute Lua code from the sexp side.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: A few things I've done with lua.cpp
that might actually make sexps useful :D
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: A few things I've done with lua.cpp
i fixed a bug with setFOV(), some of the type flags were set wrong in the ade_get_args call
Code: [Select]
ADE_FUNC(setFOV, l_Camera, "[number FOV, number Zoom Time, number Zoom Acceleration Time, number Zoom deceleration Time]",
"Sets camera FOV"
"<br>FOV is the final field of view, in radians, of the camera."
"<br>Zoom Time is the total time to take zooming in or out."
"<br>Acceleration Time is the total time it should take the camera to get up to full zoom speed."
"<br>Deceleration Time is the total time it should take the camera to slow down from full zoom speed.",
"boolean", "true if successful, false or nil otherwise")
{
camid cid;
float n_fov = VIEWER_ZOOM_DEFAULT;
float time=0.0f;
float acc_time=0.0f;
float dec_time=0.0f;
if(!ade_get_args(L, "o|ffff", l_Camera.Get(&cid), &n_fov, &time, &acc_time, &dec_time))
return ADE_RETURN_NIL;

if(!cid.isValid())
return ADE_RETURN_NIL;

cid.getCamera()->set_fov(n_fov, time, acc_time, dec_time);

return ADE_RETURN_TRUE;
}
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: A few things I've done with lua.cpp
Okay, here are some naive changes I made to several functions to make a few additional scripting functions work. I'm quite certain this could have been done in a prettier way, but I'm not experienced enough to see it....

[attachment deleted by Tolwyn]
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: A few things I've done with lua.cpp
You don't really need to leave commented out code in the files.  The beauty of SVN is we can just revert back and the patch itself shows what was there before anyway.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: A few things I've done with lua.cpp
<Jayne>Well, now I know that</Jayne>
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns