LUA, server API, etc

"eventually EUO will get to the point its (sic) unplayable" - Dudle

Moderator: EUO Moderators

LUA, server API, etc

Postby eggmceye » Thu Jul 19, 2012 8:52 pm

EUO LUA is the worst documented API in the world, however here is something to chew on

The actual C++ to LUA interface/API
http://swut.net/files/eao.pkg.cpp

This file has all the server functions that LUA can use. It's undocumented. The only tute for euo+lua is Rusty's guide below. The good news is that it's all pretty easy. The bad news is that there are tons of things that you 'need to know' or learn to make things work. Like doing 'fov updates' or syncs after certain things. Best way to learn is copy & mod existing things. If in doubt, ask me, and if you don't know how to do something, ask, and if you need some server feature function even I can add it in if isn't too hard.

Rusty's LUA scripting guide
http://euotopia.com/manual/index.php/Ru ... g_with_LUA

My original, ancient API doc
viewtopic.php?f=12&t=2657

I might review and update this - it's basically correct still, but may be missing a few things.
User avatar
eggmceye
hello
 
Posts: 9878
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia

Re: LUA, server API, etc

Postby LordMortiferus » Tue Jul 24, 2012 5:52 am

Thanks for the blood and moss overlays.
Please consider to change the type of 5d0 and 5d1 from furniture "f" to something else so they can be used over secret doors and on floor tiles as well.
User avatar
LordMortiferus
Girls only want boyfriends who have great skills.
 
Posts: 756
Joined: Tue Dec 01, 2009 10:23 pm

Re: LUA, server API, etc

Postby eggmceye » Wed Jul 25, 2012 4:55 pm

yeh I realised that once I copied the file in - changed to type I (which is a nonblocking furniture)
User avatar
eggmceye
hello
 
Posts: 9878
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia

Re: LUA, server API, etc

Postby mud » Sun Oct 28, 2012 3:19 pm

Is there any info somewhere about the details of setting up instances?

I took a look at the BM instance and also the mino's heroic portal thing, but one thing I'm not seeing is: how do I do some setup on the "new" map? Like ideally I'd want it to call load_map_256(300) (or whatever the auto-assigned instance map level is instead of 300) when the instance is created, or my own named function or anything like that.

Is that possible? If not I can probably work around it by putting a stp feature right after where the people start on the level or something and hook that up to a function, but that seems kinda ugly.

