Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, SBGuy, Petra, flink, 1 invisible), 699 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[GSTScript] 0.9.2 released #366625
04/05/11 19:39
04/05/11 19:39
Joined: Jun 2001
Posts: 1,004
Dossenbach
N
nfs42 Offline OP
Serious User
nfs42  Offline OP
Serious User
N

Joined: Jun 2001
Posts: 1,004
Dossenbach
do you want to let your users mod your games ?

here is the second release of GSTScript supporting lua 5.1.4
some standard classes are defined like EngineClass, EntityClass, CameraClass

you can register lite-c functions in lua and call lua functions from lite-c.

more...
happy scripting

Click to reveal..
Code:
-- require "GSTDebug"
	-- initialize global objects
	engine = EngineClass()
	camera = CameraClass(engine:camera())
	gImage = ImageClass()
	gSound = SoundClass()
	gSound:Load("data/sounds/impact.wav")
	engine:SetVideoMode(2) -- 1=windowed, 2= fullscreen
	engine:VideoWindow(0,0,0,0,0,"GSTScript TEST V 0.9.2 by GSTools/nfs42")
	camera:SetPan(0)
	galpha_step = -10
	gInitialized = 0


----------------------------------------------------------------------------------------
-- function: entity
-- purpose:  to be called from lite-c entity action every frame 
--------------------------------------------------------------------
	
function entity()

	gModel = EntityClass(engine:my())
	if (lastx == 0) then
		lastx = gModel:GetX()
		lasty = gModel:GetY()
	end

--	gModel:SetX(gModel:GetX() - 1 * engine:time_step())
--	gModel:SetY(gModel:GetY() - 1 * engine:time_step())
	gModel:SetPan(gModel:GetPan() - 15 * engine:time_step())
	gModel:SetTilt(gModel:GetTilt() - 15 * engine:time_step())
	gModel:SetLightRange(gModel:GetLightRange()+1)
--	gModel:SetBlue(0)
	gModel:SetGreen(255)
	gModel:SetRed(255)
	gModel:SetU(gModel:GetU() + 0.1 * engine:time_step())
	gModel:SetV(gModel:GetV() + 0.1 * engine:time_step())
	if (gModel:GetAlpha() < 0) then galpha_step = 10 end
	if (gModel:GetAlpha() > 100) then galpha_step = -10 end
	gModel:SetAlpha(gModel:GetAlpha() + galpha_step * engine:time_step())
	TESTENT(gModel:Handle())
end


----------------------------------------------------------------------------------------
-- function: cameramove
-- purpose:  controls cameramove in lua
--------------------------------------------------------------------
function cameramove()
	if engine:KeyPressedByName("cuu") then --> VK_UP
		camera:SetTilt(camera:GetTilt() + 2 * engine:time_step())
	
	elseif engine:KeyPressedByName("cud") then --> VK_DOWN
		camera:SetTilt(camera:GetTilt() - 2 * engine:time_step())
	
	elseif engine:KeyPressed(75) then --> VK_LEFT
		camera:SetPan(camera:GetPan() + 5 * engine:time_step())

	elseif engine:KeyPressed(77) then --> VK_RIGHT
    camera:SetPan(camera:GetPan() - 5 * engine:time_step())

  elseif engine:KeyPressed(33) then --> VK_PRIOR
    camera:SetPan(camera:GetPan() + 0.1 * engine:time_step())

  elseif engine:KeyPressed(34) then --> VK_NEXT
    camera:SetPan(camera:GetPan() + 0.1 * engine:time_step())

  end
end

----------------------------------------------------------------------------------------
-- function:	cameramove
-- purpose:		controls cameramove in lua
--						if first call from engine > init lua
--------------------------------------------------------------------
function GameInit()
	print("\nGame init")
	gImage:Load("items.png.pcx#1#1#32#32") -- load an image
	mouse_map(gImage:Handle())				-- set mouse_map
	if gModel then -- if gModel exists, set lightrange to a default value
		gModel:SetLightRange(0)
		gModel:SetScaleX(1)
		gModel:SetScaleY(1)
		gModel:SetScaleZ(1)
	end 
	gInitialized = 1						-- initialized
	print("\nGame init done")
end

----------------------------------------------------------------------------------------
-- function:	MainStep()
-- purpose:		is called by the engine every frame
--------------------------------------------------------------------
function MainStep()
	if (gInitialized == 0) then GameInit() end

	cameramove()
	
	engine:draw_text("LUA: <h>elp",250,250,255,25,10) 
	local x, y = engine:GetMousePos()
	local l, m, r = engine:GetMouseButtons()

	-- engine:SetMousePos(x + 5, y + 5)
	engine:draw_text("LUA:Mouse: "..x..":"..y,50,100,255,25,10) 
	engine:draw_text("LUA:MButt:"..l..":"..m..":"..r,50,120,255,25,10) 
	local h = EntityClass(engine:ObjectUnderMouse())
	if (h:Handle()>0) then
		engine:draw_text("LUA:I am under the mouse",50,150,255,25,10) 
		if (gObjectUnderMouse) then
			DrawBoundingBox(gObjectUnderMouse:Handle())
		end
		gObjectUnderMouse = h
	end

  local t = Client_GetTicks()
  local iTimeSinceLastFrame = gLastFrameTime and (t - gLastFrameTime)
  
 	if engine:KeyPressedByName("h") then
		engine:draw_text("LUA:INFO: reload script with <r>",250,270,255,25,10) 
		engine:draw_text("LUA:INFO: camera up with <cuu>",250,290,255,25,10) 
		engine:draw_text("LUA:INFO: camera down with <cud>",250,310,255,25,10) 
		engine:draw_text("LUA:INFO: resize entity <s>",250,330,255,25,10) 
		engine:draw_text("LUA:INFO: sound with <F1>",250,350,255,25,10) 
