project-navigation
Personal tools

Author Topic: lua design thoughts  (Read 55085 times)

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: lua design thoughts
« Reply #45 on: October 02, 2014, 02:41:32 pm »
but keep in mind that confunc is also callable from the in game-console where as func is not.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: lua design thoughts
« Reply #46 on: October 02, 2014, 02:46:11 pm »
e.g. the component ObjectInfo is in both lua and ufo script - which one is taken into account here?

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: lua design thoughts
« Reply #47 on: October 02, 2014, 08:15:46 pm »
e.g. the component ObjectInfo is in both lua and ufo script - which one is taken into account here?

When two definitions are available, the first one processed is taken into account. In the case here, the lua version, however this depends on the actual order of file processing. Also keep in mind that my branch has an unfinished translation of _assets.ufo (they're named _assets.0.ufo and _assets.1.ufo). So ObjectInfo is now in both however once the translation is finished in lua, the ufo script version is removed.

xray


Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: lua design thoughts
« Reply #48 on: October 04, 2014, 10:17:33 am »
Added another nice feature: events returning a boolean value. In the _assets.ufo script I came across the following code (component: healthbar)

Code: [Select]
visiblewhen "*cvar:mn_show_employee <= 2"

Using the event mechanism in lua this now becomes.

Code: [Select]
healthbar.on_visiblewhen = function (sender)
return (ufo.findvar("mn_show_employee"):as_integer() <= 2)
end

Even though the result currently is the same, the latter implementation allows for much more flexibility in creating complex expressions.

xray

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: lua design thoughts
« Reply #49 on: October 04, 2014, 04:07:40 pm »
Next milestone reached: the file _assets.ufo is now translated in lua.

xray

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: lua design thoughts
« Reply #50 on: October 23, 2014, 08:51:53 pm »
It has been a while since I put a post here. Mostly caused by stress at work and stress at home (my master thesis   :) ).

Anyway: I recently finished the binding for all classes. Means that the basic interface work is more or less finished.

I've also developed a way to generate some rudimentary documentation from the SWIG interface file. Maintaining API documentation by hand is simply not possible with the extend the API now has. The method uses SWIGs feature to dump the parsing stages in an intermediate xml file wich is then formatted using a xsl stylesheet. The result is attached below.

xray



Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: lua design thoughts
« Reply #51 on: October 24, 2014, 08:28:22 pm »
just awesome. great stuff. that sounds like it is mergeable?

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: lua design thoughts
« Reply #52 on: October 24, 2014, 08:51:32 pm »
Ehmm... well... yes, I guess it is. That leaves me with two questions:
1. how to merge the branche into the main trunc
2. I have some documentation to be added to the wiki (explaining a bit how stuff works), how do I get it into the wiki?

xray

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: lua design thoughts
« Reply #53 on: October 31, 2014, 09:36:40 pm »
do a pull request on github.

Signup in the wiki and add your documentation into http://ufoai.org/wiki/Technical_Documentation

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: lua design thoughts
« Reply #54 on: October 31, 2014, 09:37:27 pm »
you can also post the docs here and we will create the first version in the wiki if you are not familiar with mediawiki - then you can edit them later.

Offline Internecivus

  • Rookie
  • ***
  • Posts: 64
  • Sometimes I Code
    • View Profile
Re: lua design thoughts
« Reply #55 on: November 15, 2014, 10:28:33 am »
I've got the latest snapshot of rxadmin/ufoai, made some changes to Makefile to be able to build project on Linux and despite I was able to build project, it segfaults during reading from "_assets.ufo". Is it still unfinished or am I missing something?

P.S. Segfaults are occuring if component has StatBarWide in it. When I commented these components, it continued further.
« Last Edit: November 15, 2014, 11:44:59 am by Internecivus »

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: lua design thoughts
« Reply #56 on: November 15, 2014, 11:03:17 am »
It is finished, however, my build is on windows so I'm not sure why on linux is segfaults. Please provide me with some more info, e.g. the location of the segfault and the modifications you made to the build.

Offline Internecivus

  • Rookie
  • ***
  • Posts: 64
  • Sometimes I Code
    • View Profile
Re: lua design thoughts
« Reply #57 on: November 15, 2014, 11:51:20 am »
http://pastebin.com/Cw3De8sg console output.
http://pastebin.com/e5t0rfv0 Changes I've made
http://pastebin.com/HFqbfApC  Backtrace
http://pastebin.com/dpxnRZe6 Full backtrace

Segfaults are occuring if component has StatBarWide in it. When I commented these components, it continued further crashing somewhere else because of absence of these components.

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: lua design thoughts
« Reply #58 on: November 15, 2014, 01:52:20 pm »
The code is not wrong here. Runs fine on windows, however, I'm building with C::B. My guess, somewhere there is a wrong file compiled & added in the build.

Please check: do you have a file ui_lua_shared.cxx? If so, please remove it.
Note: you should also have a file ui_lua_shared.cpp. This file must be kept.

Just updated the repository rxadmin/ufoai, so if you pull, it will be removed automatically.


Offline Internecivus

  • Rookie
  • ***
  • Posts: 64
  • Sometimes I Code
    • View Profile
Re: lua design thoughts
« Reply #59 on: November 16, 2014, 10:07:37 am »
I commented out this string and now I'm able to play, but I am not sure if it wasn't a bad idea.

http://pastebin.com/t54JC339