Or alternatively, is there some function in the LUA API that will let me do manually what those magic instance portals/stairs are doing? Namely: load up a temp map that's a copy of another, but only if one doesn't already exist for the player (and if they're in a party they all share one). I mean I see load_temp_map(...), but that wouldn't do all of that cool logic itself, would it somehow?
mud
I once posted in TFIOOC!
 
Posts: 132
Joined: Wed Nov 09, 2005 12:29 pm

Re: LUA, server API, etc

Postby eggmceye » Mon Oct 29, 2012 3:42 pm

ok so what you want is the instance map to call some startup function? that the noninstance version doesn't call?

I haven't tested it but theoretically, if you make an instance of say map 50 then the parent map 50's loadup func should get called too. Then inside that func you can put code that checks to see if the map is an instance, eg

Code: Select all
function load_map_050(lvl, load_on_the_fly)

  map=get_map_ptr(lvl)

  if map.instance then

   -- extra loading here
  end
 
end


only problem is that .instance, tho exists, is not visible to lua (I can easily add that) then it all needs testing but theoretically easy mod

is this what you wanted?
User avatar
eggmceye
hello
 
Posts: 9878
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia

Re: LUA, server API, etc

Postby mud » Mon Oct 29, 2012 3:48 pm

eggmceye wrote:ok so what you want is the instance map to call some startup function? that the noninstance version doesn't call?

I haven't tested it but theoretically, if you make an instance of say map 50 then the parent map 50's loadup func should get called too. Then inside that func you can put code that checks to see if the map is an instance, eg

Code: Select all
function load_map_050(lvl, load_on_the_fly)

  map=get_map_ptr(lvl)

  if map.instance then

   -- extra loading here
  end
 
end


only problem is that .instance, tho exists, is not visible to lua (I can easily add that) then it all needs testing but theoretically easy mod

is this what you wanted?


I think the problem is that it doesn't seem to be calling the load_map_xxx function at all for an instance. So if it's supposed to be doing that either it's bugged or I did something wrong.

What I have is just a portal on map 258 set to val=-256, and the "item" of the portal is set to ffffffff (I just copied the style from the minos heroic portal, not sure if the ffffffff thing actually means anything). I get a line in the server log that's:

Code: Select all
28-10-2012 22:51:49: loading instance old=256 new=300 script=[] owner=[test]


But my load_map_256 function is never called, unless I /tele to the original level 256, and then it's only called with the first parameter set to 256.

Let me know if it'd be helpful if I threw a quick test of that into my dropbox folder or something. I noticed that I could not actually find an instance that currently uses the load_map_xxx functionality at the same time, so it's possible it's just never come up?
mud
I once posted in TFIOOC!
 
Posts: 132
Joined: Wed Nov 09, 2005 12:29 pm

Re: LUA, server API, etc

Postby eggmceye » Sat Nov 03, 2012 2:06 pm

I've added (not live but will paste into dropbox soon) a moasv.exe that has a hook that is called when instance loaded

so instead of load_map_054(lvl, on_the_fly) a func
Code: Select all
function load_instance_054(lvl)
  ...
end

will be called instead.
User avatar
eggmceye
hello
 
Posts: 9878
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia

Re: LUA, server API, etc

Postby mud » Sat Nov 03, 2012 7:53 pm

That sounds perfect. Thanks Max!
mud
I once posted in TFIOOC!
 
Posts: 132
Joined: Wed Nov 09, 2005 12:29 pm

Re: LUA, server API, etc

Postby mud » Mon Nov 05, 2012 3:29 pm

Hmm, it looks like it's calling load_instance_256(256) instead of load_instance_256(300) like I expected. User error?
mud
I once posted in TFIOOC!
 
Posts: 132
Joined: Wed Nov 09, 2005 12:29 pm

Re: LUA, server API, etc

Postby eggmceye » Mon Nov 05, 2012 3:33 pm

more like programmer (me) error because you need

Code: Select all
function load_instance_054(actual_level, parent_level)
  ...
end


right?

actually you probably don't really need parent but I'll leave it there - above will the be the api in about 5 mins
User avatar
eggmceye
hello
 
Posts: 9878
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia

Re: LUA, server API, etc

Postby mud » Mon Nov 05, 2012 3:51 pm

Yeah, anything like that would be perfect. Thanks Max.
mud
I once posted in TFIOOC!
 
Posts: 132
Joined: Wed Nov 09, 2005 12:29 pm

Re: LUA, server API, etc

Postby mud » Mon Nov 05, 2012 4:23 pm

Sorry to be a pain in the ass, but the version you put in Dropbox after we chatted in game still seems to be calling load_instance_300(300, 256) instead of load_instance_256(300, 256).
mud
I once posted in TFIOOC!
 
Posts: 132
Joined: Wed Nov 09, 2005 12:29 pm

Re: LUA, server API, etc

Postby eggmceye » Mon Nov 05, 2012 5:35 pm

ok der, try it now :fp:
User avatar
eggmceye
hello
 
Posts: 9878
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia

Re: LUA, server API, etc

Postby mud » Mon Nov 05, 2012 9:33 pm

Looks perfect, thanks again.
mud
I once posted in TFIOOC!
 
Posts: 132
Joined: Wed Nov 09, 2005 12:29 pm

Re: LUA, server API, etc

Postby LordMortiferus » Fri Nov 16, 2012 3:37 am

Is there a way to suppress switches from being set back to their original state after a certain time? I hoped making 299 an instance would do the trick but it still is the same problem - you activate a switch and when you get to the barrier several minutes later it is active again. If not I am going to code the switches with LUA.
Otherwise I am nearly done fixing 299.
User avatar
LordMortiferus
Girls only want boyfriends who have great skills.
 
Posts: 756
Joined: Tue Dec 01, 2009 10:23 pm

Re: LUA, server API, etc

Postby mud » Sat Aug 17, 2013 10:51 am

Is there a way to import LUA modules into the environment used by auxbox? I was going to do some networking type stuff if possible. I tried just installing Lua in windows and "require" the modules I wanted in an auxbox script, but it didn't seem to work no matter what I did. I also tried dofile and such.
mud
I once posted in TFIOOC!
 
Posts: 132
Joined: Wed Nov 09, 2005 12:29 pm

Re: LUA, server API, etc

Postby eggmceye » Sat Aug 17, 2013 2:54 pm

I've never tried imports via lua ... however ... and this may or may not help
but all the lua files in the clientscripts dir will be loaded - so if there is some custom lua lib you want then it can be pasted in there - but if you want the native lua libs then I'm not so sure.

I just checked server lua source - having a flashback to lua libs - and I did at one point have them in there but are currently commented out. I wonder now if you even need to import anything? I know for sure string and table don't need any imports - I use them both in server lua funcs.

Code: Select all
void start_lua() {
   
   lua_register( pLuaState, "_ALERT", luaError );

   //luaopen_io(pLuaState); // provides io.*
   //luaopen_base(pLuaState);
   //luaopen_table(pLuaState);
   //luaopen_string(pLuaState);
   //luaopen_math(pLuaState);
   //luaopen_loadlib(pLuaState);

   luaL_openlibs(pLuaState);
   
#ifdef MAPED
   tolua_maped_open (pLuaState);
#else
   tolua_eao_open (pLuaState);
#endif
   register_funcs();


   lua_pushstring(pLuaState, "LUA_PATH");
   lua_pushstring(pLuaState, "scripts/?.lua;scripts.maps/?.lua;scripts/includes/?.lua");
   lua_settable ( pLuaState, LUA_GLOBALSINDEX );

   writelog("load scripts rc=%d", load_scripts());
}
User avatar
eggmceye
hello
 
Posts: 9878
Joined: Mon Mar 11, 2002 3:55 pm
Location: Sydney, Australia

Re: LUA, server API, etc

Postby mud » Sat Aug 17, 2013 3:30 pm

Ah, cool, thanks for the info. I'll see if I can get it to work with a bit more fiddling.
mud
I once posted in TFIOOC!
 
Posts: 132
Joined: Wed Nov 09, 2005 12:29 pm

Re: LUA, server API, etc

Postby Celerion » Sat Mar 22, 2014 6:57 am

mud wrote:Is there a way to import LUA modules into the environment used by auxbox? I was going to do some networking type stuff if possible. I tried just installing Lua in windows and "require" the modules I wanted in an auxbox script, but it didn't seem to work no matter what I did. I also tried dofile and such.

It's only a work-around, but it should be possible to just paste all the code of the Lua modules, you would require, into the main-script (you don't need the "require ..."-line then, of course).
If the module itself depends on other modules, you'll have to paste their code too though.
Celerion
I'll be going back to Tibia next week.
 
Posts: 48
Joined: Sat Dec 15, 2012 6:29 am

Re: LUA, server API, etc

Postby Keighn » Wed Sep 07, 2016 10:51 pm

I know the fontain script was posted at one time. I don't suppose it and all the search scripts for weekly could be posted?

I'm hoping that someday the other servers has a version of those as well but obviously not to the uber extent. Chances would have to be tweaked as well. Its something in games I always enjoyed along with puzzles and descriptions. Probably why I like a lot of Catherines maps is because she has some hidden stuff in there even though a lot of the quests aren't activated. There is some storyline plot in all the maps that could be even more awesome than the game already is.

I have the scripts to the uber mobs Rusty and Rush and a few others developed as well. I haven't seen the comparison to those and the PD anniversary edition ones. I believe they were a little less powerful so not to insta kill everyone on the PD server.
User avatar
Keighn
Stop posting already --;
 
Posts: 4784
Joined: Sat Jun 26, 2004 10:13 am
Location: From the depths of Oregon he returns.... KEIGHN!!!!

Next

Return to EUO Development

Who is online

Users browsing this forum: No registered users and 2 guests