Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

zimberzimber wrote:Icon atlases also require a ^2 dimension though.
No they don't.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

minmay wrote:
zimberzimber wrote:Icon atlases also require a ^2 dimension though.
No they don't.
Game crashed when I attempted to use a non ^2 dimension for an atlas though, same error
My asset pack [v1.10]
Features a bit of everything! :D
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

You are probably trying to use DXT compression on an image without width and height divisible by 4 again. Save it in RGBA8 uncompressed with no mipmaps. Which you should have always been doing in the first place for GUI elements, since they don't use mipmaps and, again, DXT compression on GUI elements looks fricking awful.

Edit: To be 100% clear. This is not a Grimrock limitation. S3 texture compression (which is what we mean when we say "DXT") is based on blocks of 4x4 pixels. A DXT compressed texture definitionally does not support dimensions that are not divisible by 4. When you save a 254x255 DXT1 image with Paint.net or the GIMP plugin or whatever, the definition of the decompression algorithm is no longer sufficient to decompress the image, so you are trying to rely on DirectX, OpenGL, and the GPU all using the same nonstandard decompression method that Paint.net does. (Spoiler alert: they don't)

DXT looks awful for most 2D images because it blurs pixels and greatly reduces color resolution. The lack of color resolution is the main reason it gives terrible results for RGB normal maps; the green/alpha format used by Grimrock 2 is a workaround to get better color resolution. Most 2D stuff and especially GUI elements relies on sharp lines and crisp colors. 3D textures, on the other hand, rarely need sharp lines or full 24-bit color resolution because the colors are getting transformed by perspective and lights and filtering in the 3D world anyway.
Last edited by minmay on Wed Dec 07, 2016 2:39 am, edited 2 times in total.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Are you sure that it just wasn't dxt ~non divisible by 4?

A single row atlas is not likely to be a power of two image; being too small, or way too big.
ColdDeadStone
Posts: 24
Joined: Sat Nov 26, 2016 12:12 pm

Re: Ask a simple question, get a simple answer

Post by ColdDeadStone »

Hello! Its not the best english, apology! I have a simple question and maybe somebody have a simple answer. Its about a local variable (LV). Its NOT about the code below, its about "how to" use the local variable in cases like this.

The Counter is set to 1. The LV then should be 1 too. Now i want to call a function named action1(). My question is: How can i use the LV to call the function same as the Value of the counter? Counter is at 2 > call function action2() and so on.

Code: Select all

function doNext()
local next = nextcounter.counter:getValue()
action..next() << dont work this way.
action(next) << dont work this way either.
end

function action1()
hudPrint("Hi")
end

function action2()
hudPrint("Bye")
end
Thank you for reading and any help :)
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Looks like you need to review the syntax of Lua. This is what you wanted:

Code: Select all

function doNext()
local next = nextcounter.counter:getValue()
self["action"..next]()
end

function action1()
hudPrint("Hi")
end

function action2()
hudPrint("Bye")
end
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
ColdDeadStone
Posts: 24
Joined: Sat Nov 26, 2016 12:12 pm

Re: Ask a simple question, get a simple answer

Post by ColdDeadStone »

minmay wrote:Looks like you need to review the syntax of Lua.
Yes, that is exactly what i was looking for :) Thanks alot! And about the Syntax, i searched yesterday already for a solution on sites like lua-users.org and lua.org but i never used a local variable for things like that and i simply didnt know how to "write" it. Local Variables for me was restricted to things like:

Code: Select all

for i=1,100 do
local mylevers = findEntity("nicelever"..i)
if mylevers.lever:isActivated() then
mylevers.lever:toggle()
instead of write 100 times nicelever1.lever:toggle() ...

Im used to write more like this:

Code: Select all

function checkaction()
if nextcounter.counter:getValue() == 1 then
action1()
elseif
...bla bla
I thought that was good idea to have more control but it wasnt a good idea... Now i rewrite everything in my "dungeon" but got stucked on this one. Anyway, thanks alot for helping and have a nice Day! :)
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

3 monster related questions:

1) How do I deal damage directly to a monster through a script? (aka champion:damage(num, string) but for monsters)
Setting health to a lower value doesn't count. :v

2) What monster flags are there, and what is their effect?
I recall there was something about not missing attacks, attacks/damagers trearing the monster as if its not there, but I can't find the thread where I saw it.

3) Are there any other monster shapes other than "1x1" and "cross"?
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

zimberzimber wrote:2) What monster flags are there, and what is their effect?
I recall there was something about not missing attacks, attacks/damagers trearing the monster as if its not there, but I can't find the thread where I saw it.
viewtopic.php?f=22&t=7951&start=1220#p106377

Can be found by searching the forum for...
getMonsterFlag
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

zimberzimber wrote:1) How do I deal damage directly to a monster through a script? (aka champion:damage(num, string) but for monsters)
Setting health to a lower value doesn't count. :v
This functionality doesn't exist in the user scripting interface.
zimberzimber wrote:2) What monster flags are there, and what is their effect?
viewtopic.php?f=22&t=7951&p=106377#p106377
zimberzimber wrote:3) Are there any other monster shapes other than "1x1" and "cross"?
"3x3" but I haven't tested how well it works.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply