Scripts / Absolute noob question: Custom script

Author
Message
HarlsonRS
9
Years of Service
User Offline
Joined: 2nd Apr 2015
Location: Berlin, Germany
Posted: 6th Apr 2015 16:16 Edited at: 6th Apr 2015 16:28
okay, i tried around a bit myself and also read some stuff that i could find, but here´s the point i have to ask:..
i know that if you change a script and save it (renamed of course to not hurt the original) you also have to have >>function_myscriptname_main and myscriptname_init<< at the top ... so here´s my problem... i want to change some values in the ai_soldier.lua script, just some minor changes like ranges and such... so i didn´t change any values yet, just made a copy of it and called it ai_soldier2.lua and changed the function ai_soldier_init to ai_soldier2_init, and also added function ai_soldier2_main, since it gave me an error code "no function called ai_soldier2_main" when i just set the renamed script to a character without changing anything at first...

well now i added those above and tried it again and the error message says like "expected to end at line 8 near <eof>" ?? what ever that means...

so basically my question is: where exactly does the script ask for the changed name, where do i have to rename stuff so the script would work again (some general info would be cery nice, since i´ll need that for other scripts too i guess...) and what else is important if i rename scripts and/or change values in them?

here´s what the script currntly looks like (mostly still original, as mentioned) with some question commentary added


EDIT!
doh..., or can we make it short and just say that´s what "-- LUA Script - precede every function and global member with lowercase name of script" tries to tell me ? oO

so i´d have to rename them all like << ai_soldier2_exit(e) >> ?

and i just realised that ai_soldier_main is called further down... but all threads i have seen so far stated both _main and _init would be opening the scripts (more or less)

sorry again, total noob i know, but i´m trying to get some logic into a chaotic mind here
PM
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 6th Apr 2015 16:35
every function has a body which is surrunded by

you simply forgot the end after function ai_soldier2_init(e)


the message already said that it expected an "end" after line 8
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
HarlsonRS
9
Years of Service
User Offline
Joined: 2nd Apr 2015
Location: Berlin, Germany
Posted: 6th Apr 2015 16:45 Edited at: 6th Apr 2015 16:47
ahm okay, but i didn´t change the script other than renaming said function from soldier to soldier2, so the "end" must have been there already...

so i guess it´s that i added soldier2_main right after that and forgot to add "end" for that function? would make sense

so since there is already a soldier_main further down i´ll just remove my added one, rename the original and see what happens
PM
HarlsonRS
9
Years of Service
User Offline
Joined: 2nd Apr 2015
Location: Berlin, Germany
Posted: 6th Apr 2015 16:55
great works... so i take it that the call for _init and everything after that untill "end" belongs together and is put into one "frame" that gets closed by "end"... same for the further down "_main" ...

but i was sure i have seen both main and init in 2 lines after another... or am i just plain wrong here ?
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 6th Apr 2015 17:43 Edited at: 6th Apr 2015 17:46
edit: missed the first question - yes that's correct, everything in 'init(e)' is called right at the start and is 1 frame as you say - think of it as a setup
*note though that there are a lot of things that dont work here - such as finding out the g_Entity[e]['health'] etc or referencing objects/entities with a higher number*

no you must close the init(e) with an end before you call the main(e)

- even if it's empty like so...

*note* the 'exit' part is currently optional but previously the init(e) part didnt exist at all but is now required so it might be a good idea to include it just in case of more future changes
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
HarlsonRS
9
Years of Service
User Offline
Joined: 2nd Apr 2015
Location: Berlin, Germany
Posted: 6th Apr 2015 21:43 Edited at: 6th Apr 2015 21:46
ah alright, thanks alot (both of you) ...i think i get it...last question: can i keep this thread here for more questions (script related of course)? i would just post "question added" and add the question as q2, q3 etc. in the opener...

not a fan of posting every question in a new thread,becomes messy
PM

Login to post a reply

Server time is: 2024-12-21 13:42:46
Your offset time is: 2024-12-21 13:42:46