HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Where to Place Functions in Object Oriented Scripts  (Read 1162 times)

shadowfire

  • General Accounts
  • *
  • Posts: 107
    • View Profile

http://hewiki.heroengine.com/wiki/Creating_Server_Scripts

Ok so ya follow the tutorial right... everything works out fine and what not.  But it tells you to use the cmdTemplate  which of course thens creates a premade and simple template for utilizing a server side command function.  However in the process of this tutorial it doesnt appear to go into breaking down what is written in this template... If a page exists of this template where it is broken down then merely drop in a line after saying use this template and say for more information of this template go here... TEMPLATE!... and also it says add function... but doesnt say where in the command template to add the function. 

So yeah these are my two ideas on how to make this page better.
« Last Edit: Nov 03, 12, 09:18:42 PM by HE-Cooper »
Logged

JMurdick

  • General Accounts
  • *
  • Posts: 54
    • View Profile
Re: Please refine this wiki page
« Reply #1 on: Nov 16, 11, 09:05:16 AM »

Seems pretty straight-forward to me.  Where you put a function in a script doesn't matter because its not processing from top to bottom.

You are correct that that page doesn't detail the rest of the template.  However, I would suggest that detailing the contents of the cmdTemplate would be outside of the scope of that page.  Afterall, that page is meant to get you setup with a "hello world" script.  So at most you might simply add a link to another page that discusses the contents.
Logged

shadowfire

  • General Accounts
  • *
  • Posts: 107
    • View Profile
Re: Please refine this wiki page
« Reply #2 on: Nov 16, 11, 09:45:39 AM »

Seems pretty straight-forward to me.  Where you put a function in a script doesn't matter because its not processing from top to bottom.

You are correct that that page doesn't detail the rest of the template.  However, I would suggest that detailing the contents of the cmdTemplate would be outside of the scope of that page.  Afterall, that page is meant to get you setup with a "hello world" script.  So at most you might simply add a link to another page that discusses the contents.

Agreed murdock though didnt know it doesnt matter where in the script you put the function... but then this does seem to defy everything i know bout programming...

As for the details of the template thats why i recommended a second page bout that template and a link on the tutorial page saying look here.
Logged

JMurdick

  • General Accounts
  • *
  • Posts: 54
    • View Profile
Re: Please refine this wiki page
« Reply #3 on: Nov 16, 11, 10:25:17 AM »

Agreed murdock though didnt know it doesnt matter where in the script you put the function... but then this does seem to defy everything i know bout programming...

As for the details of the template thats why i recommended a second page bout that template and a link on the tutorial page saying look here.

Really?  Guess I'm used to the OO approach more than a procedural.  Worth reading if you are somewhat familiar with programming perhaps:  http://wiki.heroengine.com/wiki/HSL_for_programmers.  The section on OO vs Procedural is useful for this discussion.
Logged

shadowfire

  • General Accounts
  • *
  • Posts: 107
    • View Profile
Re: Please refine this wiki page
« Reply #4 on: Nov 16, 11, 10:29:32 AM »

havent read it yet but even in what I know of object oriented coding each object is still written generally linear unless you are using my favorite little code which is likely to get someone to yell at me... the GOTO loop.
Logged

JMurdick

  • General Accounts
  • *
  • Posts: 54
    • View Profile
Re: Please refine this wiki page
« Reply #5 on: Nov 16, 11, 10:43:21 AM »

havent read it yet but even in what I know of object oriented coding each object is still written generally linear unless you are using my favorite little code which is likely to get someone to yell at me... the GOTO loop.

In an object oriented environment the placement of a function within a classes script/code file has no bearing whatsoever on its functionality.  i.e. it doesn't matter if I place the getName() function above the setName() function or below it they will still operate the same.  Similarly in HSL if I create a class in the DOM such as MyName and then a class script (MyNameClassMethods) and then define getName() and setName() it won't matter to the engine whether one is above or below the other.

That is how OO works in c++, c#, java, or many other languages.  Even how it works in scripted languages like python and lua. 

Now, within the function itself the order of operations matters because the operations within a function are processed procedurally.  Perhaps thats the confusion?
Logged

shadowfire

  • General Accounts
  • *
  • Posts: 107
    • View Profile
Re: Please refine this wiki page
« Reply #6 on: Nov 16, 11, 10:45:11 AM »

well if that is true then I am really old school cause I write my OO Code linear.
Logged

Tythin4

  • General Accounts
  • *
  • Posts: 39
    • View Profile
Re: Please refine this wiki page
« Reply #7 on: Nov 16, 11, 02:33:05 PM »

well if that is true then I am really old school cause I write my OO Code linear.

writing it linear makes the code look cleaner because it's easier to follow along but to the computer itself, it doesn't matter.
Logged