English bot doesent work correct

14 replies
Goto Page
To the start Previous 1 Next To the start
13.02.11 08:22:51 pm
Up
EnderCrypt
User
Offline Off
my bot doesent work correct, it gives error:
LUA ERROR: attempt to call a nil value
mosltly after it killed its target, its suppose to walk random untill someone in vision and range shots...

but it seems like only the bot with highest id reacts

im pretty new to lua nd dont se the wrong

Spoiler >
edited 1×, last 18.02.11 06:11:49 pm
WARNING: Found unknown Windows version: Windows 7
13.02.11 08:26:13 pm
Up
MrShock
User
Offline Off
Do not push "Mark as new/unread" everytime, please.

EDIT : Ohh no .. Epic fail ... I do not know that you do not push it
16.02.11 09:59:09 pm
Up
x25
User
Offline Off
yeah thx
IMG:http://www.auplod.com/u/paolud63761.png
16.02.11 11:58:19 pm
Up
Robotic-Brain
User
Offline Off
omg please add tabs

and where (which line) did the error occur?

EDIT:

I figured it out

first the code with tabs:

More >


your misthake ist, that you try to call a function, wich does not exist
player_die is defined nowhere
and I'm not sure if player_attack and player_new_tile ist correctly implemented as well
edited 2×, last 17.02.11 12:12:48 am
18.02.11 06:00:47 pm
Up
EnderCrypt
User
Offline Off
hm bot doesent work correctly still... only the bot with highest id attacks...
LUA ERROR: attempt to call a nil value

problably anothere script
thx for help

btw: what does "attempt to call a nil value" maybe i could figure whats wrong in othere lua if i would know what that means

edit:
ok seems like it was the bot script that gives the error
it eithere gives it as soon as i spawn, or when first bot spawn

[b]Feuersturm connected
[b]Feuersturm joins the counter-terrorist forces
LUA ERROR: attempt to call a nil value
[b]Feuersturm changes name to police bot

and exacly after a bot killed me, or someone
(after the text that bot has killed player)
then i get

LUA ERROR: attempt to call a nil value

but it doesent seem to cause any trouble, but i would be happy if someone tryd find it

thx
WARNING: Found unknown Windows version: Windows 7
18.02.11 06:12:19 pm
Up
J4x
User
Offline Off
Well, nil means something without value. Try by closing and opening again c2sd, if this doesn't work thne its a error.
18.02.11 06:14:21 pm
Up
Robotic-Brain
User
Offline Off
mostly it means the function/arrayindex does not exist

e.g.:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
array={}
array[1]=0
array[2]=1
array[3]=2

if array[4]==2 then
     -- this would produce the error because array[4] does not exist
end

-- Attention! 0 ~= nil

phantomFunction(a,b)
-- this would produce the error because you have not defined phantomFunction


@2nd Error:
this is caused because you define the function player_new_tile within ai_update_living

but the first call of player_new_tile is before the first call of ai_update_living
so it isn't defined at this time
18.02.11 06:25:27 pm
Up
EnderCrypt
User
Offline Off
ehh... yeah.. could you try fix, im still beginner at lua... and i dont really understand what caused the problem, could anyone fix it, if you got time...

cause i tryd alot and still nothing
WARNING: Found unknown Windows version: Windows 7
18.02.11 06:48:24 pm
Up
Robotic-Brain
User
Offline Off
eh... sorry but i don't really understand what this script should do

if i'm wrong correct me:

on spawn:          <- thats easy
     set mode to 1
     equip some things
     set random starting direction

normal behavior:          <- thats the confusing part
     if mode 1:
          randomly run around
          if shoot by someone set him as target and switch to mode 2
     if mode 2:
          if clear field of fire
               atack
          else
               switch to mode 1


mode 1 = ROAM!
mode 2 = attack

is that correct?
18.02.11 06:56:37 pm
Up
EnderCrypt
User
Offline Off
yeah you andurstand
mode 1 mean run around randomly (lol)
mode 2 is attack mode, where it attacks target variable (id) of target if its a free feild

mode 1 switch to 2 if theres nothing beetween and in range (250)
mode 2 switches to mode 1
if theres somheting in way
WARNING: Found unknown Windows version: Windows 7
18.02.11 08:08:32 pm
Up
Robotic-Brain
User
Offline Off
so now it's working:

More >


i hope that's helpful
18.02.11 08:28:55 pm
Up
EnderCrypt
User
Offline Off
thx works perfect but missing 1 thing

first of all i would want it to attack if someone shot, i mean, theres 2 way for it to go to mode 2

1. someone damages it
2. someone shots with gun (or primary attack) whitin a certain range and theres nothing beetween, weapon does not need to damage anything, as long as its fired by player in range and vision (then i mean no walls in way)

also could you make it change back to mode 1 if target leaves... else it just kills the next person that joins (and get that id lol)

edit: lol also fix so bot check if the target is a bot... they sometimes accidently shot each other...

thx
edited 1×, last 18.02.11 08:39:55 pm
WARNING: Found unknown Windows version: Windows 7
18.02.11 08:56:01 pm
Up
Robotic-Brain
User
Offline Off
Quote:
edit: lol also fix so bot check if the target is a bot... they sometimes accidently shot each other...

eh... you mean check if the target is an enemy?

Quote:
also could you make it change back to mode 1 if target leaves... else it just kills the next person that joins (and get that id lol)


just check if traget is dead and then go back to mode 1

the rest:
just look in the normal AI script
     bots/Standart AI.lua

i can't script you everything
if you get stuck ask and I'll help you
18.02.11 09:02:46 pm
Up
EnderCrypt
User
Offline Off
k lol yeah, i just finished before you posted this, btw thx for the help, i wouldnt have succeded whitout you, thx
WARNING: Found unknown Windows version: Windows 7
18.02.11 09:08:12 pm
Up
Robotic-Brain
User
Offline Off
no problem
To the start Previous 1 Next To the start