--		engine:draw_text("LUA:INFO: reload script with <r>",250,370,255,25,10) 
	end
   	if engine:KeyHitByName("F1")>0 then
		gSound:Play(100,100)
	end
	if engine:KeyHitByName("F2")>0 then
		gSound:Pause()
	end	
	if engine:KeyHitByName("F3")>0 then
		gSound:Start()
	end
	if engine:KeyHitByName("s")>0 then
		if gModel then -- if gModel exists, set lightrange to a default value
			gModel:SetScaleX(1)
			gModel:SetScaleY(1)
			gModel:SetScaleZ(1)
		end 
	end
  --print("\n75:",engine:KeyHit(75))
	--print("\nAA:",engine:KeyHit(30))
	
	
  gLastFrameTime = Client_GetTicks()
end




Andreas
GSTools - Home of
GSTScript 0.9.8: lua scripting for A6/7/8
GSTNet 0.7.9.20: network plugin for A6/7/8
GSTsqlite 1.3.7: sql database plugin for A6/7/8
3DGS Codebase: 57 snippets || 3DGS Downloads: 248 files
[GSTScript] 0.9.4 released [Re: nfs42] #369028
04/30/11 19:47
04/30/11 19:47
Joined: Jun 2001
Posts: 1,004
Dossenbach
N
nfs42 Offline OP
Serious User
nfs42  Offline OP
Serious User
N

Joined: Jun 2001
Posts: 1,004
Dossenbach
added access to global lua variables from lite-c


Click to reveal..
Code:
int i;
	var v;
	STRING* sAuthor = str_create("");
	STRING* sVersion = str_create("");
	
	//GSTScript_SetGlobalString(_str("author"), _str("set author from lite-c")); //uncomment to overwrite the global string author from lite-c
	
	while(1) {
		mouse_pos.x = mouse_cursor.x;
		mouse_pos.y = mouse_cursor.y;
  		wait(1);
 	 	GSTScript_NotifyListener(_str("GSTError"));			// notify an gst standard listener
 	 	GSTScript_GetGlobalInt(_str("gCounter"), i);			// read a global lua int
 	 	GSTScript_GetGlobalVar(_str("gVarCounter"), v);		// read a global lua var
 	 	GSTScript_GetGlobalString(_str("author"), sAuthor);// read a global lua string
 	 	GSTScript_GetGlobalString(_str("version"), sVersion);// read a global lua string
 	 	draw_text(sAuthor,100,300,vector(250,520,520));		//draw strings
 	 	draw_text(sVersion,100,320,vector(250,520,520));
 	 	diag_var("\nlite-c: ELAPSED TIME = %1.5f",i);		//diag lua global numbers
 	 	diag_var("\nlite-c: gVarCounter = %1.5f",v);
 	 	diag("\nlite-c:"); diag(sAuthor);						// diag strings
		GSTScript_SetGlobalInt(_str("gCounter"), i + 1);	// change a global lua int
		GSTScript_SetGlobalVar(_str("gVarCounter"), v + 0.1);	// change a global lua number
 	 	
  }





Andreas
GSTools - Home of
GSTScript 0.9.8: lua scripting for A6/7/8
GSTNet 0.7.9.20: network plugin for A6/7/8
GSTsqlite 1.3.7: sql database plugin for A6/7/8
3DGS Codebase: 57 snippets || 3DGS Downloads: 248 files
[GSTScript] 0.9.4 tutorial [Re: nfs42] #369125
05/01/11 20:20
05/01/11 20:20
Joined: Jun 2001
Posts: 1,004
Dossenbach
N
nfs42 Offline OP
Serious User
nfs42  Offline OP
Serious User
N

Joined: Jun 2001
Posts: 1,004
Dossenbach
one little tutorial added to the wiki.
simple help library




Andreas
GSTools - Home of
GSTScript 0.9.8: lua scripting for A6/7/8
GSTNet 0.7.9.20: network plugin for A6/7/8
GSTsqlite 1.3.7: sql database plugin for A6/7/8
3DGS Codebase: 57 snippets || 3DGS Downloads: 248 files
Re: [GSTScript] 0.9.4 tutorial [Re: nfs42] #369890
05/08/11 14:41
05/08/11 14:41
Joined: Jun 2001
Posts: 1,004
Dossenbach
N
nfs42 Offline OP
Serious User
nfs42  Offline OP
Serious User
N

Joined: Jun 2001
Posts: 1,004
Dossenbach


Andreas
GSTools - Home of
GSTScript 0.9.8: lua scripting for A6/7/8
GSTNet 0.7.9.20: network plugin for A6/7/8
GSTsqlite 1.3.7: sql database plugin for A6/7/8
3DGS Codebase: 57 snippets || 3DGS Downloads: 248 files

Moderated by  aztec, Blink, HeelX 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1