Jump to content

DarthRaff

Members
  • Posts

    152
  • Joined

  • Last visited

Posts posted by DarthRaff

  1. Hello,

     

    Can someone, please, tell me what am i doing wrong ? i'm trying to translate it from lua with no success, thank you very much.

      if (KeyHit(KEY_E)) {
       TPick pick;
       pick = CameraPick(&pick,cam,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,3.0),0,0);
       if (pick) {
     do {
      if (GetEntityKey(pick.entity,"class") == ENTITY_MODEL) {
       break;
      }
      pick.entity = pick.entity.parent;
     } while (!pick.entity);
     if (pick.entity) {
      SendEntityMessage(pick.entity,"use");
     }
       }
      }
    

  2. Hello,

     

    I can't find any example of an object receiving a message of "use" ( sent by the player, i suppose ), and how it works. I found how to send a message when a key is pressed but not how to receive it, can someone, please, help me with that ? I'm very confused with that, thank you

  3. Well, my intention is to check the door system in the editor without use any game or controller script, but don't know if it's possible. I tried a pick function i found in a script but, don't know if i can do it that way. Actually there is no message sending or received, yet.

     

    Is this code correct ?

     if KeyHit(KEY_E)==1 then
      pick=CameraPick(fw.main.camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0)
      if pick~=nil then
       repeat
     if pick.entity:GetClass()==ENTITY_MODEL then
      break
     end
     pick.entity=pick.entity.parent
       until pick.entity==nil
       if pick.entity~=nil then
     --pick.entity:SendMessage("use",controller,0)
     self:CheckDoor()
     self.model:SetKey("estado",self.estado)
       end
      end
     end
    

     

    i' d like to know if it's correct and can do it that way before do the next step, sorry for being bored and thank you.

  4. Ok, thank you for the advise, i changed the spelling and the position of the functions in the script.

     

    Thank you very much for the answer Macklebee, i will try the pick and message.

  5. Hey,

     

    I tried this and works perfectly but just in the first object i created. If i try to put more than one object then it doesn't work in the others , just in the first one. But the position, rotation, and all that props works in all the objects. How to do, please, for have the other functions working in all the objects of the same class ?

     

    Here is the code:

    require("scripts/class")
    require("Scripts/constants/engine_const")
    local class=CreateClass(...)
    function class:InitDialog(grid)
    self.super:InitDialog(grid)
    --group=grid:AddGroup("type")
    --group:AddProperty("tipo",PROPERTY_STRING)
    group=grid:AddGroup("estados")
    group:AddProperty("initialrot",PROPERTY_INTEGUER)
    group:AddProperty("finalrot",PROPERTY_INTEGUER)
    --group:AddProperty("rot",PROPERTY_INTEGUER)
    group:AddProperty("estado",PROPERTY_STRING)
    group:AddProperty("speed",PROPERTY_FLOAT,"-1,1,1")
    group:Expand(1)
    end
    function class:CreateObject(model)
    local object = self.super:CreateObject(model)
    --object.model:SetKey("tipo","")
    object.model:SetKey("initialrot",90)
    object.model:SetKey("finalrot",0)
    object.model:SetKey("estado","0")
    object.model:SetKey("speed",0.6)
    function object:UnlockKeys()
     self.estado = self.model:GetKey("estado")
    end
    function object:Update()
     if KeyHit(KEY_E)==1 then
      self:CheckDoor()
      self.model:SetKey("estado",self.estado)
     end
    end
    function object:CheckDoor()
     if EntityDistance(fw.main.camera,self.model) < 3 then
      if self.estado == "0" then
       self.estado = "1"
       --self.model:OpenDoor()
      else
       self.estado = "0"
      end
     end
    end
    end
    

     

    I tried my self but can't find the solution, thank you

  6. Thank you very much, that's what i looking for by now. I'm try to translate a door system in lua. I have it working on c++ but i want to see the behaviour of the system in the editor. Thank you again

  7. Hello,

     

    I have that code that works perfect:

    require("scripts/class")
    require("Scripts/constants/engine_const")
    local class=CreateClass(...)
    function class:InitDialog(grid)
    self.super:InitDialog(grid)
    group=grid:AddGroup("Rotation")
        group:AddProperty("rotationspeed",PROPERTY_VEC3)
    --group:AddProperty("rotationspeed",PROPERTY_FLOAT)
    end
    function class:CreateObject(model)
        local object = self.super:CreateObject(model)
        object.model:SetKey("rotationspeed","0.0,1.0,0.0")
    --object.model:SetKey("rotationspeed","1.0")
    function object:SetKey(key,value)
     if key=="rotationspeed" then
      self.rotationspeed = StringToVec3(value)
      --self.rotationspeed=(value)
     else
      return self.super:SetKey(key,value)
     end
     return 1
    end
    function object:Update()
     if KeyHit(KEY_E) == 1 then
      self.rotationspeed.y=self.rotationspeed.y*-1
      --self.rotationspeed=self.rotationspeed*-1
     end
     model:Turn(self.rotationspeed,0)
        end
    end
    

     

    If i comment the rotationspeed Vec3 property and uncomment the rotationspeed float property, and the other changes, it doesn't work. I try to look in the scripts and models folders to do my self but can't find the solution.

     

    I want to use just a float version of the rotationspeed property. can someone, please, help me ? thank you

  8. Hello everybody and very happy new year !!

     

    i usually program in c++ but i wanted to try lua for doors in the editor. I have a door sistem writed in c++ that works and i changed a little the code to addapt it to lua but not work. <So i decided to try something easier and wrote a simple program that creates a cube rotating to the right and when hit key e the rotation direction have to change but the direction changes from the beggining and does nothing when press e. So, please, what am i doing wrong ? here is the code and thanks in advance

    require("Scripts/constants/engine_const")
    RegisterAbstractPath("")
    Graphics(1024,768)
    fw=CreateFramework()
    cam=fw.main.camera
    cam:SetPosition(Vec3(0,0,-2))
    light1 = CreateDirectionalLight()
    light1:SetRotation(Vec3(45,45,0))
    mesh=CreateCube()
    mesh:SetPosition(Vec3(0,0,0))
    vel=0.5
    while KeyHit(KEY_ESCAPE)==0 do
    if KeyHit(KEY_E) then
     vel=-0.5
    end
    mesh:Turn(Vec3(0,vel,0))
    fw:Update()
    fw:Render()
    Flip(0)
    end
    

  9. Just a random guess, would +model work instead of +mesh?

     

    not working, thank you. But if i try without +mesh like this : obj2gmf "name.obj" +scale 0.1 -nocolor,

    then it works but not performs the scale, don't know why.

  10. Hello,

     

    can someone tell me how can i use the obj converter from cmd, please?

     

    I'm trying like this: obj2gmf +mesh "name.obj" +scale 0.1 -nocolor, and it doesn't work, but if i use it

    by clicking in it, then works but can't scale.

     

    thank you.

  11. Hello,

     

    sorry, because i'm not a great programmer, and, if it was so simple, maybe it just was already made, but when you open

    the editor and have a new object that not was in the list last time you opened the editor, it make a phy file of that object, automatically.

    And, if you close the editor, erase the phy file, scale the object and open again the editor, a new phy file of that object, is created and

    works perfectly. So why is so difficult or impossible to make a script that erases and creates a new phy file from the object you scale, like

    when the editor is opened? or just the same part of program that creates the file when open the editor?

     

    Sorry again because probably it's not possible.

  12. Yes feeling stupid more and more. You are right now Framewerk working. I hate when i forget things thinking i have all correctly copied. I make other users, who kindly helps me, waste theire time. Sorry thousand times. Very angry with myself. Sorry again and thank you very much.

  13. Sorry, i'm feeling so stupid. I copied the shaders.pak the first time but then i forgot it the following time. Now working all except the transparency. I need to set it correctly but i don't know how to set the layer or whatever by now. Thank you very much and sorry :) .

×
×
  • Create New...