Jump to content


Photo

lua syntax question


13 replies to this topic

#1 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 01 February 2005 - 01:51 PM

Why is it in strategy.lua

local id = cpu_manager.stats:GetSquadID( build_type.name )
self.AddPlan( self, BuildUnitPlan( id ) ) <--- Single dot, two parameters

and not

 
local id = cpu_manager.stats:GetSquadID( build_type.name )
self:AddPlan( BuildUnitPlan( id ) ) <--- Colon, one parameter

Sorry, but I'm a LUA newb.

#2 Corsix

Corsix

    Code Monkey

  • Hosted
  • 290 posts
  • Location:Berkeley, UK
  • Projects:DoW AI, DoW Mod Studio
  •  Blue Text :)

Posted 01 February 2005 - 03:22 PM

Yes, I have wondered what this means before.

Basicly "fred:bob(" = "fred.bob(fred,"
Thus "self:AddPlan(" = "self.AddPlan(self,"

There is a complicated reason behind this but I'm shure you don't want to know.
Posted Image

#3 Guest_quiet_man_*

Guest_quiet_man_*
  • Guests

Posted 01 February 2005 - 08:24 PM

test?

#4 Corsix

Corsix

    Code Monkey

  • Hosted
  • 290 posts
  • Location:Berkeley, UK
  • Projects:DoW AI, DoW Mod Studio
  •  Blue Text :)

Posted 01 February 2005 - 08:27 PM

? (I read it in the LUA docs)
Posted Image

#5 Guest_quiet_man_*

Guest_quiet_man_*
  • Guests

Posted 01 February 2005 - 08:42 PM

hey it works, I can post without registering ;-)
I give it a try

"obejectA:method" is object oriented "language"
"objectA" is an object containing some data and "method" for doing something with this data

as today computers don't "think" object oriented, the compiler translates this to procedural language
so objects become data structures and methods become procedures, if you call a procedure you need to tell her which data it has to change

the "." version is one step "lower" language, you have the data structure "object" it contains an pointer to an procedure "method", it is caledl by writing "object.method". To tell the procedure witch data to work on, "object" is added to the parameters.

if you write "object:method(parameter)" the compiler translates it in a first step to "object.method(object,parameter)"

self is just the current active object

Hope this helps a bit,
quiet_man

#6 Corsix

Corsix

    Code Monkey

  • Hosted
  • 290 posts
  • Location:Berkeley, UK
  • Projects:DoW AI, DoW Mod Studio
  •  Blue Text :)

Posted 01 February 2005 - 08:53 PM

Although in most high level languages . is what you use to call methods and it will automatically but the object bit in.
(PS. LUA has no compiler - it is an interpreted language)
Posted Image

#7 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,164 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 02 February 2005 - 12:18 AM

Welcome aboard.. Quiet_man.. You didn't need to register in order to post? Hmmmm.. Should have to... ^_^

I take it yer a scripter/coder yourself? Otherwise.. welcome to the DoW AI project site!
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#8 quiet_man

quiet_man
  • Members
  • 33 posts

Posted 02 February 2005 - 10:16 PM

Welcome aboard.. Quiet_man.. You didn't need to register in order to post? Hmmmm.. Should have to... ;)

I take it yer a scripter/coder yourself? Otherwise.. welcome to the DoW AI project site!

<{POST_SNAPBACK}>


give a program to a programer and he breaks it :p
someone should look after the unregistered thing, no more the time where you could hang a server to the internet without firewall :p

actualy I was a coder, but I was too good and they moved me to project management ;)
and now I have barely time to post at interesting forums

but I remember the times trying to get the CC and Total Annihilation AI to do something usefull ^_^ the last thing I worked on was a little Operation Flash Point scripting

when I first saw DoW I instantly remembered TA and when I saw the AI scripting I felt in love :p just those stupid time constrains

what are you using to edit the ai files?
I have not tryed it, but it looks like C++/C, so the C plugin for eclipse might like it?

Reagards,
quiet_man

#9 Corsix

Corsix

    Code Monkey

  • Hosted
  • 290 posts
  • Location:Berkeley, UK
  • Projects:DoW AI, DoW Mod Studio
  •  Blue Text :)

Posted 02 February 2005 - 10:24 PM

Tis far from C/C++, no classes, no hard typing, etc.
Is more like VB to me (begin ... end)
Posted Image

#10 quiet_man

quiet_man
  • Members
  • 33 posts

Posted 02 February 2005 - 10:34 PM

@Corsix

uuh yes, you are right
so far for my "too good" as coder ^_^

have not done C coding the last years, but I should remember "{" "}"
It is just that most of the proprietary languages the early years were based on C parsers
maybe they have "moved" to VB?

Regards,
quiet_man

#11 Corsix

Corsix

    Code Monkey

  • Hosted
  • 290 posts
  • Location:Berkeley, UK
  • Projects:DoW AI, DoW Mod Studio
  •  Blue Text :)

Posted 02 February 2005 - 10:41 PM

Alot of languages nowadays are interpreted (VB,LUA,PHP,C#,Java,...) However C/C++ is still used alot (DoW for example), mainly for speed.
Posted Image

#12 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,164 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 02 February 2005 - 10:53 PM

Welcome Quiet Man! Are you interested in joining the team (the DoW AI LUA scripting system is, as Corsix mentioned, an interpreted language, so its not too hard to pick up - its best to own DoW so one can playtest changes made)? If you had a copy of just the AI I'm sure it wouldn't take long to pick it up. Nevertheless, thanks for stopping by!

Edited by thudo, 02 February 2005 - 10:54 PM.

Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#13 quiet_man

quiet_man
  • Members
  • 33 posts

Posted 03 February 2005 - 09:19 PM

@thudo

yes I would like to help

currently I'm very bussy with real life but I can do some singleplayer playtesting and code checking, searching errors and maybe small work.

I could not PM you?
How to conntact you to exchange e-mail?

quiet_man

#14 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,164 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 03 February 2005 - 09:29 PM

Yea I know thats odd. Let me talk to the BIG BOSS DUDE and see whats shaken regarding inability to send PMs. Just curious.. you filled out your profile right on the forums here? Maybe the board needs something. Anyway.. let me ask the Head Honcho.

Email: edwin.carter@gmail.com
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users