A website for every gema-assaultcube fan
 
HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log in  

Share | 
 

 Lua for AC server

View previous topic View next topic Go down 
Go to page : 1, 2, 3, 4  Next
AuthorMessage
Sveark



Messages : 124
Joined/Date d'inscription : 2011-05-02
Age : 23
Location/Localisation : Russia

PostSubject: Lua for AC server   Tue Aug 09, 2011 7:08 am

Hi, I heard the previous version of AssaultCube had the Lua mod maintained by NSL:Brian. |HP| said that unfortunately, we don't have the sources of the mod for AC v1.1.0.4 and that Lua was awesome. I read API of the Lua mod at acserver-lua.netne.net and made the similarity for this thing, so now we have Lua for v1.1.0.4. I tried to do it so that the old scripts could be loaded by new version without any changes. But it was hard, because I saw different APIs function names in different Lua scripts. New Lua mod supports all API described on http://acserver-lua.netne.net/ , but here're what were changed:
1) handlers (aka "hooks") names were changed from AC_--- to on---. Examples: AC_OnMapEnd --> onMapEnd, AC_PlayerSayText --> onPlayerSayText. But: AC_PluginInit --> onInit, AC_LuaLoop (tick) --> LuaLoop ()
2) tmr.tick function was removed, therefore there is no longer need to put it into LuaLoop handler.
3) AC_OnMapChange(string mapname) --> onMapChange(string mapname, integer gamemode)
4) strtok function was removed
5) some new functions were added (ban, setautoteam, getautoteam, disconnect)
6) two first arguments victim and killer in AC_PlayerGetDamage(victim,killer,damage,x,y,z) hook were swapped

Here's an example how the GEMA script (v0.5) was adapted for new Lua: gema-lua.rar
(
  1. cfg_createfile, cfg_getvalue, cfg_setvalue --> cfg.createfile, cfg.getvalue, cfg.setvalue
  2. variable = cfg.getvalue(...) --> variable = cfg.getvalue(...) or "(fail)"
  3. onPlayerSay --> onPlayerSayText
  4. onPlayerDamage(victim, killer, damage) --> onPlayerDamage(killer, victim, damage)
)
Downloads (updated 17 Feb 2013):
  • Linux x86
  • Linux x86-64
  • Windows
  • Sources
  • SvearkMod in Lua
  • Zombie mod
API (version 1.5):
  • Summary
  • Constants
  • Functions
  • Handlers
All scripts from "lua/scripts" directory are started automatically when the server is starting. Also, there's an admin command to restart Lua (unload and load all scripts from "lua/scripts"): /serverextension lua::reload and to get info: /serverextension lua::info. In addition, there're 2 switches understandable my a Lua-modded server:
--lua <path>
<path> is the path to a directory wherefrom the Lua framework will take the scripts. Note there must be a slash at the ending (example: --lua "packages/Lua scripts 2/")

--no-hitreg-fix
disables the hitreg fix.


Last edited by Sveark on Sun Feb 17, 2013 3:55 am; edited 28 times in total
Back to top Go down
View user profile http://sveark.info/ac
samsattF



Messages : 9
Joined/Date d'inscription : 2010-06-24

PostSubject: Re: Lua for AC server   Tue Aug 09, 2011 7:50 am

Thank you for all your hard work. keep it up. cheers
Back to top Go down
View user profile
TheKiller



Messages : 45
Joined/Date d'inscription : 2010-05-05
Age : 21
Location/Localisation : France

Gema stats
farthest jump: 37 cubes

PostSubject: Re: Lua for AC server   Tue Aug 09, 2011 4:56 pm

