⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lua-emulator-example.txt

📁 仙镜游戏源码,仅供学习!请勿用于非法应用!
💻 TXT
字号:
-- Script examples of Lua and YARE emulator of ragnarok online verison 0.1
-- by cix (cix987@123mail.cl)

--Multiple next example
-- Here is an example of doing a npc to say some text witha text boton
-- The next global variable tell you in wich page you are.
if next == 0 then
	sendMessage("This is the first page of the npc text")
	sendNext();
	-- The next two lines are important
	next = next +1
	return
elseif next == 1 then
	sendMessage("This is the second message form the npc")
	sendMessage("Here is another line of the second message")
	sendNext()
	next= next +1
	return
elseif next ==2 then
	sendMessage("Yet another page!!")
	sendMessage("And more lines!!")
	sendMessage("And more lines!!")
	sendMessage("And more lines!!")
	sendEnd()
end
--finish
--There must be a comment at the end of the script beacouse of a reading bug, soon to be fixed

-- MenuSelect example
--menuSelect variable tells you wich option has been selected form the menu, if it's 0 then nothing has been selected
--At the end of sendMenu strig argument there must be a :End: so the client knows where it ends.
if menuSelect == 0 then
	sendMenu("Option 1:Option 2:Option 3:End:")
	-- Return is important
	return
	end
if menuSelect == 1 then sendMessage("You have chosen the option 1")
elseif menuSelect == 2 then sendMessage("You have chosen the option 2")
elseif menuSelect == 3 then sendMessage("You have chosen the option 3")
end
sendEnd()
--finish

--Multiple menu example
-- To use multiple menus i recomend the use of next global.
if next == 0 then
	if menuSelect == 0 then
		sendMenu("Option 1:Option 2:Option 3:End:")
		return
		end
	if menuSelect == 1 then sendMessage("You have chosen the option 1") end
	if menuSelect == 2 then
		sendMessage("You have chosen the option 2")
		-- Here we don't check if menuSelect is 0, beacouse it isnt
		sendMessage("More options")
		sendMenu("Option 1:Option 2:End:")
		next = next + 1
		return
	end
	if menuSelect == 3 then sendMessage("You have chosen the option 3") end
	sendEnd()
end
if next == 1 then
	if menuSelect == 1 then sendMessage("Option 2 -> Option 1")
	elseif menuSelect == 2 then sendMessage("Option 2 -> Option 2")
	end
	-- Always a sendEnd(), if not, the window wont close.
	sendEnd()
end
--finish

The variables:
	Inside lua you can acces variables from the emulator, if they are changes they wont afect the 
	character, if you want to change variables use statusChange function.
	zeny
	class
	status_point
	skill_point
	hp
	max_hp
	sp
	max_sp
	option
	karma
	manner
	hair
	hair_color
	clothes_color
	weapon
	sheild
	head_top
	head_mid
	head_bottom
	name
	base_level
	job_level
	str
	agi
	vit
	int_
	dex
	luk

Contorl variables:
	menuSelect: The menu selection 0 if no menu has been selected
	next: Auxiliar varaible to control pages.
	input: The amount given by client when waitInput called

Comming soon
	inventory
	skill

The function made for lua to work with emulator:
sendMessage(char *msg)
	Send the message especified by msg.

sendMenu(char *options);
	Send a menu, the format is "options : options : ... :End:".

sendNext();
	Send a next buton.

sendEnd();
	Send a close buton.

changeJob(int job);
	Change the job, jobs are:
	JOB_NOVICE
	JOB_SWORDMAN
	JOB_MAGE
	JOB_ARCHER
	JOB_ACOLYTE
	JOB_MERCHANT
	JOB_THIEF
	JOB_KNIGHT
	JOB_PRIEST
	JOB_WIZARD
	JOB_BLACKSMITH
	JOB_HUNTER
	JOB_ASSASSIN

changeLook(int i, int j);
	Change the look.

warp(char *map,int x, int y);
	Warps to a location, map is the name of the map, example "prontera.gat" and x and y are the coordinates where is 
	warped

statusChange(int status,int new);
	Chnage a status, it's very important to use this function to change status, beacouse if this is not used
	the client doesn't know that a status has been changed.
	The status to change are:
	SP_SPEED not yet
	SP_BASEEXP
	SP_JOBEXP
	SP_KARMA
	SP_MANNER
	SP_HP
	SP_MAXHP
	SP_SP
	SP_MAXSP
	SP_STATUSPOINT
	SP_0a I don't know what it change.
	SP_BASELEVEL
	SP_SKILLPOINT
	SP_STR
	SP_AGI
	SP_VIT
	SP_INT	
	SP_DEX
	SP_LUK
	SP_13 I don't know what it change.
	SP_ZENY
	SP_15 I don't know what it change
	SP_NEXTBASEEXP This one work with table, the varible new won't be used.
	SP_NEXTJOBEXP This one work with table, the varible new won't be used.
	SP_WEIGHT
	SP_MAXWEIGHT
	SP_1a I don't know what it change.
	SP_1b I don't know what it change.
	SP_1c I don't know what it change.
	SP_1d I don't know what it change.
	SP_1e I don't know what it change.
	SP_1f I don't know what it change.
	SP_USTR not yet
	SP_UAGI not yet
	SP_UVIT not yet
	SP_UINT not yet
	SP_UDEX not yet
	SP_ULUK not yet
	SP_26 I don't know what it change.
	SP_27 I don't know what it change.
	SP_28 I don't know what it change.
	SP_ATK1 not yet
	SP_ATK2 not yet
	SP_MATK1 not yet
	SP_MATK2 not yet
	SP_DEF1 not yet
	SP_DEF2 not yet
	SP_MDEF1 not yet
	SP_MDEF2 not yet
	SP_HIT not yet
	SP_FLEE1 not yet
	SP_FLEE2 not yet
	SP_CRITICAL not yet
	SP_ASPD not yet
	SP_36 I don't know what it change.
	SP_JOBLEVEL

changeSavePoint(char *name,int x, int y);
	Change the save point to the especified location.
	name is the map name, x and y are the coordinates
	example: changeSavePoint("prt_in.gat",238,130)

waitInput();
	Send a wait input for something. I don't know how it quiet work.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -