1 (edited by Pocram 2009-04-08 10:09:07)

Topic: Teeworlds Fightcalc (wtf?)

Hiho!

I heard, that teeworlds will be supporten LUA in the future (I hope the mods, too), so I thought I should learn LUA, to make my own mods. (I have lots of ideas, but I'm too shy to post them big_smile)

I made a small programm, that simulates a battle in Teeworlds. All players have got the same skill, because I don't want do add a skill-system like "player 1 is better"..
In the current version, a few things are already included:

  • All weapons + changes + chances of hits

  • Hearts and shields

  • Scorelimits

  • Handycaps

  • Player names

  • Hooking the enemy into the water with the chance to drown, too. (Both can escape)

  • More than 2 players

Everything is automatic and 100% RANDOM. This means the only thing you can do is changing the code.

I don't know how to make something like an executable with LUA, so I'll post the code here and you can paste it into your editor.. (If someone knows how to make that, PLEASE tell me!)

Click me, I'm the code!

Have fun and post bugs here, please! (I hope this IS Teeworlds-related.. I mean.. It's a totally useless Teeworlds simulator!)

- Pocram

» Use the Search-Function before asking questions!

2 (edited by Pocram 2009-04-06 10:38:35)

Re: Teeworlds Fightcalc (wtf?)

Waw, thank you!
Btw, I'm planning a version with up to 16 players... It will be hard, but possible. I hope...
Yes, I DON'T know why I'm doing this or what you can do with it (it doesn't give you any advantage?) but I like it anyway! smile

- Pocram

Edit:

Ok, did it.
The code is a bit cleaner now and you can add as many players as you want. The instruction how to do it is above the players. (At the top of the code. Ok, nearly.)

» Use the Search-Function before asking questions!

3

Re: Teeworlds Fightcalc (wtf?)

Pocram wrote:

Hiho!
100% RANDOM.
- Pocram

technically not, your using a pseudo number generator (this means that the same numbers are coming up every time you execute your program) try seeding the number generator with some/a few seconds / milliseconds from the computer clock. or build your self a "real" random number generator. still tho +1 i love it.

4

Re: Teeworlds Fightcalc (wtf?)

Waw, thank you dim!
I changed the code a bit. No, I didn't change the random thing, I deleted the line where you have to put in the number of players, but you can still change it if you want.

I also tried to add the TDM gametype, but it crashes if someone falls into the water.
And I cleaned up the output, so every message is in it's own line now! (Yay!)

Now I try to add a log function, so you can save the text into a log file, with a randomly generated name.

- Pocram

» Use the Search-Function before asking questions!

5 (edited by DiM SuM! 2009-04-07 10:13:35)

Re: Teeworlds Fightcalc (wtf?)

dont work man error on line 67 or soming

6

Re: Teeworlds Fightcalc (wtf?)

Mh, it works for me..
Cold you give me the output please?
So I can see where it stopped..

- Pocram

» Use the Search-Function before asking questions!

7 (edited by DiM SuM! 2009-04-07 11:03:35)

Re: Teeworlds Fightcalc (wtf?)

lua: /home/****/Desktop/untitled folder/tee2.lua:67: unexpected symbol near `#'

like i siad error on line 67

8

Re: Teeworlds Fightcalc (wtf?)

Hm... Which programm are you using?
Try LuaEdit 3.0  :x

- Pocram

» Use the Search-Function before asking questions!

9

Re: Teeworlds Fightcalc (wtf?)

i run lua scripts thru terminal -  im using latest lua under linux -> ubuntu (u should too ^^)

10

Re: Teeworlds Fightcalc (wtf?)

Try removing row 67 to 72 and put players = 5 instead, they don't seem to be used anyway.

Worked for me without editing anything though.

11

Re: Teeworlds Fightcalc (wtf?)

No, they ARE used!
They set the maximum and the minimum anmount of players..

Hm, but I still don't know Dims problem, maybe his editor doesn't know the (# table) thing..

- Pocram

» Use the Search-Function before asking questions!

12

Re: Teeworlds Fightcalc (wtf?)

Pocram wrote:

No, they ARE used!
They set the maximum and the minimum anmount of players..

Hm, but I still don't know Dims problem, maybe his editor doesn't know the (# table) thing..

- Pocram

But there's never more than five players if you don't change anything else in the source.

13

Re: Teeworlds Fightcalc (wtf?)

Line 25:

-- Add as many players as you want by copying the other ones and entering new information.

Hm.. I should add, that the maximum anmount of players is 16..

  - Pocram

» Use the Search-Function before asking questions!

14 (edited by DiM SuM! 2009-04-07 17:25:01)

Re: Teeworlds Fightcalc (wtf?)

Pocram wrote:

Hm... Which programm are you using?
Try LuaEdit 3.0  :x

- Pocram

linux version? , i use geany or gnome text-editor (which ever one is closest to my cursor )

15 (edited by D3xter 2009-04-07 17:55:11)

Re: Teeworlds Fightcalc (wtf?)

First: End at line 126 is not needed
And maybe try #rplayer without space between, maybe it works then.


Dexter

16 (edited by Pocram 2009-04-08 10:10:17)

Re: Teeworlds Fightcalc (wtf?)

D3xter wrote:

First: End at line 126 is not needed
And maybe try #rplayer without space between, maybe it works then.


Dexter

Oh, I didn't see the end, thank you!
Maybe that's the reason why TDM doesn't work..

lolwtfcoookies98 wrote:

i have no idea how to use it.

Click me!

- Pocram

Edit

Ok, I fixed those things now, but TDM still doesn't work.

Btw, the log function is still in work so it doesn't record ANYTHING. Don't mind smile

» Use the Search-Function before asking questions!

17

Re: Teeworlds Fightcalc (wtf?)

@Pocram what happends, when you try to run TDM? Error-Messages?

Dexter

18

Re: Teeworlds Fightcalc (wtf?)

Yes, when a tee falls into the water the program crashes.
I bet it's a stupid error and it's too easy to find the mistake so I can't find it..

- Pocram

» Use the Search-Function before asking questions!

19 (edited by D3xter 2009-04-09 23:42:40)

Re: Teeworlds Fightcalc (wtf?)

The problem is, that you have got team[1] and team[2], but you assigne the players a team which is between 0 and 1, but the team[0] doesnt exist. So just do it like this and then it works:

rplayer[1].team   = math.random(1,2) -- The new Team-Assignment

Dexter

20

Re: Teeworlds Fightcalc (wtf?)

Oh. You see? A stupid error smile

Thank you, I will update it later.

- Pocram

» Use the Search-Function before asking questions!