Jump to content

Calling Spawn LUA Function from C++


Birdman
 Share

Recommended Posts

I used this code in a vehicle Lua:

 

function class:CreateObject(model)
..
SetGlobalObject("vhcobj",entity.vehicle);

 

The problem is that now CreateObject don't exist in the new vehicle lua, instead it was replaced with SPAWN.

 

I have no idea how to call SPAWN from c++ (My project runs a vehicle from C++, so what i do is, make a global object so i can control the car from Code).

 

When i used LoadModel() in c++ CreateObject() was called from the LUA, so idk what to do now.

 

Thanks a lot in advance.

Link to comment
Share on other sites

The vehicle_viperscout.lua in Scripts folder starts like this:

 

dofile("scripts/base.lua")
dofile("scripts/math.lua")
steerrate=2.0
steerlimit=30
function Spawn(model)
local entity=base_Spawn(model)
local pivot
suspensionlength=0.2
local springconstant=20.0
local springdamper=150.0

entity.vehicle=CreateVehicle(model)

 

Maybe i got confused, all i wanted is to update an old project to the last version and i found this script.

So what is this script used for? The code in Scripts folder looks more advanced than the one in the private folder.

Link to comment
Share on other sites

what version are you using? the base.lua file has not been used in about 2 years since we switched from multi-state to single state lua, and even then it only existed for a couple of months. download a fresh install of the latest and greatest LE version and use the script that daimour shows as everyone is more familiar with that setup.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I updated to the last version, maybe that file wasn't downloaded, i might delete all and redo my installation then.

 

But before this last version i never saw a version of viperscout with spawn, in fact in LE 1 i didnt have a version with spawn :). Then i updated to version 2 and got this file somehow.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...