Crystal Space
Welcome, Guest. Please login or register.
September 02, 2014, 01:31:40 am

Login with username, password and session length
Search:     Advanced search
9009 Posts in 2043 Topics by 8371 Members
Latest Member: Berger4
* Home Help Search Login Register
+  Crystal Space
|-+  Associate Projects
| |-+  CEL Discussion
| | |-+  Binding keyboard events to craft methods
« previous next »
Pages: [1] Print
Author Topic: Binding keyboard events to craft methods  (Read 4201 times)
Leetonicon
Newbie
*
Posts: 15


View Profile Email
« on: June 30, 2007, 03:02:57 am »

Basically, trying to implement the CEL hoverdemo solely in XML (i.e. for celstart)

Using some of the sample celstart apps, I think it mostly working.  However, I can't get pressing keys to call the craft methods.

What I'm doing (and I can post the whole code somewhere if that would be easier)


    <addon plugin="cel.addons.xmlscripts">
      <!-- this is legacy! -->
      <pcfactory>cel.pcfactory.pccommandinput</pcfactory>
      <pcfactory>cel.pcfactory.defaultcamera</pcfactory>
      <pcfactory>cel.pcfactory.actormove</pcfactory>
      <pcfactory>cel.pcfactory.mesh</pcfactory>
      <pcfactory>cel.pcfactory.linmove</pcfactory>
      <pcfactory>cel.pcfactory.colldet</pcfactory>
      <pcfactory>cel.pcfactory.zonemanager</pcfactory>
      <pcfactory>cel.pcfactory.properties</pcfactory>
      <pcfactory>cel.pcfactory.mechsys</pcfactory>
      <pcfactory>cel.pcfactory.mechobject</pcfactory>
      <pcfactory>cel.pcfactory.hover</pcfactory>
      <pcfactory>cel.pcfactory.craft</pcfactory>   

        <script name="camera">
     <event name="realinit">
       <var name="pcmech" value="pc(pcmechobject)" />
       <var name="pccam" value="pc(pcdefaultcamera)" />
       <var name="pccraft" value="pc(pccraft)" />

     </event>

     <event name="pccommandinput_quit1">
       <quit/>
     </event>
     <event name="pccommandinput_forward1">
       <default propclass="?pccraft" />
       <action id="actid(ThrustOn)" />
     </event>
     <event name="pccommandinput_forward0">
       <default propclass="?pccraft" />
       <action id="actid(ThrustOff)" />
     </event>
(... more input events ...)

Also, in the entity object, I did specifiy that this entity should contain a propclass named pccraft and did a bunch of action name="SetXXX"><par name="xxx" float = "yy.y" /></action>'s


I do set up so that up arrow and w both map to forward and the original code (which called eval setforce(pcmesh)) did work...

Any thoughts what I'm missing?
Logged
genjix
Jr. Member
**
Posts: 53


View Profile
« Reply #1 on: July 02, 2007, 01:47:45 pm »

Hi!

You need to bind the keys before the messages get sent.

Code:
    <addon entityname="camera" plugin="cel.addons.celentity">
      <propclass name="pccommandinput">
        <action name="Bind">
          <par string="trigger" name="up"/>
          <par string="command" name="forward"/>
        </action>
      </propclass>
  </addon>

If the keys are binded, did you try printing out a debug message under each of those events?

Code:
    <event name="pccommandinput_forward1">
       <print value="'pressed forwards!'" />  <!-- " then ' as the print expects a value. 'df' means a string -->
       <default propclass="?pccraft" />
       <action id="actid(ThrustOn)" />
     </event>
Logged
Leetonicon
Newbie
*
Posts: 15


View Profile Email
« Reply #2 on: July 05, 2007, 02:53:31 pm »

Thanks for the response, Genjix.
Unfortunately, the events are being fired just fine... the problem, as near as I can tell, is that I'm not doing the syntax of the XML correctly...

I would think that:
<event name="pccommandinput_forward1">
       <default propclass="?pccraft" />
       <action id="actid(ThrustOn)" />
     </event>

Means using propclass pccraft, apply the action "ThrustOn" ...

but if I replace actid(ThrustOn) with actid(ObviousilyBogusFunction) nothing changes and I don't get an error message.

At any rate, I'm in the middle of trying to upgrade my Linux box to the latest FC7 and then rebuild the latest CS/CEL and try again using python vs just the XML.

Logged
genjix
Jr. Member
**
Posts: 53


View Profile
« Reply #3 on: October 07, 2007, 04:00:05 pm »

The xml action script for the craft controller is incomplete. I only see

cel.action.SetSliding
cel.action.SetBraking
cel.action.SetThruster
cel.action.SetAfterBurner

When I am next at my computer I will fix this! promise Smiley
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.433 seconds with 15 queries.