Jump to content

Josh

Staff
  • Posts

    23,417
  • Joined

  • Last visited

Everything posted by Josh

  1. Josh

    Programming Poll

    My resources are finite.
  2. That file contains a type that declares all the procedural functions, since they aren't part of a class.
  3. Josh

    Single-state Lua

    Lua script: referencetable={} reference={} referencetable[3]=reference function reference:test() print("hello") end Now how would you call reference:test() from the main program?: lua_getglobal("referencetable") lua_getfield()? //Need to find the table for the value "3". lua_getfield("test") //okay Now we have to push the reference table for the test function to use. How? You cannot get the global variable "reference" because it is just one of many tables the routine will create. lua_getfield uses a string to find the value, so if I use an object as the index it doesn't work: function CreateClass(modelreference) class={} classtable[modelreference]=class end
  4. for model in iterate(CurrentWorld().entities) do Print("Entity name = "..model:GetKey("name")) end
  5. Josh

    Programming Poll

    Well, the number of BlitzMax programmers in the world is pretty much static. The number of C++ programmers is infinite. So who do I want to sell to?
  6. Import framewerk and do what I did. It will automatically detect the exposed types.
  7. The Lua command dofile is used so that compiled script files can be run.
  8. The value parameter is the value that is stored for the key. The Lua function can be used to override that value. Normally the Lua GetKey() function just returns the value it receives. When any of those special keys are encountered, the return value is something else. You can retrieve keys from any entity at any time in Lua like this: entity:GetKey("mykey") Internally this will first look up the key for "mykey", then run it through the "GetKey()" script function and return whatever value that returns.
  9. I did something kind of dumb when attempting to implement a separate raycast algorithm for thick raycasts.
  10. Josh

    Loading A Scene

    Then you are in the same boat as before. The problem is getting Lua and C++ to interact. Right now you have limited means to do this. This can be improved if I add the following: -Add a command to retrieve the Lua state (virtual machine) from a world. -Expose the entire Lua command set in the DLL. Then you can call framewerk and your own C++ commands from Lua.
  11. Particles are a good choice for localized fog.
  12. Josh

    Lua work

    I've been revising the Lua design a bit. Ideally this should have been done six months ago, but I did not realize how popular it would be. During beta testing there wasn't much interest in it. That's understandable, because no one likes using beta software. As soon as it was released, suddenly there was some very advanced stuff being implemented immediately. This is great, and I can see my thoughts about how it would benefit us were correct. It also made me want to implement a single-state system so that we could really use Lua to its full potential. I spent all day on it, and I think it's done. I just have to finish making the changes to the class scripts. This wasn't my ideal way to develop, but if changes are to be made, they should be made now, not in three months.
  13. Josh

    Single-state Lua

    Well, I started reading, and even if I can make sense of it, if it isn't immediately obvious my users won't get it. And the whole point of Lua is to be easy. With a single-state system, here is what the directional light script looks like: require("scripts/base") --Initially set all the functions we might want, so we --don't have to keep track of which ones we actually declare. light_directional_InitDialog=base_InitDialog light_directional_Spawn=base_Spawn light_directional_GetKey=GetKey light_directional_SetKey=SetKey light_directional_ReceiveMessage=base_ReceiveMessage light_directional_Kill=base_Kill function light_directional_InitDialog(grid) base_InitDialog(grid) group=grid:AddGroup("Light") group:AddProperty("Resolution",PROPERTY_CHOICE,"256,512,1024,2048") group:AddProperty("linearoffset",PROPERTY_VEC3,"0,1,2","Linear offset" ) group:AddProperty("shadowdistance",PROPERTY_VEC3,"","Shadow distance" ) group:AddProperty("Range",PROPERTY_FLOAT) group:Expand(1) end function light_directional_Spawn(model) local entity=base_Spawn(model) entity.model:SetKey("resolution","2") entity.light=CreateDirectionalLight(entity.model) return entity end function light_directional_Kill(model) local entity=entitytable[model] if entity~=nil then if entity.light~=nil then entity.light:Free() entity.light=nil end end base_Kill(model) end function light_directional_GetKey(model,key,value) local entity=entitytable[model] if entity==nil then return value end if entity.model==nil then return end if entity.light==nil then return base_GetKey(model,key,value) else if key=="linearoffset" then return entity.light:GetShadowOffset(0,0)..","..entity.light:GetShadowOffset(0,1)..","..entity.light:GetShadowOffset(0,2) elseif key=="shadowdistance" then return entity.light:GetShadowDistance(0)..","..entity.light:GetShadowDistance(1)..","..entity.light:GetShadowDistance(2) elseif key=="range" then return entity.light:GetRange() elseif key=="shadowresolution" then resolution=entity.light:GetShadowmapSize() if resolution==256 then return 0 elseif resolution==512 then return 1 elseif resolution==1024 then return 2 elseif resolution==2048 then return 3 else return -1 end else return base_GetKey(model,key,value) end end end function light_directional_SetKey(model,key,value) local entity=entitytable[model] if entity==nil then return 1 end if entity.model==nil then return 1 end if entity.light==nil then return base_SetKey(model,key,value) else if key=="resolution" then if value=="0" then entity.light:SetShadowmapSize(256) elseif value=="1" then entity.light:SetShadowmapSize(512) elseif value=="2" then entity.light:SetShadowmapSize(1024) elseif value=="3" then entity.light:SetShadowmapSize(2048) end elseif key=="range" then entity.light:SetRange(value) elseif key=="shadowdistance" then local offset=string.Explode(value,",") x=tonumber(offset[1]) y=tonumber(offset[2]) z=tonumber(offset[3]) if x==nil then x=0 end if y==nil then y=0 end if z==nil then z=0 end entity.light:SetShadowDistance(x,0) entity.light:SetShadowDistance(y,1) entity.light:SetShadowDistance(z,2) elseif key=="linearoffset" then local offset=string.Explode(value,",") x=tonumber(offset[1]) y=tonumber(offset[2]) z=tonumber(offset[3]) if x==nil then x=0 end if y==nil then y=0 end if z==nil then z=0 end entity.light:SetShadowOffset(x,1.0,0) entity.light:SetShadowOffset(y,1.0,1) entity.light:SetShadowOffset(z,1.0,2) else return base_SetKey(model,key,value) end end return 1 end
  14. I have no idea what a kg is. I know it's 1000 grams, but I don't know how much that weighs.
  15. If you want framewerk to be a C++ source code you will have to work with it and Lua. There is a way to expose your C++ classes to Lua, which could make this work very nice and seamlessly, but we need to take one step at a time.
  16. Josh

    Loading A Scene

    2.3 is the same as 2.28, with extra features. There isn't a new way to render water because it hasn't changed.
  17. Brucey on the BlitzMax forum would be the best person to talk to. I think compiling in BMX would be best because then I could add this functionality into the editor. I don't know enough about how it works yet, so your experimentations are really helpful.
  18. Josh

    Videos

    Use a third-party lib.
  19. Oh, I am very impressed with what you have done so far.
  20. Josh

    Single-state Lua

    When I think about the single state with renamed entity functions, it makes sense when I consider the resulting combined source with the main program, and all the included model scripts. The source code the engine makes by doing different script files would look something like this: Graphics(800,600) while KeyHit()==0 do update() render() flip() end function light_directional_Spawn(model) --do some stuff end function light_directional_Kill(model) --do stuff end function vehicle_truck_Spawn(model) --do some stuff end function weapon_gun_Spawn(model) --do stuff end It looks a lot like a C program, like the Quake 3 source for example. It makes sense and seems like a good approach.
  21. Lua inheritance seems extremely workaroundish to me: http://lua-users.org/wiki/InheritanceTutorial
  22. If that's the model I think it is, I did not pay to have it made, I only asked him if I could use it with Character Shop.
  23. There are other ways of doing inheritance, but my function renaming approach seemed the simplest to understand. One consideration was that if I was having trouble understanding table inheritance, many of my users would too, and that would have a negative impact on their experience and my sales.
  24. Josh

    Single-state Lua

    The function calls for an object, so an integer would not work. Lua is a little different because integers, strings, objects, and tables can all be used in the same parameter. This function has to work with C++ and every other language, so the flexibility of Lua is not something it can support.
×
×
  • Create New...