OMG he did it !!! I said that i loved the lua thing about 1 week ago and you did it !
Thank you, but i hope that no new version of AC will get out early (go on forum, they said that 2 things will change in 1 or 2 months...

I'm a little busy now, but i'll come back in game soon...
BTW, the reloading thing is awesome, 1 year ago when i scripted in LUA, i was restarting my server like 50 times a day Very Happy .

Edit : oh, setvelocity was soooo funny ^^ (but it's cool you removed that, we hacked to much maybe Very Happy )
Back to top Go down
View user profile
Sveark



Messages : 124
Joined/Date d'inscription : 2011-05-02
Age : 23
Location/Localisation : Russia

PostSubject: Re: Lua for AC server   Fri Aug 12, 2011 3:48 am

For some unknown reason my official site doesn't work. Therefore, for the time being welcome here:
Downloads and description
API: Constants, Functions and Handlers
Back to top Go down
View user profile http://sveark.info/ac
|HP|
Admin


Messages : 225
Joined/Date d'inscription : 2010-06-01

Gema stats
farthest jump: MAX

PostSubject: Re: Lua for AC server   Sat Aug 13, 2011 10:05 am

lol didnt see this coming. Thx you are awesome.
Back to top Go down
View user profile
TheKiller



Messages : 45
Joined/Date d'inscription : 2010-05-05
Age : 21
Location/Localisation : France

Gema stats
farthest jump: 37 cubes

PostSubject: Re: Lua for AC server   Mon Aug 15, 2011 10:26 am

Hi, i tested it, test.lua is working, but when i put gema script new in scripts, the server's saying that 1 script is loaded, but ingame when i say !enablegema as admin or any other command, it's doing nothing...
Do you know why?
Thanks, thekiller

Edit : hum but i have the message Do not shoot at other players... That's weird.
Back to top Go down
View user profile
Sveark



Messages : 124
Joined/Date d'inscription : 2011-05-02
Age : 23
Location/Localisation : Russia

PostSubject: Re: Lua for AC server   Tue Aug 16, 2011 6:23 am

TheKiller, the problem is in cfg library. If the config file doesn't exist or requested key wasn't found in the config file, cfg.getvalue returns nil. But the gema script expects a string. This can be fixed by two ways:
in script: replace cfg.getvalue(...) with tostring(cfg.getvalue(...)), or check its returned value if it's nil, and if it is, do something (raise an error or load defaults).
in Lua framework: replace returning value nil with empty string.
I think the 1st way is the best. There're also my misconducts: spawn function doesn't work (but I fixed it already) and /serverextension lua::reload may cause an error with memory allocating - I'm working on that (but still in vain).
Back to top Go down
View user profile http://sveark.info/ac
TheKiller



Messages : 45
Joined/Date d'inscription : 2010-05-05
Age : 21
Location/Localisation : France

Gema stats
farthest jump: 37 cubes

PostSubject: Re: Lua for AC server   Tue Aug 16, 2011 9:13 am

thanks a lot, i'll try the 1st way Very Happy
Back to top Go down
View user profile
TheKiller



Messages : 45
Joined/Date d'inscription : 2010-05-05
Age : 21
Location/Localisation : France

Gema stats
farthest jump: 37 cubes

PostSubject: Re: Lua for AC server   Tue Aug 16, 2011 10:08 am

Hum i did it, and now in server console i can see that the function is stopped : now, when the MAPINFO_STRING has nil value, it's not writing MAPINFO_STRING_PROCESSED.

But ingame, the script still do nothing...

Edit : other info, i tried to set enabled to true at server start (line 43 : false => true). Now, when i connect, the server is saying me that :
Code:
[GEMA] Welcome to this GemaScript server!
[GEMA] You have completed this map 0 times, with a best time of none
[GEMA] Your timer has started! Get Gema-ing!

Edit2 : HAHAHA when i score ac_server.exe crashs.......
Back to top Go down
View user profile
Sveark



Messages : 124
Joined/Date d'inscription : 2011-05-02
Age : 23
Location/Localisation : Russia

PostSubject: Re: Lua for AC server   Wed Aug 17, 2011 3:48 am

TheKiller, server crashes because of spawn function - it doesn't work, but raises segfault (as well as /serverextension lua::reload :/)

Edit: /serverextension lua::reload causes segfault because of logging. If there's no command putting line "<Lua> Framework destroyed" into the log, the server works perfectly. I can't understand this, but could figure out with debugger.

Edit: OK, I fixed spawn, but lua::reload I couldn't. This problem belongs to Linux and I don't know how to fix it. Downloads: Linux x86, Windows x86, sources

Edit: compressed executable for Windows x86

Up
Back to top Go down
View user profile http://sveark.info/ac
TheKiller



Messages : 45
Joined/Date d'inscription : 2010-05-05
Age : 21
Location/Localisation : France

Gema stats
farthest jump: 37 cubes

PostSubject: Re: Lua for AC server   Sat Aug 20, 2011 3:28 am

ok thank you very much, i'll see it when my internet will come back... (i use my neighbor connexion now...)
Back to top Go down
View user profile
Nirude
Admin


Messages : 176
Joined/Date d'inscription : 2010-04-21

Gema stats
farthest jump: 38

PostSubject: Re: Lua for AC server   Thu Aug 25, 2011 11:50 am

It's a great work. cheers ty svearks

I can't claim admin on my server, can you help me?
Back to top Go down
View user profile http://gema.forumactif.com
Sveark



Messages : 124
Joined/Date d'inscription : 2011-05-02
Age : 23
Location/Localisation : Russia

PostSubject: Re: Lua for AC server   Fri Aug 26, 2011 4:03 am

Admin, it's XP's problem, GUI server behaves so. It's because XP brokes password hashing algorithms and it's solved by recompiling client source code on XP - but after this you'll be able to claim admin only on your own server
Back to top Go down
View user profile http://sveark.info/ac
Nirude
Admin


Messages : 176
Joined/Date d'inscription : 2010-04-21

Gema stats
farthest jump: 38

PostSubject: Re: Lua for AC server   Fri Aug 26, 2011 8:52 am

samsat helped me a lot for it. TY.
Back to top Go down
View user profile http://gema.forumactif.com
Nirude
Admin


Messages : 176
Joined/Date d'inscription : 2010-04-21

Gema stats
farthest jump: 38

PostSubject: Re: Lua for AC server   Fri Aug 26, 2011 2:37 pm

I have just tried it, but I got an error, and I can't use !enablegema:
Lua error: lua/scripts/gemascript2_new.lua:106: attempt to concatenate field '?'
(a nil value)
I have downloaded it and just add tostring before cfg.getvalue but can't get it works yet.
Can you help me?

edit: Now I don't have any error but !enablegema still doesn't work.

edit2: found what's wrong with !enablegema:
onPlayerSay => onPlayerSayText
But now, nothing happened when I score, I just get more errors Sad
Maybe I have an outdated version of gema_script.lua?

edit3: I tried some functions and I can't use changemap, setnextmode and setnextmap

edit4: Is there a way with a lua script to launch a map on AC which doesn't meet quality requisites?
Back to top Go down
View user profile http://gema.forumactif.com
Sveark



Messages : 124
Joined/Date d'inscription : 2011-05-02
Age : 23
Location/Localisation : Russia

PostSubject: Re: Lua for AC server   Sat Aug 27, 2011 6:01 am

Admin wrote:
edit2: found what's wrong with !enablegema:
onPlayerSay => onPlayerSayText
But now, nothing happened when I score, I just get more errors Sad
Maybe I have an outdated version of gema_script.lua?
I forgot to replace onPlayerSay with onPlayerSayText. And yes, this script is old and bugged
Admin wrote:
edit3: I tried some functions and I can't use changemap, setnextmode and setnextmap
These functions work normally... I tried
Admin wrote:
edit4: Is there a way with a lua script to launch a map on AC which doesn't meet quality requisites?
What quality requisites? I don't see quality check in the sources
Back to top Go down
View user profile http://sveark.info/ac
samsattF



Messages : 9
Joined/Date d'inscription : 2010-06-24

PostSubject: Re: Lua for AC server   Sat Aug 27, 2011 6:57 am

Sveark wrote:

I forgot to replace onPlayerSay with onPlayerSayText. And yes, this script is old and bugged
The latest version of GemaScript is 0.5 : GemaScript 0.5 by BS-CiD
Sveark wrote:
What quality requisites? I don't see quality check in the sources
Brahma wrote:
The requirements are:

- You cannot have a big open area in your map more than 10000 cubes
- You cannot have a high ceil mean value (not greater than 30 cubes over all map)
- You cannot have pick ups too close each other (the exceptions are health pack and pistol clips, which can stay 3 cubes)
- The same for the flags... at least 30 cubes

Note, as we find more crap maps in 1.1, we create more restrictions to block these maps... so, read Mr.Floppy manual for more info...
These values are applicable for 1.1.0.4.
Brahma wrote:
1) The map has one or more big open areas (this is printed in the server logs via MA value)
2) The map has a high mean ceiling value (twin towers like; this is printed in the server logs via A value)
3) The map has pick ups too close to each other (it is printed the item and the x,y position of it... use "/go_to x y" command to find the item
4) The flags are too close to each other
Back to top Go down
View user profile
Nirude
Admin


