1 / 35

2 – Scripting

SW Development Course Multiplayer Multimedia Apps on the Web. 2 – Scripting. Events Language elements Flow control constructs Implicit parameters Movement EVENTs Navigating documentation Array and SETs. EVENT. Whatever happens, an EVENTO triggers

facer
Download Presentation

2 – Scripting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SW Development CourseMultiplayer Multimedia Apps on the Web 2 – Scripting Events Language elements Flow control constructs Implicit parameters Movement EVENTs Navigating documentation Array and SETs

  2. EVENT • Whatever happens, an EVENTO triggers • When an EVENT triggers, the system looks for a specific piece of software • At each call, if that piece of software is found, it is executed

  3. EVENT example • At the game’s startup • onStart Event • If code for onStart is found, it is executed

  4. EVENT • EVENT id_evento • Instruction • Instruction .. • End_EVENT  verify Developers Ref.

  5. EVENT Example • EVENT onStart • Call PopMonster() ‘My function – make a monster ‘to pop up in a random room • End_EVENT

  6. EVENT example • A character gets looked at (clicked on) • The event person.onLook triggers • If existing, the event gets executed and stop. • Otherwise the generic event onLook triggers • If existing, the event gets executed.

  7. Implicit parameters • $OWNER – who owns the event equals to this in Java • $AGENT – who started the action • $TARGET – third actor (sometimes used, mostly not)

  8. EVENT Model: person.onLook $AGENT $OWNER

  9. onLook EVENT Example SCRIPTS EVENT guy.onLook Speak $OWNER,$AGENT,“So, what’s up?" END_SCRIPTS

  10. Speak • Speak [speaker,][destination,] phrase [, phrase …] • “speaker” Defaults to: $OWNER • “destination” Defaults to: $AGENT • If there are many phrases, they are printed in cycle

  11. Speak from this… SCRIPTS EVENT guy.onLook Speak $OWNER,$AGENT,“So, what’s up?“ END_SCRIPTS

  12. …to this (compact form) SCRIPTS EVENT guy.onLook Speak“So, what’s up?“ END_SCRIPTS

  13. Pre-defined values SYS (System voice) • Use as “speaker” when needed $WORLD (All connected players) • Use as “destination”

  14. onLook EVENT Example SCRIPTS EVENT guy.onLook Speak SYS,$WORLD,“Player “ + $AGENT + “ looks “ + $OWNER END_SCRIPTS

  15. Object Model di CHARACTERS • Use the dot . to refer to an object’s property Person.name Name of the person Person.container Where person is (room object) Person.container.id (room’s ID) Person.container.name (room’s name)

  16. Print • Print [dest,] What [, what…] • Print “In this room there’s some light” • Print “OWNER=“ + $OWNER + “ AGENT= “ + $AGENT + “ TARGET=“ + $TARGET

  17. Assignment – remember a value • Birthday = “July 26th” • Print Birthday July 26th

  18. If .. Else • If (condition) • Istructions • Else • Istructions • End_If • No THEN • End_If and not: “End If”

  19. RndInt(N) • Returns a random nunmber from 1 a N

  20. If .. Else IfRndInt(2) = 1 Print “ODD!” Else Print “EVEN!” End_If

  21. EVENT Model: person.onHear $TARGET $AGENT $OWNER

  22. Printing implicit parameters • Print “OWNER=“ + $OWNER + “ AGENT= “ + $AGENT + “ TARGET=“ + $TARGET

  23. Inspecting the log • System folder • File name is: debug#.log • # = number of slot you used • Note: If it is missing then edit setting debugTo= in the worldnav#.properties file

  24. Echoing speech • EVENT person.onHear • Speak $OWNER,$AGENT,”You said: “ + $TARGET + “, what do you mean?” • END_EVENT

  25. EVENT Model: room.onLoose $AGENT $TARGET $OWNER

  26. EVENT Model: person.onExit $OWNER $AGENT $TARGET

  27. EVENT Model: person.onEnter $OWNER $AGENT $TARGET

  28. EVENT Model: room.onReceive $AGENT (?) $TARGET $OWNER

  29. Navigating Developers Reference • How DimensioneX works • Configuration • Design-time part (DXW) • Run-Time part (SmallBasic) • Objects’ Object Model • System (built-in) Events • Available Functions • Available Istructions

  30. Array arrGreets 1 2 3 4 “ciao” “hola” “hi” “hello”

  31. Array + RndInt(N) • arrGreets = NewSet(“ciao,hola,hello”) • Speak arrGreets(RndInt(3)) • Ciao • Hello • Ciao • Hola

  32. SET setObjects book crown scroll sword

  33. For Each Next • For Each var In set • Instructions • Next • Careful! To set and arrays

  34. For Each Next + SET Print “present characters:” For Eachx In getCharactersIn($WORLD) Printx.name Next

  35. Summary • Events • Language elements • Flow control constructs • Implicit parameters • Movement EVENTs • Navigating documentation • Array and SETs

More Related