Page 1 of 1
sample script (lua oop) textinput and buttons
Posted: Sun Jan 20, 2013 2:42 am
by comscript
for those who are interested by an area of text input
(example, open a secret door with a password)
Sample script
- connection between a pressure plate, and buttons in the interface (onDrawGui). (change properties of the buttons)
- input text
connection between a wall_button, textinput , secretdoor
to open the secret door, type "OPENSECRET" in the text area
you can use and modify this code
dungeon with source files
http://grimrock.nexusmods.com/mods/182
Re: sample script (lua oop) textinput and buttons
Posted: Sun Jan 20, 2013 3:27 am
by Komag
wow, thanks for working up this proof of concept, good example of what can be done
Re: samples scripts (textinput, buttons trace projectile)
Posted: Sat Feb 16, 2013 5:08 pm
by comscript
A simple function that can target a projectile
no timer, but the function ondrawGui
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onDrawGui = function (g)
script1.traceProjectile()
end
}
example:
when the projectile passes under a wooden door, the door closes.
spawn your projectile with a id=myspell
Code: Select all
defineSpell{
name = "myspell",
uiName = "myspell",
skill = "air_magic",
level = 0,
runes = "CH",
manaCost = 10,
onCast = function()
script1.mySpell()
end
}
function mySpell()
local spell
local dx, dy = getForward(party.facing)
local x = party.x + dx
local y = party.y + dy
if x<0 then x=0 end
if x>31 then x=31 end
if y<0 then y =0 end
if y>31 then y = 31 end
spawn("lightning_bolt",party.level,party.x+dx,party.y+dy,party.facing,"myspell")
end
in your script1
Code: Select all
xt = 50
yt = 50
function traceProjectile()
if myspell then
local x=myspell.x
local y=myspell.y
if xt ~= x or yt ~=y then -- execute only if the coordinates are changed
xt = x
yt = y
for i in entitiesAt(party.level,x,y) do
if i.name ~= "lightning_bolt" then
hudPrint(i.name)
end
if i.name == "dungeon_door_wooden" then i:close() end
end
end
else
xt = 50
yt = 50
end
end
The projectile closes all the doors under which it passes and display the names of all entities on its way.
Re: sample script (lua oop) textinput and buttons
Posted: Sat Feb 16, 2013 5:13 pm
by Komag
another very cool example, thanks!
Re: sample script (lua oop) textinput and buttons
Posted: Sat Feb 16, 2013 6:58 pm
by Diarmuid
This is the principle I've been using to track spells in exsp (
viewtopic.php?f=14&t=4459). I do not know if you were aware of it or if you checked the code...
I track spellProjectiles by Id, creating a spell object with properties and methods which is handled oop-style across the different functions. It also includes detection algorithms for various collisions and a hooks system, effects, monster methods, helper functions...
Re: sample script (lua oop) textinput and buttons
Posted: Sat Feb 16, 2013 10:42 pm
by JKos
That's a pretty cool script. I think that it would be a nice addition to the grimwidgets framework:
https://github.com/xanathar/grimwidgets
Thread:
viewtopic.php?f=14&t=4454
Would you like to participate and convert your script for the grimwidgets? We already have a similar 3D button made by Xanathar, but we don't have a text input field.
Re: sample script (lua oop) textinput and buttons
Posted: Sun Feb 17, 2013 12:12 pm
by comscript
You can use this code as you want, it's just an exemple it needs to be improved.