Messages : 176
Joined/Date d'inscription : 2010-04-21

Gema stats
farthest jump: 38

PostSubject: Re: Lua for AC server   Sat Aug 27, 2011 7:52 am

Quote :
The latest version of GemaScript is 0.5 : GemaScript 0.5 by BS-CiD
It isn't better ^^

that's my script:
Code:
function onPlayerSayText(pid,text)
   changemap(ac_depot, GM_CTF, 15)
        print("textfound")
end

I can see the text "textfound" but it doesn't changemap or do anything...
Back to top Go down
View user profile http://gema.forumactif.com
TheKiller



Messages : 45
Joined/Date d'inscription : 2010-05-05
Age : 21
Location/Localisation : France

Gema stats
farthest jump: 37 cubes

PostSubject: Re: Lua for AC server   Sat Aug 27, 2011 8:14 am

Haha you used my technique to find out bugs, ask to the script to print lots of text to see if a function is executed. ^^ I use it a lot in CubeScripting.
Back to top Go down
View user profile
Sveark



Messages : 124
Joined/Date d'inscription : 2011-05-02
Age : 23
Location/Localisation : Russia

PostSubject: Re: Lua for AC server   Sat Aug 27, 2011 5:29 pm

Admin, replace this line:
changemap(ac_depot, GM_CTF, 15)
with this one:
changemap("ac_depot", GM_CTF, 15)

