1. I have 2 scripts one that spawns a barrel and when it hits the death trigger box it deletes it but it only spawns 2 barrels then stops running the script.
Barrel Spawn Script
- Code: Select all
obj = 0;
spawnID = 0; -- Set Exist to 0 to spawn 1st barrel
function onInit(objID)
sky.lprint("LUA: Script Active!");
obj = objID;
x,y,z = entity.getWorldPosition( obj ); --Get the world position of the barrel spawn point
end
function onUpdate(timeDelta)
if( entity.exist(spawnID) == 0 ) then -- check that barrel doesnt exist
spawnID = entity.spawnPreset("Barrel 05",x,y,z); -- Spawn the preset barrel05 @ world position of spawn point
entity.setTag(spawnID,"barrel01"); -- Set the Tag so barrel can be refrenced in other script.
end
end
--[[ Not Needed once deleted spawnID wont hold any value
function spawnBarrel (value)
if (value == "0") then
spawnID = 0;
end
end
]]--
Death Trigger Script.
- Code: Select all
obj = 0;
x,y,z =0;
function onInit(objID)
sky.lprint("LUA: Script Active!");
obj = objID;
playerID = entity.getIDFromTag("player");
x,y,z = entity.getPosition(entity.getIDFromTag("spawnpoint"));
y=y+2;
end
-- Updated every frame
function onUpdate(timeDelta)
end
function onTrigger_Enter(hitID)
entname = entity.getTagFromID(hitID) --Get the TAG from the ID of the entity that collided with the trigger box
if(entname == "Player")then -- the name of the player entity
sky.lprint("Player Detected..."); --Left for debugging
character.setPosition(hitID,x,y,z);
end
if(entname == ("barrel01"))then -- the name of the player entity
entity.delete( entity.getIDFromTag("barrel01") );
-- entity.callFn( obj, (entity.getIDFromTag("bar_spawn")), spawnBarrel, 0);
end
if(entname == ("barrel02"))then -- the name of the player entity
entity.delete( entity.getIDFromTag("barrel02") );
end
end
2. I have a verticle platform that moves up and down, when it hits xx limit then changes direction, it sort of works but the visual is well check out the video below.... it worked in gen1...
- Code: Select all
obj = 0;
direction=1.2;
x,y,z =0;
lift1ID = 0;
function onInit(objID)
obj = objID;
lift1ID = entity.getIDFromTag("lift1");
bodyID = physics.getBodyID(lift1ID);
end
function onUpdate(timeDelta)
x,y,z = entity.getPosition( lift1ID );
--sky.lprint("Position ok");
y=y+(direction)*timeDelta;
if (y > -6.79999) then direction = -2.2; --sky.lprint("lower limit")
end
if (y < -11.4529) then direction = 2.2; --sky.lprint("higher limit")
end
entity.setPosition(lift1ID,x,y,z);
wx,wy,wz = entity.getWorldPosition( lift1ID );
physics.setPosition(bodyID,wx,wy,wz);
end
The main idea I had for this one was to use it as part of a tutorial series for beginners to use to get used to the workflows in skyline, obviously the next scene would be a fps and 3rd scene a 3rd person then top down..