samsattF wrote:
1) The map has one or more big open areas (this is printed in the server logs via MA value)
2) The map has a high mean ceiling value (twin towers like; this is printed in the server logs via A value)
3) The map has pick ups too close to each other (it is printed the item and the x,y position of it... use "/go_to x y" command to find the item
4) The flags are too close to each other
Hmm... but I don't see the blocking code. Only checking exists. Maybe I need to test client's code, or more server's files
TheKiller, I use that super-logging way too

Edit: samsattF and Admin, just realized, map checking proceeds on client side

Edit: here's the GEMA Lua script v0.5: download. Works fine, but you need to replace that old GEMA maplist. I marked changed code lines with a comment like -- (N), where N is a number of a change. There're following alterations:
1) with cfg.getvalue:
Old Lua scripts don't check returned value of this function. But in new Lua framework it may be nil, therefore this line:
local infostr = cfg_getvalue(MAPINFO_CFG, name)
was transformed by 2 changes into this one:
local infostr = cfg.getvalue(MAPINFO_CFG, name) or "(fail)"

2) with onPlayerDamage hook:
old form of this hook was like: AC_PlayerGetDamage(victim,killer,damage,x,y,z)
but new form is: onPlayerDamage (integer actor_cn, integer target_cn, integer damage)
This means that victim and killer arguments were swapped.

3) old include file "split.inc" doesn't exist anymore, thus include("split") code line is no longer needed, because split function is implemented in ac_server.inc file -- this file, as far as I know, is used by most Lua scripts.

Edit: up
Back to top Go down
View user profile http://sveark.info/ac
Nirude
Admin


Messages : 176
Joined/Date d'inscription : 2010-04-21

Gema stats
farthest jump: 38

PostSubject: Re: Lua for AC server   Sun Aug 28, 2011 9:21 am

TY very much, maybe you should edit the first post to put the good gemascript version ^^
Back to top Go down
View user profile http://gema.forumactif.com
Nirude
Admin


Messages : 176
Joined/Date d'inscription : 2010-04-21

Gema stats
farthest jump: 38

PostSubject: Re: Lua for AC server   Sun Aug 28, 2011 12:00 pm

I tried some functions: "setpos" and "dodamage" doesn't work:
-setpos set the position only for the server, not for clients
-dodamage don't push players
Back to top Go down
View user profile http://gema.forumactif.com
Sveark



Messages : 124
Joined/Date d'inscription : 2011-05-02
Age : 23
Location/Localisation : Russia

PostSubject: Re: Lua for AC server   Mon Aug 29, 2011 4:08 am

Admin, yeah, setpos controls position only on server side :/ I'm figuring out how server can fully move a player. And I realized dodamage doesn't push player, it just descreases health and armour. But also I realized that it's possible to return setvelocity function. Well, it means that today/tomorrow Lua update will be released (setvelocity and position control)
Back to top Go down
View user profile http://sveark.info/ac
Nirude
Admin


Messages : 176
Joined/Date d'inscription : 2010-04-21

Gema stats
farthest jump: 38

PostSubject: Re: Lua for AC server   Mon Aug 29, 2011 8:26 am

Oh ty! you are so nice Smile
Back to top Go down
View user profile http://gema.forumactif.com
Sveark



Messages : 124
Joined/Date d'inscription : 2011-05-02
Age : 23
Location/Localisation : Russia

PostSubject: Re: Lua for AC server   Mon Aug 29, 2011 6:38 pm

Update. setvelocity function was returned. But setpos will set position only on server side, because server can't control positions, it can set offset to real player position
Back to top Go down
View user profile http://sveark.info/ac
Sponsored content




PostSubject: Re: Lua for AC server   Today at 11:09 pm

Back to top Go down
 
Lua for AC server
View previous topic View next topic Back to top 
Page 1 of 4Go to page : 1, 2, 3, 4  Next
 Similar topics
-
» .^f2F-.Swemmei Recruting in server 1
» Lag playing in Taiwan server from Shanghai
» Proxy Server Taiwan: How To.
» WoW "Development" Server
» Omnos (( Maybe another name depending on server)) Sunbearer

Permissions in this forum:You cannot reply to topics in this forum
gema :: International :: General-
Jump to: